Refactor missed classes

This commit is contained in:
Darren Shepherd 2013-10-17 16:00:11 -07:00
parent 711ad386d1
commit 9cbb309d6b
15 changed files with 405 additions and 455 deletions

View File

@ -50,7 +50,7 @@ import com.cloud.netapp.dao.PoolDao;
import com.cloud.netapp.dao.VolumeDao;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;
@Component
@ -225,7 +225,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager
throw new ResourceInUseException("There are luns on the volume");
}
final Transaction txn = Transaction.currentTxn();
final TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
PoolVO pool = _poolDao.findById(volume.getPoolId());
if (pool == null) {
@ -388,7 +388,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager
}
Long volumeId = null;
final Transaction txn = Transaction.currentTxn();
final TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
NetappVolumeVO volume = null;
volume = _volumeDao.findVolume(ipAddress, aggName, volName);
@ -624,7 +624,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager
String[] result = new String[3];
StringBuilder lunName = new StringBuilder("lun-");
LunVO lun = null;
final Transaction txn = Transaction.currentTxn();
final TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
PoolVO pool = _poolDao.findPool(poolName);
@ -802,7 +802,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager
@DB
public void destroyLunOnFiler(String lunName) throws InvalidParameterValueException, ServerException{
final Transaction txn = Transaction.currentTxn();
final TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
LunVO lun = _lunDao.findByName(lunName);

View File

@ -42,8 +42,10 @@ import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
import org.apache.cloudstack.api.command.admin.host.AddSecondaryStorageCmd;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@ -51,6 +53,7 @@ import org.springframework.stereotype.Component;
import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.HashMap;
@ -159,7 +162,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
mockHost.setResource("com.cloud.agent.AgentRoutingResource");
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
mockHost = _mockHostDao.persist(mockHost);
@ -170,7 +173,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
throw new CloudRuntimeException("Error configuring agent", ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -256,7 +259,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
private void handleSystemVMStop() {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
if (this.mode.equalsIgnoreCase("Stop")) {
txn.start();
@ -279,7 +282,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
throw new CloudRuntimeException("Unable to get host " + guid + " due to " + ex.getMessage(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -323,7 +326,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
mockHost.setResource(resource);
mockHost.setVmId(vmId);
Transaction simtxn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy simtxn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
simtxn.start();
mockHost = _mockHostDao.persist(mockHost);
@ -334,7 +337,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
+ ex.getMessage(), ex);
} finally {
simtxn.close();
simtxn = Transaction.open(Transaction.CLOUD_DB);
simtxn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
simtxn.close();
}
@ -366,7 +369,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
@Override
public MockHost getHost(String guid) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
MockHost _host = _mockHostDao.findByGuid(guid);
@ -382,7 +385,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
throw new CloudRuntimeException("Unable to get host " + guid + " due to " + ex.getMessage(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -391,7 +394,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
public GetHostStatsAnswer getHostStatistic(GetHostStatsCommand cmd) {
String hostGuid = cmd.getHostGuid();
MockHost host = null;
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
host = _mockHostDao.findByGuid(hostGuid);
@ -404,11 +407,11 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
throw new CloudRuntimeException("Unable to get host " + hostGuid + " due to " + ex.getMessage(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
Transaction vmtxn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy vmtxn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
vmtxn.start();
List<MockVMVO> vms = _mockVmDao.findByHostId(host.getId());
@ -435,7 +438,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
+ ex.getMessage(), ex);
} finally {
vmtxn.close();
vmtxn = Transaction.open(Transaction.CLOUD_DB);
vmtxn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
vmtxn.close();
}
}

View File

@ -76,7 +76,7 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.template.TemplateProp;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.VirtualMachine.State;
@ -120,7 +120,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
VMTemplateDao templateDao;
private MockVolumeVO findVolumeFromSecondary(String path, String ssUrl, MockVolumeType type) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
String volumePath = path.replaceAll(ssUrl, "");
@ -141,7 +141,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Unable to find volume " + path + " on secondary " + ssUrl, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -154,7 +154,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
return new PrimaryStorageDownloadAnswer("Can't find primary storage");
}
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockStoragePoolVO primaryStorage = null;
try {
txn.start();
@ -168,7 +168,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when finding primary storagee " + cmd.getPoolUuid(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -179,7 +179,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
newVolume.setPoolId(primaryStorage.getId());
newVolume.setSize(template.getSize());
newVolume.setType(MockVolumeType.VOLUME);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
_mockVolumeDao.persist(newVolume);
@ -189,7 +189,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when saving volume " + newVolume, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return new PrimaryStorageDownloadAnswer(newVolume.getPath(), newVolume.getSize());
@ -200,7 +200,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
StorageFilerTO sf = cmd.getPool();
DiskProfile dskch = cmd.getDiskCharacteristics();
MockStoragePoolVO storagePool = null;
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
storagePool = _mockStoragePoolDao.findByUuid(sf.getUuid());
@ -213,7 +213,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when finding storage " + sf.getUuid(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -224,7 +224,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
volume.setPath(storagePool.getMountPoint() + volumeName);
volume.setSize(dskch.getSize());
volume.setType(MockVolumeType.VOLUME);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
volume = _mockVolumeDao.persist(volume);
@ -234,7 +234,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when saving volume " + volume, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -246,7 +246,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public AttachVolumeAnswer AttachVolume(AttachVolumeCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
String poolid = cmd.getPoolUuid();
@ -270,7 +270,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
+ cmd.getVmName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -284,7 +284,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
}
String vmName = cmd.getVmName();
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockVMVO vm = null;
try {
txn.start();
@ -298,7 +298,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when attaching iso to vm " + vm.getName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return new Answer(cmd);
@ -306,7 +306,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public Answer DeleteStoragePool(DeleteStoragePoolCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
MockStoragePoolVO storage = _mockStoragePoolDao.findByUuid(cmd.getPool().getUuid());
@ -321,7 +321,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when deleting storage pool " + cmd.getPool().getPath(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -329,7 +329,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public ModifyStoragePoolAnswer ModifyStoragePool(ModifyStoragePoolCommand cmd) {
StorageFilerTO sf = cmd.getPool();
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockStoragePoolVO storagePool = null;
try {
txn.start();
@ -361,7 +361,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when modifying storage pool " + cmd.getPool().getPath(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return new ModifyStoragePoolAnswer(cmd, storagePool.getCapacity(), 0, new HashMap<String, TemplateProp>());
@ -370,7 +370,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public Answer CreateStoragePool(CreateStoragePoolCommand cmd) {
StorageFilerTO sf = cmd.getPool();
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockStoragePoolVO storagePool = null;
try {
txn.start();
@ -402,7 +402,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when creating storage pool " + cmd.getPool().getPath(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return new ModifyStoragePoolAnswer(cmd, storagePool.getCapacity(), 0, new HashMap<String, TemplateProp>());
@ -410,7 +410,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public Answer SecStorageSetup(SecStorageSetupCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockSecStorageVO storage = null;
try {
txn.start();
@ -424,7 +424,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when setting up sec storage" + cmd.getSecUrl(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return new SecStorageSetupAnswer(storage.getMountPoint());
@ -432,7 +432,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public Answer ListVolumes(ListVolumeCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockSecStorageVO storage = null;
try {
txn.start();
@ -446,11 +446,11 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when finding sec storage " + cmd.getSecUrl(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
List<MockVolumeVO> volumes = _mockVolumeDao.findByStorageIdAndType(storage.getId(),
@ -468,7 +468,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when finding template on sec storage " + storage.getId(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -483,7 +483,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
MockSecStorageVO storage = null;
String nfsUrl = ((NfsTO) store).getUrl();
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
storage = _mockSecStorageDao.findByUrl(nfsUrl);
try {
txn.start();
@ -501,14 +501,14 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when finding template on sec storage " + storage.getId(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@Override
public Answer Destroy(DestroyCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
MockVolumeVO volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolume().getPath());
@ -530,7 +530,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when destroying volume " + cmd.getVolume().getPath(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return new Answer(cmd);
@ -539,7 +539,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public DownloadAnswer Download(DownloadCommand cmd) {
MockSecStorageVO ssvo = null;
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
ssvo = _mockSecStorageDao.findByUrl(cmd.getSecUrl());
@ -553,7 +553,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error accessing secondary storage " + cmd.getSecUrl(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -564,7 +564,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
volume.setSize(0);
volume.setType(MockVolumeType.TEMPLATE);
volume.setStatus(Status.DOWNLOAD_IN_PROGRESS);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
volume = _mockVolumeDao.persist(volume);
@ -574,7 +574,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when saving volume " + volume, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return new DownloadAnswer(String.valueOf(volume.getId()), 0, "Downloading", Status.DOWNLOAD_IN_PROGRESS,
@ -583,7 +583,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public DownloadAnswer DownloadProcess(DownloadProgressCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
String volumeId = cmd.getJobId();
@ -616,7 +616,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error during download job " + cmd.getJobId(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -624,7 +624,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public GetStorageStatsAnswer GetStorageStats(GetStorageStatsCommand cmd) {
String uuid = cmd.getStorageId();
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
if (uuid == null) {
@ -653,7 +653,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("DBException during storage stats collection for pool " + uuid, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -663,7 +663,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
String volPath = cmd.getVolumePath();
MockVolumeVO volume = null;
MockStoragePoolVO storagePool = null;
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
volume = _mockVolumeDao.findByStoragePathAndType(volPath);
@ -680,7 +680,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Unable to perform snapshot", ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -693,7 +693,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
snapshot.setPoolId(storagePool.getId());
snapshot.setType(MockVolumeType.SNAPSHOT);
snapshot.setStatus(Status.DOWNLOADED);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
snapshot = _mockVolumeDao.persist(snapshot);
@ -703,7 +703,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when saving snapshot " + snapshot, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -717,7 +717,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
MockVolumeVO volume = null;
MockVolumeVO snapshot = null;
MockSecStorageVO secStorage = null;
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolumePath());
@ -742,7 +742,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when backing up snapshot");
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -754,7 +754,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
newsnapshot.setSize(snapshot.getSize());
newsnapshot.setStatus(Status.DOWNLOADED);
newsnapshot.setType(MockVolumeType.SNAPSHOT);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
snapshot = _mockVolumeDao.persist(snapshot);
@ -764,7 +764,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when backing up snapshot " + newsnapshot, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -773,7 +773,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public CreateVolumeFromSnapshotAnswer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockVolumeVO backSnapshot = null;
MockStoragePoolVO primary = null;
try {
@ -795,7 +795,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when creating volume from snapshot", ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -808,7 +808,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
volume.setSize(backSnapshot.getSize());
volume.setStatus(Status.DOWNLOADED);
volume.setType(MockVolumeType.VOLUME);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
_mockVolumeDao.persist(volume);
@ -818,7 +818,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when creating volume from snapshot " + volume, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -828,7 +828,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public Answer Delete(DeleteCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
MockVolumeVO template = _mockVolumeDao.findByStoragePathAndType(cmd.getData().getPath());
@ -842,7 +842,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when deleting object");
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return new Answer(cmd);
@ -879,7 +879,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public void preinstallTemplates(String url, long zoneId) {
MockSecStorageVO storage = null;
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
storage = _mockSecStorageDao.findByUrl(url);
@ -933,14 +933,14 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
} catch (Exception ex) {
throw new CloudRuntimeException("Unable to find sec storage at " + url, ex);
} finally {
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@Override
public StoragePoolInfo getLocalStorage(String hostGuid) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockHost host = null;
MockStoragePoolVO storagePool = null;
try {
@ -953,7 +953,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Unable to find host " + hostGuid, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -965,7 +965,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
storagePool.setCapacity(DEFAULT_HOST_STORAGE_SIZE);
storagePool.setHostGuid(hostGuid);
storagePool.setStorageType(StoragePoolType.Filesystem);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
storagePool = _mockStoragePoolDao.persist(storagePool);
@ -975,7 +975,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when saving storagePool " + storagePool, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -985,7 +985,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public StoragePoolInfo getLocalStorage(String hostGuid, Long storageSize) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockHost host = null;
try {
txn.start();
@ -996,13 +996,13 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Unable to find host " + hostGuid, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
if (storageSize == null) {
storageSize = DEFAULT_HOST_STORAGE_SIZE;
}
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockStoragePoolVO storagePool = null;
try {
txn.start();
@ -1013,7 +1013,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when finding storagePool " + storagePool, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
if (storagePool == null) {
@ -1024,7 +1024,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
storagePool.setCapacity(storageSize);
storagePool.setHostGuid(hostGuid);
storagePool.setStorageType(StoragePoolType.Filesystem);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
storagePool = _mockStoragePoolDao.persist(storagePool);
@ -1034,7 +1034,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when saving storagePool " + storagePool, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -1044,7 +1044,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public CreatePrivateTemplateAnswer CreatePrivateTemplateFromSnapshot(CreatePrivateTemplateFromSnapshotCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockVolumeVO snapshot = null;
MockSecStorageVO sec = null;
try {
@ -1066,7 +1066,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
txn.commit();
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -1078,7 +1078,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
template.setSize(snapshot.getSize());
template.setStatus(Status.DOWNLOADED);
template.setType(MockVolumeType.TEMPLATE);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
template = _mockVolumeDao.persist(template);
@ -1088,7 +1088,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when saving template " + template, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -1098,7 +1098,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public Answer ComputeChecksum(ComputeChecksumCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
MockVolumeVO volume = _mockVolumeDao.findByName(cmd.getTemplatePath());
@ -1116,14 +1116,14 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
return new Answer(cmd, true, md5);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@Override
public CreatePrivateTemplateAnswer CreatePrivateTemplateFromVolume(CreatePrivateTemplateFromVolumeCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockVolumeVO volume = null;
MockSecStorageVO sec = null;
try {
@ -1143,7 +1143,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
throw new CloudRuntimeException("Error when creating private template from volume");
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -1155,7 +1155,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
template.setSize(volume.getSize());
template.setStatus(Status.DOWNLOADED);
template.setType(MockVolumeType.TEMPLATE);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
template = _mockVolumeDao.persist(template);
@ -1166,7 +1166,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
+ template.getName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -1176,7 +1176,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
@Override
public CopyVolumeAnswer CopyVolume(CopyVolumeCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
boolean toSecondaryStorage = cmd.toSecondaryStorage();
MockSecStorageVO sec = null;
MockStoragePoolVO primaryStorage = null;
@ -1193,11 +1193,11 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
+ cmd.getSecondaryStorageURL(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
primaryStorage = _mockStoragePoolDao.findByUuid(cmd.getPool().getUuid());
@ -1211,12 +1211,12 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
+ cmd.getPool(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
MockVolumeVO volume = null;
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolumePath());
@ -1230,7 +1230,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
+ cmd.getVolumePath(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -1243,7 +1243,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
vol.setSize(volume.getSize());
vol.setStatus(Status.DOWNLOADED);
vol.setType(MockVolumeType.VOLUME);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
vol = _mockVolumeDao.persist(vol);
@ -1254,7 +1254,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
+ vol.getName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return new CopyVolumeAnswer(cmd, true, null, sec.getMountPoint(), vol.getPath());
@ -1266,7 +1266,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
vol.setSize(volume.getSize());
vol.setStatus(Status.DOWNLOADED);
vol.setType(MockVolumeType.VOLUME);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
vol = _mockVolumeDao.persist(vol);
@ -1277,7 +1277,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
+ vol.getName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return new CopyVolumeAnswer(cmd, true, null, primaryStorage.getMountPoint(), vol.getPath());

View File

@ -72,7 +72,7 @@ import com.cloud.simulator.dao.MockVMDao;
import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.VirtualMachine.State;
import org.apache.log4j.Logger;
@ -111,7 +111,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
int cpuHz, long ramSize,
String bootArgs, String hostGuid) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockHost host = null;
MockVm vm = null;
try {
@ -128,7 +128,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("Unable to start VM " + vmName, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
@ -153,7 +153,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
} else if (vmName.startsWith("i-")) {
vm.setType("User");
}
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
vm = _mockVmDao.persist((MockVMVO) vm);
@ -163,13 +163,13 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("unable to save vm to db " + vm.getName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
} else {
if(vm.getState() == State.Stopped) {
vm.setState(State.Running);
txn = Transaction.open(Transaction.SIMULATOR_DB);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
_mockVmDao.update(vm.getId(), (MockVMVO)vm);
@ -179,7 +179,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("unable to update vm " + vm.getName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -230,7 +230,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
@Override
public Map<String, MockVMVO> getVms(String hostGuid) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
List<MockVMVO> vms = _mockVmDao.findByHostGuid(hostGuid);
@ -245,7 +245,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("unable to fetch vms from host " + hostGuid, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -282,7 +282,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
@Override
public Map<String, State> getVmStates(String hostGuid) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
Map<String, State> states = new HashMap<String, State>();
@ -301,7 +301,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("unable to fetch vms from host " + hostGuid, ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -338,7 +338,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
@Override
public CheckVirtualMachineAnswer checkVmState(CheckVirtualMachineCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
MockVMVO vm = _mockVmDao.findByVmName(cmd.getVmName());
@ -353,7 +353,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("unable to fetch vm state " + cmd.getVmName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -378,7 +378,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
@Override
public MigrateAnswer Migrate(MigrateCommand cmd, SimulatorInfo info) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
String vmName = cmd.getVmName();
@ -405,14 +405,14 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("unable to migrate vm " + cmd.getVmName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@Override
public PrepareForMigrationAnswer prepareForMigrate(PrepareForMigrationCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
VirtualMachineTO vmTo = cmd.getVirtualMachine();
try {
txn.start();
@ -425,7 +425,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("unable to find vm " + vmTo.getName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
return new PrepareForMigrationAnswer(cmd);
}
@ -438,7 +438,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
@Override
public Answer CleanupNetworkRules(CleanupNetworkRulesCmd cmd, SimulatorInfo info) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
List<MockSecurityRulesVO> rules = _mockSecurityDao.findByHost(info.getHostUuid());
@ -455,7 +455,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("unable to clean up rules", ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -503,7 +503,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
@Override
public StopAnswer stopVM(StopCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
String vmName = cmd.getVmName();
@ -523,14 +523,14 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("unable to stop vm " + cmd.getVmName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@Override
public RebootAnswer rebootVM(RebootCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
MockVm vm = _mockVmDao.findByVmName(cmd.getVmName());
@ -545,7 +545,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
throw new CloudRuntimeException("unable to stop vm " + cmd.getVmName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}

View File

@ -99,7 +99,7 @@ import com.cloud.utils.Pair;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.component.PluggableService;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.VirtualMachine.State;
import org.apache.cloudstack.storage.command.DeleteCommand;
@ -182,7 +182,7 @@ public class SimulatorManagerImpl extends ManagerBase implements SimulatorManage
@DB
@Override
public Answer simulate(Command cmd, String hostGuid) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
MockHost host = _mockHost.findByGuid(hostGuid);
String cmdName = cmd.toString();
@ -373,7 +373,7 @@ public class SimulatorManagerImpl extends ManagerBase implements SimulatorManage
return new Answer(cmd, false, e.toString());
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
@ -403,7 +403,7 @@ public class SimulatorManagerImpl extends ManagerBase implements SimulatorManage
@Override
public boolean configureSimulator(Long zoneId, Long podId, Long clusterId, Long hostId, String command,
String values) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
MockConfigurationVO config = _mockConfigDao.findByCommand(zoneId, podId, clusterId, hostId, command);
@ -427,7 +427,7 @@ public class SimulatorManagerImpl extends ManagerBase implements SimulatorManage
throw new CloudRuntimeException("Unable to configure simulator because of " + ex.getMessage(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
return true;

View File

@ -20,7 +20,7 @@ import com.cloud.simulator.MockConfigurationVO;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionLegacy;
import org.springframework.stereotype.Component;
import javax.ejb.Local;
@ -117,7 +117,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
@Override
public MockConfigurationVO findByNameBottomUP(Long dcId, Long podId, Long clusterId, Long hostId, String name) {
Transaction txn = Transaction.currentTxn();
TransactionLegacy txn = TransactionLegacy.currentTxn();
StringBuilder search = new StringBuilder();
Formatter formatter = new Formatter(search);
formatter.format("select * from mockconfiguration where (name='%s') and ((data_center_id = %d and pod_id = %d and cluster_id = %d and host_id = %d)", name, dcId, podId, clusterId, hostId);

View File

@ -120,6 +120,8 @@ import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallbackNoReturn;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
import com.cloud.utils.ssh.SshHelper;
@ -1091,32 +1093,12 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
// Add DC to database into vmware_data_center table
vmwareDc = new VmwareDatacenterVO(guid, vmwareDcName, vCenterHost, userName, password);
Transaction txn = Transaction.currentTxn();
try {
txn.start();
vmwareDc = _vmwareDcDao.persist(vmwareDc);
txn.commit();
} catch (Exception e) {
txn.rollback();
s_logger.error("Failed to persist VMware datacenter details to database. Exception: " + e.getMessage());
throw new CloudRuntimeException(e.getMessage());
}
vmwareDc = _vmwareDcDao.persist(vmwareDc);
// Map zone with vmware datacenter
vmwareDcZoneMap = new VmwareDatacenterZoneMapVO(zoneId, vmwareDc.getId());
txn = Transaction.currentTxn();
try {
txn.start();
vmwareDcZoneMap = _vmwareDcZoneMapDao.persist(vmwareDcZoneMap);
txn.commit();
} catch (Exception e) {
txn.rollback();
s_logger.error("Failed to associate VMware datacenter with zone " + zoneId + ". Exception: " + e.getMessage());
// Removing VMware datacenter from vmware_data_center table because association with zone failed.
_vmwareDcDao.remove(vmwareDcZoneMap.getId());
throw new CloudRuntimeException(e.getMessage());
}
vmwareDcZoneMap = _vmwareDcZoneMapDao.persist(vmwareDcZoneMap);
// Set custom field for this DC
if (addDcCustomFieldDef) {
@ -1152,40 +1134,35 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
validateZoneWithResources(zoneId, "remove VMware datacenter to zone");
// Get DC associated with this zone
VmwareDatacenterZoneMapVO vmwareDcZoneMap;
VmwareDatacenterVO vmwareDatacenter;
String vmwareDcName;
long vmwareDcId;
String vCenterHost;
String userName;
String password;
DatacenterMO dcMo = null;
Transaction txn;
vmwareDcZoneMap = _vmwareDcZoneMapDao.findByZoneId(zoneId);
final VmwareDatacenterZoneMapVO vmwareDcZoneMap = _vmwareDcZoneMapDao.findByZoneId(zoneId);
// Check if zone is associated with VMware DC
if (vmwareDcZoneMap == null) {
throw new CloudRuntimeException("Zone " + zoneId + " is not associated with any VMware datacenter.");
}
vmwareDcId = vmwareDcZoneMap.getVmwareDcId();
final long vmwareDcId = vmwareDcZoneMap.getVmwareDcId();
vmwareDatacenter = _vmwareDcDao.findById(vmwareDcId);
vmwareDcName = vmwareDatacenter.getVmwareDatacenterName();
vCenterHost = vmwareDatacenter.getVcenterHost();
userName = vmwareDatacenter.getUser();
password = vmwareDatacenter.getPassword();
txn = Transaction.currentTxn();
try {
txn.start();
// Remove the VMware datacenter entry in table vmware_data_center
_vmwareDcDao.remove(vmwareDcId);
// Remove the map entry in table vmware_data_center_zone_map
_vmwareDcZoneMapDao.remove(vmwareDcZoneMap.getId());
txn.commit();
} catch (Exception e) {
s_logger.info("Caught exception when trying to delete VMware datacenter record." + e.getMessage());
throw new CloudRuntimeException("Failed to delete VMware datacenter.");
}
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
// Remove the VMware datacenter entry in table vmware_data_center
_vmwareDcDao.remove(vmwareDcId);
// Remove the map entry in table vmware_data_center_zone_map
_vmwareDcZoneMapDao.remove(vmwareDcZoneMap.getId());
}
});
// Construct context
VmwareContext context = null;

View File

@ -38,6 +38,8 @@ import com.cloud.resource.ResourceManager;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallbackNoReturn;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
import com.cloud.network.dao.PortProfileDao;
@ -131,29 +133,13 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
if (VSMObj == null) {
// Create the VSM record. For now, we aren't using the vsmName field.
VSMObj = new CiscoNexusVSMDeviceVO(ipaddress, username, password);
Transaction txn = Transaction.currentTxn();
try {
txn.start();
_ciscoNexusVSMDeviceDao.persist(VSMObj);
txn.commit();
} catch (Exception e) {
txn.rollback();
throw new CloudRuntimeException(e.getMessage());
}
_ciscoNexusVSMDeviceDao.persist(VSMObj);
}
// At this stage, we have a VSM record for sure. Connect the VSM to the cluster Id.
long vsmId = _ciscoNexusVSMDeviceDao.getVSMbyIpaddress(ipaddress).getId();
ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsmId);
Transaction txn = Transaction.currentTxn();
try {
txn.start();
_clusterVSMDao.persist(connectorObj);
txn.commit();
} catch (Exception e) {
txn.rollback();
throw new CloudRuntimeException(e.getMessage());
}
_clusterVSMDao.persist(connectorObj);
// Now, get a list of all the ESXi servers in this cluster.
// This is effectively a select * from host where cluster_id=clusterId;
@ -196,7 +182,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
}
@DB
public boolean deleteCiscoNexusVSM(long vsmId) throws ResourceInUseException {
public boolean deleteCiscoNexusVSM(final long vsmId) throws ResourceInUseException {
CiscoNexusVSMDeviceVO cisconexusvsm = _ciscoNexusVSMDeviceDao.findById(vsmId);
if (cisconexusvsm == null) {
// This entry is already not present. Return success.
@ -225,20 +211,16 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
}
// Iterate through the cluster list again, this time, delete the VSM.
Transaction txn = Transaction.currentTxn();
try {
txn.start();
// Remove the VSM entry in CiscoNexusVSMDeviceVO's table.
_ciscoNexusVSMDeviceDao.remove(vsmId);
// Remove the current record as well from ClusterVSMMapVO's table.
_clusterVSMDao.removeByVsmId(vsmId);
// There are no hosts at this stage in the cluster, so we don't need
// to notify any resources or remove host details.
txn.commit();
} catch (Exception e) {
s_logger.info("Caught exception when trying to delete VSM record.." + e.getMessage());
throw new CloudRuntimeException("Failed to delete VSM");
}
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
// Remove the VSM entry in CiscoNexusVSMDeviceVO's table.
_ciscoNexusVSMDeviceDao.remove(vsmId);
// Remove the current record as well from ClusterVSMMapVO's table.
_clusterVSMDao.removeByVsmId(vsmId);
}
});
return true;
}
@ -252,15 +234,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Disabled) {
// it's currently disabled. So change it to enabled and write it out to the db.
cisconexusvsm.setVsmDeviceState(CiscoNexusVSMDeviceVO.VSMDeviceState.Enabled);
Transaction txn = Transaction.currentTxn();
try {
txn.start();
_ciscoNexusVSMDeviceDao.persist(cisconexusvsm);
txn.commit();
} catch (Exception e) {
txn.rollback();
throw new CloudRuntimeException(e.getMessage());
}
_ciscoNexusVSMDeviceDao.persist(cisconexusvsm);
}
return cisconexusvsm;
@ -276,15 +250,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Enabled) {
// it's currently disabled. So change it to enabled and write it out to the db.
cisconexusvsm.setVsmDeviceState(CiscoNexusVSMDeviceVO.VSMDeviceState.Disabled);
Transaction txn = Transaction.currentTxn();
try {
txn.start();
_ciscoNexusVSMDeviceDao.persist(cisconexusvsm);
txn.commit();
} catch (Exception e) {
txn.rollback();
throw new CloudRuntimeException(e.getMessage());
}
_ciscoNexusVSMDeviceDao.persist(cisconexusvsm);
}
return cisconexusvsm;

View File

@ -61,6 +61,8 @@ import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
import com.cloud.utils.component.Manager;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallback;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
@ -260,7 +262,7 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
}
@DB
public Pair<Boolean, Long> validateAndAddVsm(String vsmIp, String vsmUser, String vsmPassword, long clusterId, String clusterName) throws ResourceInUseException {
public Pair<Boolean, Long> validateAndAddVsm(final String vsmIp, final String vsmUser, final String vsmPassword, final long clusterId, String clusterName) throws ResourceInUseException {
CiscoNexusVSMDeviceVO vsm = null;
boolean vsmAdded = false;
Long vsmId = 0L;
@ -293,36 +295,24 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
}
}
// persist credentials to database if the VSM entry is not already in the db.
if (_vsmDao.getVSMbyIpaddress(vsmIp) == null) {
vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword);
txn = Transaction.currentTxn();
try {
txn.start();
vsm = _vsmDao.persist(vsm);
txn.commit();
} catch (Exception e) {
txn.rollback();
s_logger.error("Failed to persist Cisco Nexus 1000v VSM details to database. Exception: " + e.getMessage());
throw new CloudRuntimeException(e.getMessage());
vsm = Transaction.execute(new TransactionCallback<CiscoNexusVSMDeviceVO>() {
@Override
public CiscoNexusVSMDeviceVO doInTransaction(TransactionStatus status) {
CiscoNexusVSMDeviceVO vsm = null;
if (_vsmDao.getVSMbyIpaddress(vsmIp) == null) {
vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword);
vsm = _vsmDao.persist(vsm);
}
// Create a mapping between the cluster and the vsm.
vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
if (vsm != null) {
ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsm.getId());
_clusterVSMDao.persist(connectorObj);
}
return vsm;
}
}
// Create a mapping between the cluster and the vsm.
vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
if (vsm != null) {
ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsm.getId());
txn = Transaction.currentTxn();
try {
txn.start();
_clusterVSMDao.persist(connectorObj);
txn.commit();
} catch (Exception e) {
txn.rollback();
s_logger.error("Failed to associate Cisco Nexus 1000v VSM with cluster: " + clusterName + ". Exception: " + e.getMessage());
_vsmDao.remove(vsm.getId()); // Removing VSM from virtual_supervisor_module table because association with cluster failed.
// Cluster would be deleted from cluster table by callee.
throw new CloudRuntimeException(e.getMessage());
}
}
});
} else {
String msg;
msg = "The global parameter " + Config.VmwareUseNexusVSwitch.toString() +

View File

@ -29,7 +29,6 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
import com.cloud.agent.AgentManager;
@ -84,6 +83,9 @@ import com.cloud.resource.UnableDeleteHostException;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallback;
import com.cloud.utils.db.TransactionCallbackNoReturn;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
@ -329,11 +331,10 @@ public class BigSwitchVnsElement extends AdapterBase implements
@DB
public BigSwitchVnsDeviceVO addBigSwitchVnsDevice(AddBigSwitchVnsDeviceCmd cmd) {
ServerResource resource = new BigSwitchVnsResource();
String deviceName = VnsConstants.BigSwitchVns.getName();
final String deviceName = VnsConstants.BigSwitchVns.getName();
NetworkDevice networkDevice = NetworkDevice
.getNetworkDevice(deviceName);
Long physicalNetworkId = cmd.getPhysicalNetworkId();
BigSwitchVnsDeviceVO bigswitchVnsDevice = null;
final Long physicalNetworkId = cmd.getPhysicalNetworkId();
PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
.findById(physicalNetworkId);
@ -344,7 +345,7 @@ public class BigSwitchVnsElement extends AdapterBase implements
}
long zoneId = physicalNetwork.getDataCenterId();
PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao
final PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao
.findByServiceProvider(physicalNetwork.getId(),
networkDevice.getNetworkServiceProvder());
if (ntwkSvcProvider == null) {
@ -377,33 +378,33 @@ public class BigSwitchVnsElement extends AdapterBase implements
Map<String, Object> hostdetails = new HashMap<String, Object>();
hostdetails.putAll(params);
Transaction txn = Transaction.currentTxn();
try {
resource.configure(cmd.getHost(), hostdetails);
Host host = _resourceMgr.addHost(zoneId, resource,
final Host host = _resourceMgr.addHost(zoneId, resource,
Host.Type.L2Networking, params);
if (host != null) {
txn.start();
bigswitchVnsDevice = new BigSwitchVnsDeviceVO(host.getId(),
physicalNetworkId, ntwkSvcProvider.getProviderName(),
deviceName);
_bigswitchVnsDao.persist(bigswitchVnsDevice);
DetailVO detail = new DetailVO(host.getId(),
"bigswitchvnsdeviceid",
String.valueOf(bigswitchVnsDevice.getId()));
_hostDetailsDao.persist(detail);
txn.commit();
return bigswitchVnsDevice;
return Transaction.execute(new TransactionCallback<BigSwitchVnsDeviceVO>() {
@Override
public BigSwitchVnsDeviceVO doInTransaction(TransactionStatus status) {
BigSwitchVnsDeviceVO bigswitchVnsDevice = new BigSwitchVnsDeviceVO(host.getId(),
physicalNetworkId, ntwkSvcProvider.getProviderName(),
deviceName);
_bigswitchVnsDao.persist(bigswitchVnsDevice);
DetailVO detail = new DetailVO(host.getId(),
"bigswitchvnsdeviceid",
String.valueOf(bigswitchVnsDevice.getId()));
_hostDetailsDao.persist(detail);
return bigswitchVnsDevice;
}
});
} else {
throw new CloudRuntimeException(
"Failed to add BigSwitch Vns Device due to internal error.");
}
} catch (ConfigurationException e) {
txn.rollback();
throw new CloudRuntimeException(e.getMessage());
}
}

View File

@ -29,7 +29,6 @@ import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
@ -71,6 +70,7 @@ import com.cloud.dc.dao.ClusterVSMMapDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
@ -123,7 +123,11 @@ import com.cloud.user.Account;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.db.EntityManager;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallback;
import com.cloud.utils.db.TransactionCallbackWithException;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.exception.ExceptionUtil;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
@ -274,11 +278,11 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
}
@Override
public boolean implement(Network network, NetworkOffering offering,
DeployDestination dest, ReservationContext context)
public boolean implement(final Network network, final NetworkOffering offering,
final DeployDestination dest, final ReservationContext context)
throws ConcurrentOperationException, ResourceUnavailableException,
InsufficientCapacityException {
DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
final DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
if (zone.getNetworkType() == NetworkType.Basic) {
s_logger.debug("Not handling network implement in zone of type " + NetworkType.Basic);
@ -289,7 +293,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
return false;
}
List<CiscoVnmcControllerVO> devices = _ciscoVnmcDao.listByPhysicalNetwork(network.getPhysicalNetworkId());
final List<CiscoVnmcControllerVO> devices = _ciscoVnmcDao.listByPhysicalNetwork(network.getPhysicalNetworkId());
if (devices.isEmpty()) {
s_logger.error("No Cisco Vnmc device on network " + network.getName());
return false;
@ -312,114 +316,121 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
return false;
}
Transaction txn = Transaction.currentTxn();
boolean status = false;
try {
txn.start();
Transaction.executeWithException(new TransactionCallbackWithException<Object>() {
@Override
public Object doInTransaction(TransactionStatus status) throws InsufficientAddressCapacityException, ResourceUnavailableException {
// ensure that there is an ASA 1000v assigned to this network
CiscoAsa1000vDevice assignedAsa = assignAsa1000vToNetwork(network);
if (assignedAsa == null) {
s_logger.error("Unable to assign ASA 1000v device to network " + network.getName());
return false;
}
// ensure that there is an ASA 1000v assigned to this network
CiscoAsa1000vDevice assignedAsa = assignAsa1000vToNetwork(network);
if (assignedAsa == null) {
s_logger.error("Unable to assign ASA 1000v device to network " + network.getName());
throw new CloudRuntimeException("Unable to assign ASA 1000v device to network " + network.getName());
}
ClusterVO asaCluster = _clusterDao.findById(assignedAsa.getClusterId());
ClusterVSMMapVO clusterVsmMap = _clusterVsmMapDao.findByClusterId(assignedAsa.getClusterId());
if (clusterVsmMap == null) {
s_logger.error("Vmware cluster " + asaCluster.getName() + " has no Cisco Nexus VSM device associated with it");
throw new CloudRuntimeException("Vmware cluster " + asaCluster.getName() + " has no Cisco Nexus VSM device associated with it");
}
CiscoNexusVSMDeviceVO vsmDevice = _vsmDeviceDao.findById(clusterVsmMap.getVsmId());
if (vsmDevice == null) {
s_logger.error("Unable to load details of Cisco Nexus VSM device associated with cluster " + asaCluster.getName());
throw new CloudRuntimeException("Unable to load details of Cisco Nexus VSM device associated with cluster " + asaCluster.getName());
}
CiscoVnmcControllerVO ciscoVnmcDevice = devices.get(0);
HostVO ciscoVnmcHost = _hostDao.findById(ciscoVnmcDevice.getHostId());
_hostDao.loadDetails(ciscoVnmcHost);
Account owner = context.getAccount();
PublicIp sourceNatIp = _ipAddrMgr.assignSourceNatIpAddressToGuestNetwork(owner, network);
long vlanId = Long.parseLong(BroadcastDomainType.getValue(network.getBroadcastUri()));
List<VlanVO> vlanVOList = _vlanDao.listVlansByPhysicalNetworkId(network.getPhysicalNetworkId());
List<String> publicGateways = new ArrayList<String>();
for (VlanVO vlanVO : vlanVOList) {
publicGateways.add(vlanVO.getVlanGateway());
}
// due to VNMC limitation of not allowing source NAT ip as the outside ip of firewall,
// an additional public ip needs to acquired for assigning as firewall outside ip.
// In case there are already additional ip addresses available (network restart) use one
// of them such that it is not the source NAT ip
IpAddress outsideIp = null;
List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), null);
for (IPAddressVO ip : publicIps) {
if (!ip.isSourceNat()) {
outsideIp = ip;
break;
}
}
if (outsideIp == null) { // none available, acquire one
try {
Account caller = CallContext.current().getCallingAccount();
long callerUserId = CallContext.current().getCallingUserId();
outsideIp = _ipAddrMgr.allocateIp(owner, false, caller, callerUserId, zone);
} catch (ResourceAllocationException e) {
s_logger.error("Unable to allocate additional public Ip address. Exception details " + e);
throw new CloudRuntimeException("Unable to allocate additional public Ip address. Exception details " + e);
}
try {
outsideIp = _ipAddrMgr.associateIPToGuestNetwork(outsideIp.getId(), network.getId(), true);
} catch (ResourceAllocationException e) {
s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " + vlanId + ". Exception details "
+ e);
throw new CloudRuntimeException("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " + vlanId + ". Exception details "
+ e);
}
}
// create logical edge firewall in VNMC
String gatewayNetmask = NetUtils.getCidrNetmask(network.getCidr());
// due to ASA limitation of allowing single subnet to be assigned to firewall interfaces,
// all public ip addresses must be from same subnet, this essentially means single public subnet in zone
if (!createLogicalEdgeFirewall(vlanId, network.getGateway(), gatewayNetmask,
outsideIp.getAddress().addr(), sourceNatIp.getNetmask(), publicGateways, ciscoVnmcHost.getId())) {
s_logger.error("Failed to create logical edge firewall in Cisco VNMC device for network " + network.getName());
throw new CloudRuntimeException("Failed to create logical edge firewall in Cisco VNMC device for network " + network.getName());
}
// create stuff in VSM for ASA device
if (!configureNexusVsmForAsa(vlanId, network.getGateway(),
vsmDevice.getUserName(), vsmDevice.getPassword(), vsmDevice.getipaddr(),
assignedAsa.getInPortProfile(), ciscoVnmcHost.getId())) {
s_logger.error("Failed to configure Cisco Nexus VSM " + vsmDevice.getipaddr() +
" for ASA device for network " + network.getName());
throw new CloudRuntimeException("Failed to configure Cisco Nexus VSM " + vsmDevice.getipaddr() +
" for ASA device for network " + network.getName());
}
// configure source NAT
if (!configureSourceNat(vlanId, network.getCidr(), sourceNatIp, ciscoVnmcHost.getId())) {
s_logger.error("Failed to configure source NAT in Cisco VNMC device for network " + network.getName());
throw new CloudRuntimeException("Failed to configure source NAT in Cisco VNMC device for network " + network.getName());
}
// associate Asa 1000v instance with logical edge firewall
if (!associateAsaWithLogicalEdgeFirewall(vlanId, assignedAsa.getManagementIp(), ciscoVnmcHost.getId())) {
s_logger.error("Failed to associate Cisco ASA 1000v (" + assignedAsa.getManagementIp() +
") with logical edge firewall in VNMC for network " + network.getName());
throw new CloudRuntimeException("Failed to associate Cisco ASA 1000v (" + assignedAsa.getManagementIp() +
") with logical edge firewall in VNMC for network " + network.getName());
}
ClusterVO asaCluster = _clusterDao.findById(assignedAsa.getClusterId());
ClusterVSMMapVO clusterVsmMap = _clusterVsmMapDao.findByClusterId(assignedAsa.getClusterId());
if (clusterVsmMap == null) {
s_logger.error("Vmware cluster " + asaCluster.getName() + " has no Cisco Nexus VSM device associated with it");
return false;
}
CiscoNexusVSMDeviceVO vsmDevice = _vsmDeviceDao.findById(clusterVsmMap.getVsmId());
if (vsmDevice == null) {
s_logger.error("Unable to load details of Cisco Nexus VSM device associated with cluster " + asaCluster.getName());
return false;
}
CiscoVnmcControllerVO ciscoVnmcDevice = devices.get(0);
HostVO ciscoVnmcHost = _hostDao.findById(ciscoVnmcDevice.getHostId());
_hostDao.loadDetails(ciscoVnmcHost);
Account owner = context.getAccount();
PublicIp sourceNatIp = _ipAddrMgr.assignSourceNatIpAddressToGuestNetwork(owner, network);
long vlanId = Long.parseLong(BroadcastDomainType.getValue(network.getBroadcastUri()));
List<VlanVO> vlanVOList = _vlanDao.listVlansByPhysicalNetworkId(network.getPhysicalNetworkId());
List<String> publicGateways = new ArrayList<String>();
for (VlanVO vlanVO : vlanVOList) {
publicGateways.add(vlanVO.getVlanGateway());
}
// due to VNMC limitation of not allowing source NAT ip as the outside ip of firewall,
// an additional public ip needs to acquired for assigning as firewall outside ip.
// In case there are already additional ip addresses available (network restart) use one
// of them such that it is not the source NAT ip
IpAddress outsideIp = null;
List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), null);
for (IPAddressVO ip : publicIps) {
if (!ip.isSourceNat()) {
outsideIp = ip;
break;
return null;
}
}
if (outsideIp == null) { // none available, acquire one
try {
Account caller = CallContext.current().getCallingAccount();
long callerUserId = CallContext.current().getCallingUserId();
outsideIp = _ipAddrMgr.allocateIp(owner, false, caller, callerUserId, zone);
} catch (ResourceAllocationException e) {
s_logger.error("Unable to allocate additional public Ip address. Exception details " + e);
return false;
}
try {
outsideIp = _ipAddrMgr.associateIPToGuestNetwork(outsideIp.getId(), network.getId(), true);
} catch (ResourceAllocationException e) {
s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " + vlanId + ". Exception details "
+ e);
return false;
}
}
// create logical edge firewall in VNMC
String gatewayNetmask = NetUtils.getCidrNetmask(network.getCidr());
// due to ASA limitation of allowing single subnet to be assigned to firewall interfaces,
// all public ip addresses must be from same subnet, this essentially means single public subnet in zone
if (!createLogicalEdgeFirewall(vlanId, network.getGateway(), gatewayNetmask,
outsideIp.getAddress().addr(), sourceNatIp.getNetmask(), publicGateways, ciscoVnmcHost.getId())) {
s_logger.error("Failed to create logical edge firewall in Cisco VNMC device for network " + network.getName());
return false;
}
// create stuff in VSM for ASA device
if (!configureNexusVsmForAsa(vlanId, network.getGateway(),
vsmDevice.getUserName(), vsmDevice.getPassword(), vsmDevice.getipaddr(),
assignedAsa.getInPortProfile(), ciscoVnmcHost.getId())) {
s_logger.error("Failed to configure Cisco Nexus VSM " + vsmDevice.getipaddr() +
" for ASA device for network " + network.getName());
return false;
}
// configure source NAT
if (!configureSourceNat(vlanId, network.getCidr(), sourceNatIp, ciscoVnmcHost.getId())) {
s_logger.error("Failed to configure source NAT in Cisco VNMC device for network " + network.getName());
return false;
}
// associate Asa 1000v instance with logical edge firewall
if (!associateAsaWithLogicalEdgeFirewall(vlanId, assignedAsa.getManagementIp(), ciscoVnmcHost.getId())) {
s_logger.error("Failed to associate Cisco ASA 1000v (" + assignedAsa.getManagementIp() +
") with logical edge firewall in VNMC for network " + network.getName());
return false;
}
status = true;
txn.commit();
} finally {
if (!status) {
txn.rollback();
//FIXME: also undo changes in VNMC, VSM if anything failed
}
}, Exception.class);
} catch (CloudRuntimeException e) {
s_logger.error("CiscoVnmcElement failed", e);
return false;
} catch (Exception e) {
ExceptionUtil.rethrowRuntime(e);
ExceptionUtil.rethrow(e, InsufficientAddressCapacityException.class);
ExceptionUtil.rethrow(e, ResourceUnavailableException.class);
throw new IllegalStateException(e);
}
return true;
@ -522,9 +533,9 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
@Override
public CiscoVnmcController addCiscoVnmcResource(AddCiscoVnmcResourceCmd cmd) {
String deviceName = Provider.CiscoVnmc.getName();
final String deviceName = Provider.CiscoVnmc.getName();
NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName);
Long physicalNetworkId = cmd.getPhysicalNetworkId();
final Long physicalNetworkId = cmd.getPhysicalNetworkId();
CiscoVnmcController ciscoVnmcResource = null;
PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
@ -533,7 +544,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
}
long zoneId = physicalNetwork.getDataCenterId();
PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(),
final PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(),
networkDevice.getNetworkServiceProvder());
if (ntwkSvcProvider == null) {
throw new CloudRuntimeException("Network Service Provider: " + networkDevice.getNetworkServiceProvder() +
@ -560,27 +571,27 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
hostdetails.putAll(params);
ServerResource resource = new CiscoVnmcResource();
Transaction txn = Transaction.currentTxn();
try {
resource.configure(cmd.getHost(), hostdetails);
Host host = _resourceMgr.addHost(zoneId, resource, Host.Type.ExternalFirewall, params);
final Host host = _resourceMgr.addHost(zoneId, resource, Host.Type.ExternalFirewall, params);
if (host != null) {
txn.start();
ciscoVnmcResource = new CiscoVnmcControllerVO(host.getId(), physicalNetworkId, ntwkSvcProvider.getProviderName(), deviceName);
_ciscoVnmcDao.persist((CiscoVnmcControllerVO)ciscoVnmcResource);
DetailVO detail = new DetailVO(host.getId(), "deviceid", String.valueOf(ciscoVnmcResource.getId()));
_hostDetailsDao.persist(detail);
txn.commit();
return ciscoVnmcResource;
return Transaction.execute(new TransactionCallback<CiscoVnmcController>() {
@Override
public CiscoVnmcController doInTransaction(TransactionStatus status) {
CiscoVnmcController ciscoVnmcResource = new CiscoVnmcControllerVO(host.getId(), physicalNetworkId, ntwkSvcProvider.getProviderName(), deviceName);
_ciscoVnmcDao.persist((CiscoVnmcControllerVO)ciscoVnmcResource);
DetailVO detail = new DetailVO(host.getId(), "deviceid", String.valueOf(ciscoVnmcResource.getId()));
_hostDetailsDao.persist(detail);
return ciscoVnmcResource;
}
});
} else {
throw new CloudRuntimeException("Failed to add Cisco Vnmc device due to internal error.");
}
} catch (ConfigurationException e) {
txn.rollback();
throw new CloudRuntimeException(e.getMessage());
}
}

View File

@ -46,6 +46,8 @@ import com.cloud.user.AccountVO;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallbackNoReturn;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
@ -206,16 +208,15 @@ public class MidoNetPublicNetworkGuru extends PublicNetworkGuru {
s_logger.debug("public network deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIp4Address());
}
IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
final IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
if (ip != null && nic.getReservationStrategy() != Nic.ReservationStrategy.Managed) {
Transaction txn = Transaction.currentTxn();
txn.start();
_ipAddrMgr.markIpAsUnavailable(ip.getId());
_ipAddressDao.unassignIpAddress(ip.getId());
txn.commit();
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
_ipAddrMgr.markIpAsUnavailable(ip.getId());
_ipAddressDao.unassignIpAddress(ip.getId());
}
});
}
nic.deallocate();

View File

@ -31,7 +31,6 @@ import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
import org.apache.cloudstack.region.gslb.GslbServiceProvider;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
@ -110,13 +109,14 @@ import com.cloud.offering.NetworkOffering;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallbackNoReturn;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.UrlUtil;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import com.google.gson.Gson;
@Local(value = {NetworkElement.class, StaticNatServiceProvider.class, LoadBalancingServiceProvider.class, GslbServiceProvider.class})
@ -409,9 +409,9 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
}
@DB
private ExternalLoadBalancerDeviceVO configureNetscalerLoadBalancer(long lbDeviceId, Long capacity, Boolean dedicatedUse, List<Long> newPodsConfig) {
ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
Map<String, String> lbDetails = _detailsDao.findDetails(lbDeviceVo.getHostId());
private ExternalLoadBalancerDeviceVO configureNetscalerLoadBalancer(final long lbDeviceId, Long capacity, Boolean dedicatedUse, List<Long> newPodsConfig) {
final ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
final Map<String, String> lbDetails = _detailsDao.findDetails(lbDeviceVo.getHostId());
if ((lbDeviceVo == null) || !isNetscalerDevice(lbDeviceVo.getDeviceName())) {
throw new InvalidParameterValueException("No netscaler device found with ID: " + lbDeviceId);
@ -425,7 +425,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
}
}
List<Long> podsToAssociate = new ArrayList<Long>();
final List<Long> podsToAssociate = new ArrayList<Long>();
if (newPodsConfig != null && newPodsConfig.size() > 0) {
for (Long podId: newPodsConfig) {
HostPodVO pod = _podDao.findById(podId);
@ -441,7 +441,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
}
}
List<Long> podsToDeassociate = new ArrayList<Long>();
final List<Long> podsToDeassociate = new ArrayList<Long>();
for (Long podId: currentPodsConfig) {
if (!newPodsConfig.contains(podId)) {
podsToDeassociate.add(podId);
@ -482,26 +482,28 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
lbDeviceVo.setIsDedicatedDevice(dedicatedUse);
}
Transaction txn = Transaction.currentTxn();
txn.start();
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
_lbDeviceDao.update(lbDeviceId, lbDeviceVo);
for (Long podId: podsToAssociate) {
NetScalerPodVO nsPodVo = new NetScalerPodVO(lbDeviceId, podId);
_netscalerPodDao.persist(nsPodVo);
}
for (Long podId: podsToDeassociate) {
NetScalerPodVO nsPodVo = _netscalerPodDao.findByPodId(podId);
_netscalerPodDao.remove(nsPodVo.getId());
}
// FIXME get the row lock to avoid race condition
_detailsDao.persist(lbDeviceVo.getHostId(), lbDetails);
_lbDeviceDao.update(lbDeviceId, lbDeviceVo);
for (Long podId: podsToAssociate) {
NetScalerPodVO nsPodVo = new NetScalerPodVO(lbDeviceId, podId);
_netscalerPodDao.persist(nsPodVo);
}
for (Long podId: podsToDeassociate) {
NetScalerPodVO nsPodVo = _netscalerPodDao.findByPodId(podId);
_netscalerPodDao.remove(nsPodVo.getId());
}
// FIXME get the row lock to avoid race condition
_detailsDao.persist(lbDeviceVo.getHostId(), lbDetails);
}
});
HostVO host = _hostDao.findById(lbDeviceVo.getHostId());
txn.commit();
_agentMgr.reconnect(host.getId());
return lbDeviceVo;
}

View File

@ -30,7 +30,6 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
@ -114,6 +113,8 @@ import com.cloud.user.Account;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallback;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.NicProfile;
@ -552,12 +553,10 @@ public class NiciraNvpElement extends AdapterBase implements
@DB
public NiciraNvpDeviceVO addNiciraNvpDevice(AddNiciraNvpDeviceCmd cmd) {
ServerResource resource = new NiciraNvpResource();
String deviceName = Network.Provider.NiciraNvp.getName();
final String deviceName = Network.Provider.NiciraNvp.getName();
NetworkDevice networkDevice = NetworkDevice
.getNetworkDevice(deviceName);
Long physicalNetworkId = cmd.getPhysicalNetworkId();
NiciraNvpDeviceVO niciraNvpDevice = null;
final Long physicalNetworkId = cmd.getPhysicalNetworkId();
PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
.findById(physicalNetworkId);
if (physicalNetwork == null) {
@ -567,7 +566,7 @@ public class NiciraNvpElement extends AdapterBase implements
}
long zoneId = physicalNetwork.getDataCenterId();
PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao
final PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao
.findByServiceProvider(physicalNetwork.getId(),
networkDevice.getNetworkServiceProvder());
if (ntwkSvcProvider == null) {
@ -606,33 +605,33 @@ public class NiciraNvpElement extends AdapterBase implements
Map<String, Object> hostdetails = new HashMap<String, Object>();
hostdetails.putAll(params);
Transaction txn = Transaction.currentTxn();
try {
resource.configure(cmd.getHost(), hostdetails);
Host host = _resourceMgr.addHost(zoneId, resource,
final Host host = _resourceMgr.addHost(zoneId, resource,
Host.Type.L2Networking, params);
if (host != null) {
txn.start();
return Transaction.execute(new TransactionCallback<NiciraNvpDeviceVO>() {
@Override
public NiciraNvpDeviceVO doInTransaction(TransactionStatus status) {
NiciraNvpDeviceVO niciraNvpDevice = new NiciraNvpDeviceVO(host.getId(),
physicalNetworkId, ntwkSvcProvider.getProviderName(),
deviceName);
_niciraNvpDao.persist(niciraNvpDevice);
DetailVO detail = new DetailVO(host.getId(),
"niciranvpdeviceid", String.valueOf(niciraNvpDevice
.getId()));
_hostDetailsDao.persist(detail);
niciraNvpDevice = new NiciraNvpDeviceVO(host.getId(),
physicalNetworkId, ntwkSvcProvider.getProviderName(),
deviceName);
_niciraNvpDao.persist(niciraNvpDevice);
DetailVO detail = new DetailVO(host.getId(),
"niciranvpdeviceid", String.valueOf(niciraNvpDevice
.getId()));
_hostDetailsDao.persist(detail);
txn.commit();
return niciraNvpDevice;
return niciraNvpDevice;
}
});
} else {
throw new CloudRuntimeException(
"Failed to add Nicira Nvp Device due to internal error.");
}
} catch (ConfigurationException e) {
txn.rollback();
throw new CloudRuntimeException(e.getMessage());
}
}

View File

@ -191,7 +191,7 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A
if (e instanceof NetworkRuleConflictException) {
throw (NetworkRuleConflictException) e;
}
throw new CloudRuntimeException("Unable to add lb rule for ip address " + newRule.getSourceIpAddressId(), e);
throw new CloudRuntimeException("Unable to add lb rule for ip address " + newRuleFinal.getSourceIpAddressId(), e);
} finally {
if (!success && newRule != null) {
_lbMgr.removeLBRule(newRule);