cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [3/3] git commit: updated refs/heads/vmsync to 1f0186a
Date Wed, 26 Jun 2013 00:19:56 GMT
Removed all traces of casting


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

Branch: refs/heads/vmsync
Commit: 1f0186aafec37462fccc002e56ec2ece15a6c173
Parents: 241d546
Author: Alex Huang <alex.huang@gmail.com>
Authored: Tue Jun 25 17:20:39 2013 -0700
Committer: Alex Huang <alex.huang@gmail.com>
Committed: Tue Jun 25 17:20:39 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/hypervisor/guru/VMwareGuru.java   |  4 ++--
 .../network/element/VirtualRouterElement.java   | 23 +++++++++-----------
 .../VirtualNetworkApplianceManagerImpl.java     |  3 ++-
 .../com/cloud/storage/VolumeManagerImpl.java    | 14 +++++-------
 4 files changed, 20 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f0186aa/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
index 60839b1..9d2b842 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
@@ -117,8 +117,8 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru
{
             details = new HashMap<String, String>();
 
         String nicDeviceType = details.get(VmDetailConstants.NIC_ADAPTER);
-        if(vm.getVirtualMachine() instanceof DomainRouterVO || vm.getVirtualMachine() instanceof
ConsoleProxyVO
-                || vm.getVirtualMachine() instanceof SecondaryStorageVmVO) {
+        if (vm.getType() == VirtualMachine.Type.DomainRouter || vm.getType() == VirtualMachine.Type.ConsoleProxy
+                || vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
 
             if(nicDeviceType == null) {
                 details.put(VmDetailConstants.NIC_ADAPTER, _vmwareMgr.getSystemVMDefaultNicAdapterType());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f0186aa/server/src/com/cloud/network/element/VirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java
index 22eb86a..d2314e0 100755
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -79,8 +79,10 @@ import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.user.AccountManager;
+import com.cloud.uservm.UserVm;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.SearchCriteria2;
 import com.cloud.utils.db.SearchCriteriaService;
@@ -89,7 +91,6 @@ import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.UserVmManager;
-import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachine.State;
 import com.cloud.vm.VirtualMachine.Type;
@@ -143,6 +144,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     VirtualRouterProviderDao _vrProviderDao;
     @Inject
     IPAddressDao _ipAddressDao;
+    @Inject
+    EntityManager _entityMgr;
 
     protected boolean canHandle(Network network, Service service) {
         Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(network);
@@ -1026,12 +1029,10 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 			return true;
 		}
 		if (vm.getType() == Type.DomainRouter) {
-			assert vm instanceof DomainRouterVO;
-			DomainRouterVO router = (DomainRouterVO)vm.getVirtualMachine();
+            DomainRouterVO router = _entityMgr.findById(DomainRouterVO.class, vm.getId());
 			_routerMgr.setupDhcpForPvlan(false, router, router.getHostId(), nic);
 		} else if (vm.getType() == Type.User){
-			assert vm instanceof UserVmVO;
-			UserVmVO userVm = (UserVmVO)vm.getVirtualMachine();
+            UserVm userVm = _entityMgr.findById(UserVm.class, vm.getId());
 			_userVmMgr.setupVmForPvlan(false, userVm.getHostId(), nic);
 		}
 		return true;
@@ -1045,12 +1046,10 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 			return;
 		}
 		if (vm.getType() == Type.DomainRouter) {
-			assert vm instanceof DomainRouterVO;
-			DomainRouterVO router = (DomainRouterVO)vm.getVirtualMachine();
+            DomainRouterVO router = _entityMgr.findById(DomainRouterVO.class, vm.getId());
 			_routerMgr.setupDhcpForPvlan(true, router, router.getHostId(), nic);
 		} else if (vm.getType() == Type.User){
-			assert vm instanceof UserVmVO;
-			UserVmVO userVm = (UserVmVO)vm.getVirtualMachine();
+            UserVm userVm = _entityMgr.findById(UserVm.class, vm.getId());
 			_userVmMgr.setupVmForPvlan(true, userVm.getHostId(), nic);
 		}
 	}
@@ -1063,12 +1062,10 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 			return;
 		}
 		if (vm.getType() == Type.DomainRouter) {
-			assert vm instanceof DomainRouterVO;
-			DomainRouterVO router = (DomainRouterVO)vm.getVirtualMachine();
+            DomainRouterVO router = _entityMgr.findById(DomainRouterVO.class, vm.getId());
 			_routerMgr.setupDhcpForPvlan(true, router, router.getHostId(), nic);
 		} else if (vm.getType() == Type.User){
-			assert vm instanceof UserVmVO;
-			UserVmVO userVm = (UserVmVO)vm.getVirtualMachine();
+            UserVm userVm = _entityMgr.findById(UserVm.class, vm.getId());
 			_userVmMgr.setupVmForPvlan(true, userVm.getHostId(), nic);
 		}
 	}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f0186aa/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 9bceb32..488577e 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -486,7 +486,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements
V
     @Override
     public boolean savePasswordToRouter(Network network, final NicProfile nic, VirtualMachineProfile
profile, List<? extends VirtualRouter> routers)
             throws ResourceUnavailableException {
-        _userVmDao.loadDetails((UserVmVO)profile.getVirtualMachine());
+        UserVmVO vm = _userVmDao.findById(profile.getId());
+        _userVmDao.loadDetails(vm);
 
         final VirtualMachineProfile updatedProfile = profile;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f0186aa/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index 235adf6..da2f9c4 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -33,7 +33,6 @@ import javax.naming.ConfigurationException;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
@@ -162,6 +161,7 @@ import com.cloud.utils.Pair;
 import com.cloud.utils.UriUtils;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.fsm.NoTransitionException;
@@ -182,10 +182,8 @@ import com.cloud.vm.dao.VMInstanceDao;
 import com.cloud.vm.snapshot.VMSnapshotVO;
 import com.cloud.vm.snapshot.dao.VMSnapshotDao;
 
-@Component
 public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
-    private static final Logger s_logger = Logger
-            .getLogger(VolumeManagerImpl.class);
+    private static final Logger s_logger = Logger.getLogger(VolumeManagerImpl.class);
     @Inject
     protected UserVmManager _userVmMgr;
     @Inject
@@ -328,6 +326,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
     UploadMonitor _uploadMonitor;
     @Inject
     UploadDao _uploadDao;
+    @Inject
+    EntityManager _entityMgr;
 
     private int _copyvolumewait;
     @Inject
@@ -2209,9 +2209,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
     }
     
     @Override
-    public void prepareForMigration(
-            VirtualMachineProfile vm,
-            DeployDestination dest) {
+    public void prepareForMigration(VirtualMachineProfile vm, DeployDestination dest) {
         List<VolumeVO> vols = _volsDao.findUsableVolumesForInstance(vm.getId());
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Preparing " + vols.size() + " volumes for " + vm);
@@ -2224,7 +2222,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         }
 
         if (vm.getType() == VirtualMachine.Type.User) {
-            UserVmVO userVM = (UserVmVO) vm.getVirtualMachine();
+            UserVm userVM = _entityMgr.findById(UserVm.class, vm.getId());
             if (userVM.getIsoId() != null) {
                 DataTO dataTO = tmplFactory.getTemplate(userVM.getIsoId(), DataStoreRole.Image,
userVM.getDataCenterId()).getTO();
                 DiskTO iso = new DiskTO(dataTO, 3L, Volume.Type.ISO);


Mime
View raw message