cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dar...@apache.org
Subject [2/3] git commit: updated refs/heads/txn-refactor to 323bbcc
Date Fri, 18 Oct 2013 00:11:10 GMT
Refactor missed classes


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9cbb309d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9cbb309d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9cbb309d

Branch: refs/heads/txn-refactor
Commit: 9cbb309d6b95c8522bfddd9e4244a19a166cdc7a
Parents: 711ad38
Author: Darren Shepherd <darren.s.shepherd@gmail.com>
Authored: Thu Oct 17 16:00:11 2013 -0700
Committer: Darren Shepherd <darren.s.shepherd@gmail.com>
Committed: Thu Oct 17 16:00:11 2013 -0700

----------------------------------------------------------------------
 .../src/com/cloud/netapp/NetappManagerImpl.java |  10 +-
 .../agent/manager/MockAgentManagerImpl.java     |  27 +-
 .../agent/manager/MockStorageManagerImpl.java   | 170 ++++++------
 .../cloud/agent/manager/MockVmManagerImpl.java  |  46 ++--
 .../agent/manager/SimulatorManagerImpl.java     |  10 +-
 .../simulator/dao/MockConfigurationDaoImpl.java |   4 +-
 .../vmware/manager/VmwareManagerImpl.java       |  53 ++--
 .../network/CiscoNexusVSMDeviceManagerImpl.java |  68 ++---
 .../network/element/CiscoNexusVSMElement.java   |  50 ++--
 .../network/element/BigSwitchVnsElement.java    |  45 ++--
 .../cloud/network/element/CiscoVnmcElement.java | 265 ++++++++++---------
 .../network/guru/MidoNetPublicNetworkGuru.java  |  19 +-
 .../cloud/network/element/NetscalerElement.java |  52 ++--
 .../cloud/network/element/NiciraNvpElement.java |  45 ++--
 .../lb/ApplicationLoadBalancerManagerImpl.java  |   2 +-
 15 files changed, 408 insertions(+), 458 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cbb309d/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java b/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java
index 8f7b6d8..e0c2f57 100644
--- a/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java
+++ b/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cbb309d/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
index fcc1b4f..dec6b38 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
@@ -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();
         }
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cbb309d/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
index d23575b..64463d4 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
@@ -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());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cbb309d/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
index 64df113..0ac49ad 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
@@ -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();
         }
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cbb309d/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
index f6bd2b6..f30bd36 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cbb309d/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java
index fd825b7..a681c06 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cbb309d/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index 211f668..9af0aa0 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cbb309d/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
index 9ec64ff..1b08a5c 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cbb309d/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
index 6c6ce55..92564dd 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
@@ -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() +

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cbb309d/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java
index cb6e7fc..6b75634 100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java
@@ -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());
         }
     }


Mime
View raw message