cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [2/4] git commit: updated refs/heads/master to cb5ab37
Date Wed, 17 Jul 2013 23:22:25 GMT
Changed allocate method to be virtual machine type agnostic


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

Branch: refs/heads/master
Commit: 541f9d7f9c6bcd3c07db252647de2433667d1bb4
Parents: 76e7985
Author: ahuang <alex.huang@citrix.com>
Authored: Wed Jul 17 14:34:17 2013 -0700
Committer: ahuang <alex.huang@citrix.com>
Committed: Wed Jul 17 15:58:46 2013 -0700

----------------------------------------------------------------------
 .../orchestration/CloudOrchestrator.java        |  16 +-
 .../lb/ElasticLoadBalancerManagerImpl.java      |  65 +--
 .../lb/InternalLoadBalancerVMManagerImpl.java   |  66 +--
 .../consoleproxy/ConsoleProxyManagerImpl.java   |  26 +-
 .../VirtualNetworkApplianceManagerImpl.java     |  48 +-
 .../VpcVirtualNetworkApplianceManagerImpl.java  | 112 ++---
 .../secondary/SecondaryStorageManagerImpl.java  |  29 +-
 .../storage/snapshot/SnapshotManagerImpl.java   |  39 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java  |  33 +-
 server/src/com/cloud/vm/VirtualMachineGuru.java |  19 -
 .../src/com/cloud/vm/VirtualMachineManager.java |  34 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 171 +++----
 .../com/cloud/vm/MockUserVmManagerImpl.java     | 453 -------------------
 .../cloud/vm/MockVirtualMachineManagerImpl.java | 323 -------------
 .../cloud/vm/VirtualMachineManagerImplTest.java |  97 ++--
 15 files changed, 277 insertions(+), 1254 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/541f9d7f/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
index 96fb1d9..1efeb80 100755
--- a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
@@ -25,27 +25,27 @@ import java.util.Map;
 
 import javax.inject.Inject;
 
-import com.cloud.storage.VolumeManager;
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
 import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
+import org.apache.cloudstack.engine.cloud.entity.api.VMEntityManager;
 import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
 import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl;
-import org.apache.cloudstack.engine.cloud.entity.api.VMEntityManager;
 import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
 import org.apache.cloudstack.engine.service.api.OrchestrationService;
-import org.springframework.stereotype.Component;
 
 import com.cloud.deploy.DeploymentPlan;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.hypervisor.Hypervisor;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
-
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkVO;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.DiskOfferingVO;
+import com.cloud.storage.VolumeManager;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.user.dao.AccountDao;
@@ -211,9 +211,7 @@ public class CloudOrchestrator implements OrchestrationService {
 
 
 
-    	if (_itMgr.allocate(_userVmDao.findById(vm.getId(), true), _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null,	plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
-			return null;
-		}
+        _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType);
 
         return vmEntity;
     }
@@ -266,9 +264,7 @@ public class CloudOrchestrator implements OrchestrationService {
 
 		HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
 
-    	if (_itMgr.allocate(_userVmDao.findById(vm.getId(), true), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null,	plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
-			return null;
-		}
+        _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType);
 
         return vmEntity;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/541f9d7f/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
index 3e2cbbe..601b034 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -189,9 +189,9 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
     PodVlanMapDao _podVlanMapDao;
     @Inject
     ElasticLbVmMapDao _elbVmMapDao;
-    @Inject 
+    @Inject
     NetworkDao _networksDao;
-    @Inject 
+    @Inject
     AccountDao _accountDao;
     @Inject
     PhysicalNetworkServiceProviderDao _physicalProviderDao;
@@ -228,7 +228,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
         }
     }
 
-    public DomainRouterVO deployLoadBalancerVM(Long networkId, IPAddressVO ipAddr, Long accountId) {  
+    public DomainRouterVO deployLoadBalancerVM(Long networkId, IPAddressVO ipAddr, Long accountId) {
         NetworkVO network = _networkDao.findById(networkId);
         DataCenter dc = _dcDao.findById(network.getDataCenterId());
         Long podId = getPodIdForDirectIp(ipAddr);
@@ -300,7 +300,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
             String uuid = rule.getUuid();
             List<LbDestination> destinations = rule.getDestinations();
             LoadBalancerTO lb = new LoadBalancerTO(uuid, elbIp, srcPort, protocol, algorithm, revoked, false, false, destinations);
-            lbs[i++] = lb; 
+            lbs[i++] = lb;
         }
 
         NetworkOffering offering =_networkOfferingDao.findById(guestNetworkId);
@@ -411,8 +411,8 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
         _elasticLbVmRamSize = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmMemory.key()), DEFAULT_ELB_VM_RAMSIZE);
         _elasticLbvmCpuMHz = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmCpuMhz.key()), DEFAULT_ELB_VM_CPU_MHZ);
         _elasticLbvmNumCpu = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmNumVcpu.key()), 1);
-        _elasticLbVmOffering = new ServiceOfferingVO("System Offering For Elastic LB VM", _elasticLbvmNumCpu, 
-                _elasticLbVmRamSize, _elasticLbvmCpuMHz, 0, 0, true, null, useLocalStorage, 
+        _elasticLbVmOffering = new ServiceOfferingVO("System Offering For Elastic LB VM", _elasticLbvmNumCpu,
+                _elasticLbVmRamSize, _elasticLbvmCpuMHz, 0, 0, true, null, useLocalStorage,
                 true, null, true, VirtualMachine.Type.ElasticLoadBalancerVm, true);
         _elasticLbVmOffering.setUniqueName(ServiceOffering.elbVmDefaultOffUniqueName);
         _elasticLbVmOffering = _serviceOfferingDao.persistSystemServiceOffering(_elasticLbVmOffering);
@@ -430,7 +430,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
                 throw new ConfigurationException("ELB: Traffic type for front end of load balancer has to be guest or public; found : " + traffType);
             s_logger.info("ELB: Elastic Load Balancer: will balance on " + traffType );
             int gcIntervalMinutes =  NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmGcInterval.key()), 5);
-            if (gcIntervalMinutes < 5) 
+            if (gcIntervalMinutes < 5)
                 gcIntervalMinutes = 5;
             s_logger.info("ELB: Elastic Load Balancer: scheduling GC to run every " + gcIntervalMinutes + " minutes" );
             _gcThreadPool = Executors.newScheduledThreadPool(1, new NamedThreadFactory("ELBVM-GC"));
@@ -475,8 +475,8 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Starting a ELB vm for network configurations: " + guestNetwork + " in " + dest);
             }
-            assert guestNetwork.getState() == Network.State.Implemented 
-                || guestNetwork.getState() == Network.State.Setup 
+            assert guestNetwork.getState() == Network.State.Implemented
+                    || guestNetwork.getState() == Network.State.Setup
                     || guestNetwork.getState() == Network.State.Implementing : "Network is not yet fully implemented: " + guestNetwork;
 
             DataCenterDeployment plan = null;
@@ -513,12 +513,14 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
                     throw new CloudRuntimeException("Cannot find virtual router provider " + typeString + " as service provider " + provider.getId());
                 }
                
-                elbVm = new DomainRouterVO(id, _elasticLbVmOffering.getId(), vrProvider.getId(), 
+                elbVm = new DomainRouterVO(id, _elasticLbVmOffering.getId(), vrProvider.getId(),
                         VirtualMachineName.getSystemVmName(id, _instance, _elbVmNamePrefix), template.getId(), template.getHypervisorType(),
                         template.getGuestOSId(), owner.getDomainId(), owner.getId(), false, 0, false, RedundantState.UNKNOWN,
                         _elasticLbVmOffering.getOfferHA(), false, VirtualMachine.Type.ElasticLoadBalancerVm, null);
                 elbVm.setRole(Role.LB);
-                elbVm = _itMgr.allocate(elbVm, template, _elasticLbVmOffering, networks, plan, null, owner);
+                elbVm = _routerDao.persist(elbVm);
+                _itMgr.allocate(elbVm.getInstanceName(), template, _elasticLbVmOffering, networks, plan, null);
+                elbVm = _routerDao.findById(elbVm.getId());
                 //TODO: create usage stats
             }
 
@@ -558,7 +560,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
     
     protected List<LoadBalancerVO> findExistingLoadBalancers(String lbName, Long ipId, Long accountId, Long domainId, Integer publicPort) {
         SearchBuilder<LoadBalancerVO> sb = _lbDao.createSearchBuilder();
-        sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ); 
+        sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
         sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
         sb.and("publicPort", sb.entity().getSourcePortStart(), SearchCriteria.Op.EQ);
         if (ipId != null) {
@@ -575,7 +577,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
         sc.setParameters("accountId", accountId);
         if (ipId != null) {
             sc.setParameters("sourceIpAddress", ipId);
-        } 
+        }
         if (domainId != null) {
             sc.setParameters("domainId",domainId);
         }
@@ -595,7 +597,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
         
         PublicIp ip = _networkMgr.assignPublicIpAddress(frontEndNetwork.getDataCenterId(), null, account, VlanType.DirectAttached, frontEndNetwork.getId(), null, true);
         IPAddressVO ipvo = _ipAddressDao.findById(ip.getId());
-        ipvo.setAssociatedWithNetworkId(frontEndNetwork.getId()); 
+        ipvo.setAssociatedWithNetworkId(frontEndNetwork.getId());
         _ipAddressDao.update(ipvo.getId(), ipvo);
         txn.commit();
         s_logger.info("Acquired frontend IP for ELB " + ip);
@@ -606,7 +608,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
     public void releaseIp(long ipId, long userId, Account caller) {
         s_logger.info("ELB: Release public IP for loadbalancing " + ipId);
         IPAddressVO ipvo = _ipAddressDao.findById(ipId);
-        ipvo.setAssociatedWithNetworkId(null); 
+        ipvo.setAssociatedWithNetworkId(null);
         _ipAddressDao.update(ipvo.getId(), ipvo);
        _networkMgr.disassociatePublicIpAddress(ipId, userId, caller);
        _ipAddressDao.unassignIpAddress(ipId);
@@ -639,7 +641,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
                         existingLbs = findExistingLoadBalancers(lb.getName(), null, lb.getAccountId(), lb.getDomainId(), null);
                         if (existingLbs != null) {
                             throw new InvalidParameterValueException("Supplied LB name " + lb.getName() + " is not associated with IP " + lb.getSourceIpAddressId() );
-                        } 
+                        }
                     } else {
                         s_logger.debug("Could not find any existing frontend ips for this account for this LB rule, acquiring a new frontent IP for ELB");
                         PublicIp ip = allocDirectIp(account, networkId);
@@ -662,7 +664,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
             try {
                 lb.setSourceIpAddressId(ipId);
                 
-                result = _lbMgr.createPublicLoadBalancer(lb.getXid(), lb.getName(), lb.getDescription(), 
+                result = _lbMgr.createPublicLoadBalancer(lb.getXid(), lb.getName(), lb.getDescription(),
                         lb.getSourcePortStart(), lb.getDefaultPortStart(), ipId.longValue(), lb.getProtocol(),
                         lb.getAlgorithm(), false, CallContext.current());
             } catch (NetworkRuleConflictException e) {
@@ -779,25 +781,11 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
     }
 
     @Override
-    public DomainRouterVO findByName(String name) {
-        if (!VirtualMachineName.isValidSystemVmName(name, _instance, _elbVmNamePrefix)) {
-            return null;
-        }
-
-        return _routerDao.findById(VirtualMachineName.getSystemVmId(name));
-    }
-
-    @Override
     public DomainRouterVO findById(long id) {
         return _routerDao.findById(id);
     }
 
     @Override
-    public DomainRouterVO persist(DomainRouterVO elbVm) {
-        return _routerDao.persist(elbVm);
-    }
-
-    @Override
     public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest, ReservationContext context) {
         DomainRouterVO elbVm = profile.getVirtualMachine();
         
@@ -860,7 +848,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
         String domain = guestNetwork.getNetworkDomain();
         if (domain != null) {
             buf.append(" domain=" + domain);
-        }  
+        }
 
         buf.append(" dns1=").append(defaultDns1);
         if (defaultDns2 != null) {
@@ -984,16 +972,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
     }
 
     @Override
-    public Long convertToId(String vmName) {
-        if (!VirtualMachineName.isValidSystemVmName(vmName, _instance, _elbVmNamePrefix)) {
-            return null;
-        }
-
-        return VirtualMachineName.getSystemVmId(vmName);
-    }
-    
-    @Override
     public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile) {
-    } 
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/541f9d7f/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
index e027ec3..06d3f70 100644
--- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -151,26 +151,11 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
     @Inject ConfigurationServer _configServer;
 
     @Override
-    public DomainRouterVO findByName(String name) {
-        if (!VirtualMachineName.isValidSystemVmName(name, _instance, _internalLbVmNamePrefix)) {
-            return null;
-        }
-
-        return _internalLbVmDao.findById(VirtualMachineName.getRouterId(name));
-    }
-
-    @Override
     public DomainRouterVO findById(long id) {
         return _internalLbVmDao.findById(id);
     }
 
     @Override
-    public DomainRouterVO persist(DomainRouterVO vm) {
-        DomainRouterVO virtualRouter =  _internalLbVmDao.persist(vm);
-        return virtualRouter;
-    }
-
-    @Override
     public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile,
             DeployDestination dest, ReservationContext context) {
 
@@ -208,7 +193,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
                 // Internal LB control command is sent over management server in VMware
                 if (dest.getHost().getHypervisorType() == HypervisorType.VMware) {
                     if (s_logger.isInfoEnabled()) {
-                        s_logger.info("Check if we need to add management server explicit route to Internal LB. pod cidr: " 
+                        s_logger.info("Check if we need to add management server explicit route to Internal LB. pod cidr: "
                                 + dest.getPod().getCidrAddress() + "/" + dest.getPod().getCidrSize()
                                 + ", pod gateway: " + dest.getPod().getGateway() + ", management host: " + _mgmtHost);
                     }
@@ -325,7 +310,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
 
         // restart network if restartNetwork = false is not specified in profile parameters
         boolean reprogramGuestNtwk = true;
-        if (profile.getParameter(Param.ReProgramGuestNetworks) != null 
+        if (profile.getParameter(Param.ReProgramGuestNetworks) != null
                 && (Boolean) profile.getParameter(Param.ReProgramGuestNetworks) == false) {
             reprogramGuestNtwk = false;
         }
@@ -357,15 +342,6 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
     }
 
     @Override
-    public Long convertToId(String vmName) {
-        if (!VirtualMachineName.isValidSystemVmName(vmName, _instance, _internalLbVmNamePrefix)) {
-            return null;
-        }
-
-        return VirtualMachineName.getRouterId(vmName);
-    }
-
-    @Override
     public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile) {
     }
     
@@ -477,9 +453,9 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
         
         Network guestNetwork = _ntwkModel.getNetwork(guestNetworkId);
         Nic guestNic = _nicDao.findByNtwkIdAndInstanceId(guestNetwork.getId(), internalLbVm.getId());
-        NicProfile guestNicProfile = new NicProfile(guestNic, guestNetwork, guestNic.getBroadcastUri(), guestNic.getIsolationUri(), 
-                _ntwkModel.getNetworkRate(guestNetwork.getId(), internalLbVm.getId()), 
-                _ntwkModel.isSecurityGroupSupportedInNetwork(guestNetwork), 
+        NicProfile guestNicProfile = new NicProfile(guestNic, guestNetwork, guestNic.getBroadcastUri(), guestNic.getIsolationUri(),
+                _ntwkModel.getNetworkRate(guestNetwork.getId(), internalLbVm.getId()),
+                _ntwkModel.isSecurityGroupSupportedInNetwork(guestNetwork),
                 _ntwkModel.getNetworkTag(internalLbVm.getHypervisorType(), guestNetwork));
 
         NetworkOffering offering =_networkOfferingDao.findById(guestNetworkId);
@@ -541,7 +517,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
 
         _accountMgr.checkAccess(caller, null, true, internalLbVm);
 
-        return _itMgr.expunge(internalLbVm, _accountMgr.getActiveUser(callerUserId), caller); 
+        return _itMgr.expunge(internalLbVm, _accountMgr.getActiveUser(callerUserId), caller);
     }
 
     
@@ -574,7 +550,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
     
     
     @Override
-    public List<DomainRouterVO> deployInternalLbVm(Network guestNetwork, Ip requestedGuestIp, DeployDestination dest, 
+    public List<DomainRouterVO> deployInternalLbVm(Network guestNetwork, Ip requestedGuestIp, DeployDestination dest,
             Account owner, Map<Param, Object> params) throws InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException {
 
@@ -583,7 +559,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
         return startInternalLbVms(params, internalLbVms);
     }
     
-    protected List<DomainRouterVO> startInternalLbVms(Map<Param, Object> params, List<DomainRouterVO> internalLbVms) 
+    protected List<DomainRouterVO> startInternalLbVms(Map<Param, Object> params, List<DomainRouterVO> internalLbVms)
             throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
         List<DomainRouterVO> runningInternalLbVms = null;
 
@@ -609,8 +585,8 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
     
     
     @DB
-    protected List<DomainRouterVO> findOrDeployInternalLbVm(Network guestNetwork, Ip requestedGuestIp, DeployDestination dest, 
-            Account owner, Map<Param, Object> params) throws ConcurrentOperationException, 
+    protected List<DomainRouterVO> findOrDeployInternalLbVm(Network guestNetwork, Ip requestedGuestIp, DeployDestination dest,
+            Account owner, Map<Param, Object> params) throws ConcurrentOperationException,
             InsufficientCapacityException, ResourceUnavailableException {
 
         List<DomainRouterVO> internalLbVms = new ArrayList<DomainRouterVO>();
@@ -688,7 +664,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
             s_logger.debug("Adding nic for Internal LB in Guest network " + guestNetwork);
             NicProfile guestNic = new NicProfile();
             if (guestIp != null) {
-                guestNic.setIp4Address(guestIp.addr());  
+                guestNic.setIp4Address(guestIp.addr());
             } else {
                 guestNic.setIp4Address(_ntwkMgr.acquireGuestIpAddress(guestNetwork, null));
             }
@@ -789,12 +765,14 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
                     continue;
                 }
 
-                internalLbVm = new DomainRouterVO(id, routerOffering.getId(), internalLbProviderId, 
+                internalLbVm = new DomainRouterVO(id, routerOffering.getId(), internalLbProviderId,
                 VirtualMachineName.getSystemVmName(id, _instance, _internalLbVmNamePrefix), template.getId(), template.getHypervisorType(),
-                template.getGuestOSId(), owner.getDomainId(), owner.getId(), false, 0, false, 
+                template.getGuestOSId(), owner.getDomainId(), owner.getId(), false, 0, false,
                 RedundantState.UNKNOWN, false, false, VirtualMachine.Type.InternalLoadBalancerVm, vpcId);
                 internalLbVm.setRole(Role.INTERNAL_LB_VM);
-                internalLbVm = _itMgr.allocate(internalLbVm, template, routerOffering, networks, plan, null, owner);
+                internalLbVm = _internalLbVmDao.persist(internalLbVm);
+                _itMgr.allocate(internalLbVm.getInstanceName(), template, routerOffering, networks, plan, null);
+                internalLbVm = _internalLbVmDao.findById(internalLbVm.getId());
             } catch (InsufficientCapacityException ex) {
                 if (allocateRetry < 2 && iter.hasNext()) {
                     s_logger.debug("Failed to allocate the Internal lb vm with hypervisor type " + hType + ", retrying one more time");
@@ -833,7 +811,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
     
     
 
-    protected DomainRouterVO startInternalLbVm(DomainRouterVO internalLbVm, Account caller, long callerUserId, Map<Param, Object> params) 
+    protected DomainRouterVO startInternalLbVm(DomainRouterVO internalLbVm, Account caller, long callerUserId, Map<Param, Object> params)
             throws StorageUnavailableException, InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException {
         s_logger.debug("Starting Internal LB VM " + internalLbVm);
@@ -850,7 +828,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
     }
     
     
-    protected List<HypervisorType> getHypervisors(DeployDestination dest, DeploymentPlan plan, 
+    protected List<HypervisorType> getHypervisors(DeployDestination dest, DeploymentPlan plan,
             List<HypervisorType> supportedHypervisors) throws InsufficientServerCapacityException {
         List<HypervisorType> hypervisors = new ArrayList<HypervisorType>();
 
@@ -880,7 +858,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
     }
     
     @Override
-    public boolean applyLoadBalancingRules(Network network, final List<LoadBalancingRule> rules, List<? extends VirtualRouter> internalLbVms) 
+    public boolean applyLoadBalancingRules(Network network, final List<LoadBalancingRule> rules, List<? extends VirtualRouter> internalLbVms)
             throws ResourceUnavailableException {
         if (rules == null || rules.isEmpty()) {
             s_logger.debug("No lb rules to be applied for network " + network);
@@ -896,7 +874,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
         if (lbVm.getState() == State.Running) {
             return sendLBRules(lbVm, rules, network.getId());
         } else if (lbVm.getState() == State.Stopped || lbVm.getState() == State.Stopping) {
-            s_logger.debug("Internal LB VM " + lbVm.getInstanceName() + " is in " + lbVm.getState() + 
+            s_logger.debug("Internal LB VM " + lbVm.getInstanceName() + " is in " + lbVm.getState() +
                     ", so not sending apply lb rules commands to the backend");
             return true;
         } else {
@@ -943,7 +921,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
     
     
     @Override
-    public VirtualRouter startInternalLbVm(long internalLbVmId, Account caller, long callerUserId) 
+    public VirtualRouter startInternalLbVm(long internalLbVmId, Account caller, long callerUserId)
             throws StorageUnavailableException, InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException {
         

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/541f9d7f/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 1035c5c..30fbb48 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -723,8 +723,9 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
 
         ConsoleProxyVO proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(),
                 systemAcct.getId(), 0, _serviceOffering.getOfferHA());
+        proxy = _consoleProxyDao.persist(proxy);
         try {
-            proxy = _itMgr.allocate(proxy, template, _serviceOffering, networks, plan, null, systemAcct);
+            _itMgr.allocate(name, template, _serviceOffering, networks, plan, null);
         } catch (InsufficientCapacityException e) {
             s_logger.warn("InsufficientCapacity", e);
             throw new CloudRuntimeException("Insufficient capacity exception", e);
@@ -1009,14 +1010,6 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
     }
 
     @Override
-    public Long convertToId(String vmName) {
-        if (!VirtualMachineName.isValidConsoleProxyName(vmName, _instance)) {
-            return null;
-        }
-        return VirtualMachineName.getConsoleProxyId(vmName);
-    }
-
-    @Override
     public boolean stopProxy(long proxyVmId) {
         ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
         if (proxy == null) {
@@ -1479,27 +1472,12 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
         _consoleProxyDao.update(proxy.getId(), proxy);
     }
 
-
-
-    @Override
-    public ConsoleProxyVO persist(ConsoleProxyVO proxy) {
-        return _consoleProxyDao.persist(proxy);
-    }
-
     @Override
     public ConsoleProxyVO findById(long id) {
         return _consoleProxyDao.findById(id);
     }
 
     @Override
-    public ConsoleProxyVO findByName(String name) {
-        if (!VirtualMachineName.isValidConsoleProxyName(name)) {
-            return null;
-        }
-        return findById(VirtualMachineName.getConsoleProxyId(name));
-    }
-
-    @Override
     public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, StopAnswer answer) {
         //release elastic IP here if assigned
         IPAddressVO ip = _ipAddressDao.findByAssociatedVmId(profile.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/541f9d7f/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 66d904c..6390395 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -790,15 +790,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
     protected VirtualNetworkApplianceManagerImpl() {
     }
 
-    @Override
-    public Long convertToId(final String vmName) {
-        if (!VirtualMachineName.isValidRouterName(vmName, _instance)) {
-            return null;
-        }
-
-        return VirtualMachineName.getRouterId(vmName);
-    }
-
     private VmDataCommand generateVmDataCommand(VirtualRouter router, String vmPrivateIpAddress, String userData,
             String serviceOffering, String zoneName, String guestIpAddress, String vmName,
             String vmInstanceName, long vmId, String vmUuid, String publicKey, long guestNetworkId) {
@@ -1046,7 +1037,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             }
             String privateIP = router.getPrivateIpAddress();
             HostVO host = _hostDao.findById(router.getHostId());
-            if (host == null || host.getStatus() != Status.Up) {
+            if (host == null || host.getState() != Status.Up) {
                 continue;
             } else if (host.getManagementServerId() != ManagementServerNode.getManagementServerId()) {
                 /* Only cover hosts managed by this management server */
@@ -1118,7 +1109,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             } else {
                 String privateIP = router.getPrivateIpAddress();
                 HostVO host = _hostDao.findById(router.getHostId());
-                if (host == null || host.getStatus() != Status.Up) {
+                if (host == null || host.getState() != Status.Up) {
                     router.setRedundantState(RedundantState.UNKNOWN);
                     updated = true;
                 } else if (privateIP != null) {
@@ -1177,7 +1168,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
         if (masterRouter.getState() == State.Running && backupRouter.getState() == State.Running) {
             HostVO masterHost = _hostDao.findById(masterRouter.getHostId());
             HostVO backupHost = _hostDao.findById(backupRouter.getHostId());
-            if (masterHost.getStatus() == Status.Up && backupHost.getStatus() == Status.Up) {
+            if (masterHost.getState() == Status.Up && backupHost.getState() == Status.Up) {
                 String title =  "Reboot " + backupRouter.getInstanceName() + " to ensure redundant virtual routers work";
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(title);
@@ -1412,7 +1403,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             }
 
             for (HostVO h : hosts) {
-                if (h.getStatus() == Status.Up) {
+                if (h.getState() == Status.Up) {
                     s_logger.debug("Pick up host that has hypervisor type " + h.getHypervisorType() + " in cluster " +
                                 cv.getId() + " to start domain router for OVM");
                     return h.getHypervisorType();
@@ -1658,7 +1649,9 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                 template.getGuestOSId(), owner.getDomainId(), owner.getId(), isRedundant, 0, false,
                 RedundantState.UNKNOWN, offerHA, false, vpcId);
                 router.setRole(Role.VIRTUAL_ROUTER);
-                router = _itMgr.allocate(router, template, routerOffering, networks, plan, null, owner);
+                router = _routerDao.persist(router);
+                _itMgr.allocate(router.getInstanceName(), template, routerOffering, networks, plan, null);
+                router = _routerDao.findById(router.getId());
             } catch (InsufficientCapacityException ex) {
                 if (allocateRetry < 2 && iter.hasNext()) {
                     s_logger.debug("Failed to allocate the VR with hypervisor type " + hType + ", retrying one more time");
@@ -1979,7 +1972,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             State state = router.getState();
             if (router.getHostId() != null && state != State.Running) {
                 HostVO host = _hostDao.findById(router.getHostId());
-                if (host == null || host.getStatus() != Status.Up) {
+                if (host == null || host.getState() != Status.Up) {
                     skip = true;
                 }
             }
@@ -2673,7 +2666,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             if (router.getState() != State.Running) {
                 s_logger.warn("Failed to start remote access VPN: router not in right state " + router.getState());
                 throw new ResourceUnavailableException("Failed to start remote access VPN: router not in right state "
-                + router.getState(), DataCenter.class, network.getDataCenterId());
+                        + router.getState(), DataCenter.class, network.getDataCenterId());
             }
 
             Commands cmds = new Commands(OnError.Stop);
@@ -2741,7 +2734,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             } else {
                 s_logger.warn("Failed to delete remote access VPN: domR " + router + " is not in right state " + router.getState());
                 throw new ResourceUnavailableException("Failed to delete remote access VPN: domR is not in right state " +
-                router.getState(), DataCenter.class, network.getDataCenterId());
+                        router.getState(), DataCenter.class, network.getDataCenterId());
             }
         }
 
@@ -3026,12 +3019,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
     }
 
     @Override
-    public DomainRouterVO persist(DomainRouterVO router) {
-        DomainRouterVO virtualRouter =  _routerDao.persist(router);
-        return virtualRouter;
-    }
-
-    @Override
     //FIXME add partial success and STOP state support
     public String[] applyVpnUsers(Network network, List<? extends VpnUser> users, List<DomainRouterVO> routers) throws ResourceUnavailableException {
         if (routers == null || routers.isEmpty()) {
@@ -3046,7 +3033,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             if (router.getState() != State.Running) {
                 s_logger.warn("Failed to add/remove VPN users: router not in running state");
                 throw new ResourceUnavailableException("Unable to assign ip addresses, domR is not in right state " +
-                router.getState(), DataCenter.class, network.getDataCenterId());
+                        router.getState(), DataCenter.class, network.getDataCenterId());
             }
 
             Commands cmds = new Commands(OnError.Continue);
@@ -3095,15 +3082,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
         return _routerDao.findById(id);
     }
 
-    @Override
-    public DomainRouterVO findByName(String name) {
-        if (!VirtualMachineName.isValidRouterName(name)) {
-            return null;
-        }
-
-        return _routerDao.findById(VirtualMachineName.getRouterId(name));
-    }
-
     @Override @ActionEvent(eventType = EventTypes.EVENT_ROUTER_START, eventDescription = "starting router Vm", async = true)
     public VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException{
         return startRouter(id, true);
@@ -3810,7 +3788,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                 s_logger.debug("Applying " + typeString + " in network " + network);
 
                 if (router.isStopPending()) {
-                    if (_hostDao.findById(router.getHostId()).getStatus() == Status.Up) {
+                    if (_hostDao.findById(router.getHostId()).getState() == Status.Up) {
                         throw new ResourceUnavailableException("Unable to process due to the stop pending router " +
                     router.getInstanceName() + " haven't been stopped after it's host coming back!",
                                 DataCenter.class, router.getDataCenterId());
@@ -3840,7 +3818,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                 s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
                         ", so not sending apply " + typeString + " commands to the backend");
             } else {
-                s_logger.warn("Unable to apply " + typeString +", virtual router is not in the right state " + router.getState());
+                s_logger.warn("Unable to apply " + typeString + ", virtual router is not in the right state " + router.getState());
                 if (isZoneBasic && isPodLevelException) {
                     throw new ResourceUnavailableException("Unable to apply " + typeString +
                             ", virtual router is not in the right state", Pod.class, podId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/541f9d7f/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index 986dd4f..3ca4331 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -164,7 +164,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     NetworkACLItemDao _networkACLItemDao;
     
     @Override
-    public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner, 
+    public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
             Map<Param, Object> params) throws InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException {
         if(s_logger.isTraceEnabled()) {
@@ -178,7 +178,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     
     @DB
     protected List<DomainRouterVO> findOrDeployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
-            Map<Param, Object> params) throws ConcurrentOperationException, 
+            Map<Param, Object> params) throws ConcurrentOperationException,
             InsufficientCapacityException, ResourceUnavailableException {
 
         s_logger.debug("Deploying Virtual Router in VPC "+ vpc);
@@ -187,11 +187,11 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             throw new ConcurrentOperationException("Unable to lock vpc " + vpc.getId());
         }
         
-        //1) Get deployment plan and find out the list of routers     
+        //1) Get deployment plan and find out the list of routers
         Pair<DeploymentPlan, List<DomainRouterVO>> planAndRouters = getDeploymentPlanAndRouters(vpc.getId(), dest);
         DeploymentPlan plan = planAndRouters.first();
         List<DomainRouterVO> routers = planAndRouters.second();
-        try { 
+        try {
             //2) Return routers if exist
             if (routers.size() >= 1) {
                 return routers;
@@ -207,13 +207,13 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             VirtualRouterProvider vpcVrProvider = null;
            
             for (PhysicalNetwork pNtwk : pNtwks) {
-                PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(pNtwk.getId(), 
+                PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(pNtwk.getId(),
                         VirtualRouterProviderType.VPCVirtualRouter.toString());
                 if (provider == null) {
-                    throw new CloudRuntimeException("Cannot find service provider " + 
+                    throw new CloudRuntimeException("Cannot find service provider " +
                             VirtualRouterProviderType.VPCVirtualRouter.toString() + " in physical network " + pNtwk.getId());
                 }
-                vpcVrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(), 
+                vpcVrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(),
                         VirtualRouterProviderType.VPCVirtualRouter);
                 if (vpcVrProvider != null) {
                     break;
@@ -245,7 +245,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
 
     
     @Override
-    public boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) 
+    public boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
             throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
         if (s_logger.isTraceEnabled()) {
             s_logger.trace("addVpcRouterToGuestNetwork(" + router.getUuid() + ", " + network.getCidr() + ", " + isRedundant + ")");
@@ -288,7 +288,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     }
 
     @Override
-    public boolean removeVpcRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) 
+    public boolean removeVpcRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
             throws ConcurrentOperationException, ResourceUnavailableException {
         if (network.getTrafficType() != TrafficType.Guest) {
             s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest);
@@ -318,8 +318,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     
     protected DomainRouterVO deployVpcRouter(Account owner, DeployDestination dest, DeploymentPlan plan, Map<Param, Object> params,
             boolean isRedundant, VirtualRouterProvider vrProvider, long svcOffId,
-            Long vpcId, PublicIp sourceNatIp) throws ConcurrentOperationException, 
-            InsufficientAddressCapacityException, InsufficientServerCapacityException, InsufficientCapacityException, 
+            Long vpcId, PublicIp sourceNatIp) throws ConcurrentOperationException,
+            InsufficientAddressCapacityException, InsufficientServerCapacityException, InsufficientCapacityException,
             StorageUnavailableException, ResourceUnavailableException {
         if(s_logger.isTraceEnabled()) {
             s_logger.trace("deployVpcRouter(" + owner.getAccountName() + ", " + dest.getHost() + ", " + plan.toString() + ", " + params.toString()
@@ -327,19 +327,19 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         }
         List<Pair<NetworkVO, NicProfile>> networks = createVpcRouterNetworks(owner, isRedundant, plan, new Pair<Boolean, PublicIp>(true, sourceNatIp),
                 vpcId);
-        DomainRouterVO router = 
-                super.deployRouter(owner, dest, plan, params, isRedundant, vrProvider, svcOffId, vpcId, networks, true, 
+        DomainRouterVO router =
+                super.deployRouter(owner, dest, plan, params, isRedundant, vrProvider, svcOffId, vpcId, networks, true,
                         _vpcMgr.getSupportedVpcHypervisors());
         
         return router;
     }
     
-    protected boolean setupVpcGuestNetwork(Network network, VirtualRouter router, boolean add, NicProfile guestNic) 
+    protected boolean setupVpcGuestNetwork(Network network, VirtualRouter router, boolean add, NicProfile guestNic)
             throws ConcurrentOperationException, ResourceUnavailableException{
 
-        boolean result = true;  
+        boolean result = true;
         if (router.getState() == State.Running) {
-            SetupGuestNetworkCommand setupCmd = createSetupGuestNetworkCommand(router, add, guestNic);   
+            SetupGuestNetworkCommand setupCmd = createSetupGuestNetworkCommand(router, add, guestNic);
 
             Commands cmds = new Commands(OnError.Stop);
             cmds.addCommand("setupguestnetwork", setupCmd);
@@ -353,7 +353,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             }
             return result;
         } else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
-            s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + 
+            s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
                     ", so not sending setup guest network command to the backend");
             return true;
         } else {
@@ -370,7 +370,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         String defaultDns2 = null;
         
         boolean dnsProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter);
-        boolean dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, 
+        boolean dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
                 Provider.VPCVirtualRouter);
         
         boolean setupDns = dnsProvided || dhcpProvided;
@@ -386,7 +386,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         
         NicProfile nicProfile = _networkModel.getNicProfile(router, nic.getNetworkId(), null);
 
-        SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, false, null, 
+        SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, false, null,
                 defaultDns1, defaultDns2, add, _itMgr.toNicTO(nicProfile, router.getHypervisorType()));
         
         String brd = NetUtils.long2Ip(NetUtils.ip2Long(guestNic.getIp4Address()) | ~NetUtils.ip2Long(guestNic.getNetmask()));
@@ -441,7 +441,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                 
                 String macAddress = vlanMacAddress.get(ipAddr.getVlanTag());
                 
-                IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, false, 
+                IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, false,
                         ipAddr.isSourceNat(), ipAddr.getVlanTag(), ipAddr.getGateway(), ipAddr.getNetmask(), macAddress,
                         networkRate, ipAddr.isOneToOneNat());
 
@@ -509,7 +509,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                 URI broadcastUri = BroadcastDomainType.Vlan.toUri(vlanTag);
                 _itMgr.removeVmFromNetwork(router, publicNtwk, broadcastUri);
             } catch (ConcurrentOperationException e) {
-                s_logger.warn("Failed to remove router " + router + " from vlan " + vlanTag + 
+                s_logger.warn("Failed to remove router " + router + " from vlan " + vlanTag +
                         " in public network " + publicNtwk + " due to ", e);
                 return false;
             }
@@ -540,14 +540,14 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                 publicNtwk = _networkModel.getNetwork(ip.getNetworkId());
                 publicNic = _itMgr.addVmToNetwork(router, publicNtwk, defaultNic);
             } catch (ConcurrentOperationException e) {
-                s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag + 
+                s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
                         " in public network " + publicNtwk + " due to ", e);
             } catch (InsufficientCapacityException e) {
-                s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag + 
+                s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
                         " in public network " + publicNtwk + " due to ", e);
             } finally {
                 if (publicNic == null) {
-                    s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag + 
+                    s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
                             " in public network " + publicNtwk);
                     return false;
                 }
@@ -555,7 +555,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             //Create network usage commands. Send commands to router after IPAssoc
             NetworkUsageCommand netUsageCmd = new NetworkUsageCommand(router.getPrivateIpAddress(), router.getInstanceName(), true, defaultNic.getIp4Address(), vpc.getCidr());
             netUsagecmds.addCommand(netUsageCmd);
-            UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(), 
+            UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(),
             publicNtwk.getId(), publicNic.getIp4Address(), router.getId(), router.getType().toString());
             if (stats == null) {
                 stats = new UserStatisticsVO(router.getAccountId(), router.getDataCenterId(), publicNic.getIp4Address(), router.getId(),
@@ -573,22 +573,22 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                 List<PublicIpAddress> ipsToSend = new ArrayList<PublicIpAddress>();
                 for (PublicIpAddress ipAddr : ipAddress) {
                     String broadcastURI = BroadcastDomainType.Vlan.toUri(ipAddr.getVlanTag()).toString();
-                    Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(ipAddr.getNetworkId(), 
+                    Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(ipAddr.getNetworkId(),
                             router.getId(), broadcastURI);
                     
                     String macAddress = null;
                     if (nic == null) {
                         if (ipAddr.getState() != IpAddress.State.Releasing) {
-                            throw new CloudRuntimeException("Unable to find the nic in network " + ipAddr.getNetworkId() + 
+                            throw new CloudRuntimeException("Unable to find the nic in network " + ipAddr.getNetworkId() +
                                     "  to apply the ip address " + ipAddr  + " for");
                         }
-                        s_logger.debug("Not sending release for ip address " + ipAddr + 
+                        s_logger.debug("Not sending release for ip address " + ipAddr +
                                 " as its nic is already gone from VPC router " + router);
                     } else {
                         macAddress = nic.getMacAddress();
                         vlanMacAddress.put(ipAddr.getVlanTag(), macAddress);
                         ipsToSend.add(ipAddr);
-                    }   
+                    }
                 }
                 if (!ipsToSend.isEmpty()) {
                     createVpcAssociatePublicIPCommands(router, ipsToSend, cmds, vlanMacAddress);
@@ -607,7 +607,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     
     
     @Override
-    public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest, 
+    public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest,
             ReservationContext context) {
         
         if (profile.getVirtualMachine().getVpcId() != null) {
@@ -751,7 +751,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             for (Pair<Nic, Network> nicNtwk : publicNics) {
                 Nic publicNic = nicNtwk.first();
                 Network publicNtwk = nicNtwk.second();
-                IPAddressVO userIp = _ipAddressDao.findByIpAndSourceNetworkId(publicNtwk.getId(), 
+                IPAddressVO userIp = _ipAddressDao.findByIpAndSourceNetworkId(publicNtwk.getId(),
                         publicNic.getIp4Address());
                
                 if (userIp.isSourceNat()) {
@@ -767,11 +767,11 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                     }
                 }
                 PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, publicNic.getNetworkId(), publicNic.getBroadcastUri().toString()), router.getInstanceName(), router.getType());
-                cmds.addCommand(plugNicCmd); 
+                cmds.addCommand(plugNicCmd);
                 VpcVO vpc = _vpcDao.findById(router.getVpcId());
                 NetworkUsageCommand netUsageCmd = new NetworkUsageCommand(router.getPrivateIpAddress(), router.getInstanceName(), true, publicNic.getIp4Address(), vpc.getCidr());
                 usageCmds.add(netUsageCmd);
-                UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(), 
+                UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(),
                 publicNtwk.getId(), publicNic.getIp4Address(), router.getId(), router.getType().toString());
                 if (stats == null) {
                     stats = new UserStatisticsVO(router.getAccountId(), router.getDataCenterId(), publicNic.getIp4Address(), router.getId(),
@@ -788,7 +788,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             //add VPC router to guest networks
             for (Pair<Nic, Network> nicNtwk : guestNics) {
                 Nic guestNic = nicNtwk.first();
-                //plug guest nic 
+                //plug guest nic
                 PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, guestNic.getNetworkId(), null), router.getInstanceName(), router.getType());
                 cmds.addCommand(plugNicCmd);
                 
@@ -838,18 +838,18 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                 gateway = _vpcMgr.getVpcGateway(route.getVpcGatewayId());
                 gatewayMap.put(gateway.getId(), gateway);
             }
-            staticRouteProfiles.add(new StaticRouteProfile(route, gateway)); 
+            staticRouteProfiles.add(new StaticRouteProfile(route, gateway));
         }
         
-        s_logger.debug("Found " + staticRouteProfiles.size() + " static routes to apply as a part of vpc route " 
+        s_logger.debug("Found " + staticRouteProfiles.size() + " static routes to apply as a part of vpc route "
                 + router + " start");
-        if (!staticRouteProfiles.isEmpty()) {   
+        if (!staticRouteProfiles.isEmpty()) {
             createStaticRouteCommands(staticRouteProfiles, router, cmds);
         }
         
         //5) REPROGRAM GUEST NETWORK
         boolean reprogramGuestNtwks = true;
-        if (profile.getParameter(Param.ReProgramGuestNetworks) != null 
+        if (profile.getParameter(Param.ReProgramGuestNetworks) != null
                 && (Boolean) profile.getParameter(Param.ReProgramGuestNetworks) == false) {
             reprogramGuestNtwks = false;
         }
@@ -973,7 +973,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
      * @return
      * @throws ResourceUnavailableException
      */
-    protected boolean setupVpcPrivateNetwork(VirtualRouter router, boolean add, NicProfile privateNic) 
+    protected boolean setupVpcPrivateNetwork(VirtualRouter router, boolean add, NicProfile privateNic)
             throws ResourceUnavailableException {
         if(s_logger.isTraceEnabled()) {
             s_logger.trace("deployVpcRouter(" + router.getHostName() + ", " + add + ", " + privateNic.getMacAddress() + ")");
@@ -999,7 +999,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                 return false;
             }
         } else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
-            s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + 
+            s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
                     ", so not sending setup private network command to the backend");
         } else {
             s_logger.warn("Unable to setup private gateway, virtual router " + router + " is not in the right state " + router.getState());
@@ -1011,7 +1011,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     }
 
     @Override
-    public boolean destroyPrivateGateway(PrivateGateway gateway, VirtualRouter router) 
+    public boolean destroyPrivateGateway(PrivateGateway gateway, VirtualRouter router)
             throws ConcurrentOperationException, ResourceUnavailableException {
         
         if (!_networkModel.isVmPartOfNetwork(router.getId(), gateway.getNetworkId())) {
@@ -1041,7 +1041,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     }
     
     @Override
-    protected void finalizeIpAssocForNetwork(Commands cmds, VirtualRouter router, Provider provider, 
+    protected void finalizeIpAssocForNetwork(Commands cmds, VirtualRouter router, Provider provider,
             Long guestNetworkId, Map<String, String> vlanMacAddress) {
         
         if (router.getVpcId() == null) {
@@ -1068,9 +1068,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         boolean result = true;
         for (VirtualRouter router : routers) {
             if (router.getState() == State.Running) {
-                result = result && sendStaticRoutes(staticRoutes, routers.get(0));     
+                result = result && sendStaticRoutes(staticRoutes, routers.get(0));
             } else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
-                s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + 
+                s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
                         ", so not sending StaticRoute command to the backend");
             } else {
                 s_logger.warn("Unable to apply StaticRoute, virtual router is not in the right state " + router.getState());
@@ -1082,7 +1082,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         return result;
     }
     
-    protected boolean sendStaticRoutes(List<StaticRouteProfile> staticRoutes, DomainRouterVO router) 
+    protected boolean sendStaticRoutes(List<StaticRouteProfile> staticRoutes, DomainRouterVO router)
             throws ResourceUnavailableException {
         Commands cmds = new Commands(OnError.Continue);
         createStaticRouteCommands(staticRoutes, router, cmds);
@@ -1202,7 +1202,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     }
     
     
-    protected List<Pair<NetworkVO, NicProfile>> createVpcRouterNetworks(Account owner, boolean isRedundant, 
+    protected List<Pair<NetworkVO, NicProfile>> createVpcRouterNetworks(Account owner, boolean isRedundant,
             DeploymentPlan plan, Pair<Boolean, PublicIp> sourceNatIp, long vpcId) throws ConcurrentOperationException,
             InsufficientAddressCapacityException {
 
@@ -1237,7 +1237,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         List<IPAddressVO> ips = _ipAddressDao.listByAssociatedVpc(vpcId, false);
         for (IPAddressVO ip : ips) {
             PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId()));
-            if ((ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating) 
+            if ((ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating)
                     && _vpcMgr.isIpAllocatedToVpc(ip)&& !publicVlans.contains(publicIp.getVlanTag())) {
                 s_logger.debug("Allocating nic for router in vlan " + publicIp.getVlanTag());
                 NicProfile publicNic = new NicProfile();
@@ -1269,9 +1269,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         
         if (privateNic != null) {
             VirtualMachine vm = _vmDao.findById(privateNic.getId());
-            privateNicProfile = new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(), 
-                    _networkModel.getNetworkRate(privateNetwork.getId(), vm.getId()), 
-                    _networkModel.isSecurityGroupSupportedInNetwork(privateNetwork), 
+            privateNicProfile = new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(),
+                    _networkModel.getNetworkRate(privateNetwork.getId(), vm.getId()),
+                    _networkModel.isSecurityGroupSupportedInNetwork(privateNetwork),
                     _networkModel.getNetworkTag(vm.getHypervisorType(), privateNetwork));
         } else {
             String vlanTag = privateNetwork.getBroadcastUri().getHost();
@@ -1306,7 +1306,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         return guestNic;
     }
     
-    protected Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> getNicsToChangeOnRouter 
+    protected Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> getNicsToChangeOnRouter
     (final List<? extends PublicIpAddress> publicIps, VirtualRouter router) {
         //1) check which nics need to be plugged/unplugged and plug/unplug them
         
@@ -1327,7 +1327,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                 Nic nic = _nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId, router.getId(), ip.getAddress().addr());
                 if (nic != null) {
                     nicsToUnplug.put(ip.getVlanTag(), ip);
-                    s_logger.debug("Need to unplug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() + 
+                    s_logger.debug("Need to unplug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() +
                             " in public network id =" + publicNtwkId);
                 }
             }
@@ -1345,12 +1345,12 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                          
             if (ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating) {
                 //nic has to be plugged only when there are no nics for this vlan tag exist on VR
-                Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(publicNtwkId, router.getId(), 
+                Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(publicNtwkId, router.getId(),
                         broadcastUri.toString());
                 
                 if (nic == null && nicsToPlug.get(ip.getVlanTag()) == null) {
                     nicsToPlug.put(ip.getVlanTag(), ip);
-                    s_logger.debug("Need to plug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() + 
+                    s_logger.debug("Need to plug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() +
                             " in public network id =" + publicNtwkId);
                 } else {
                     PublicIpAddress nicToUnplug = nicsToUnplug.get(ip.getVlanTag());
@@ -1360,12 +1360,12 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                         _nicDao.update(nicVO.getId(), nicVO);
                         s_logger.debug("Updated the nic " + nicVO + " with the new ip address " + ip.getAddress().addr());
                         nicsToUnplug.remove(ip.getVlanTag());
-                    } 
+                    }
                 }
             }
         }
         
-        Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> nicsToChange = 
+        Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> nicsToChange =
                 new Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>>(nicsToPlug, nicsToUnplug);
         return nicsToChange;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/541f9d7f/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
index 9408d48..5931aa1 100755
--- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
+++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
@@ -419,7 +419,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
 
         SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
         sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.SecondaryStorageVM);
-        sc.addAnd(sc.getEntity().getStatus(), Op.IN, com.cloud.host.Status.Up, com.cloud.host.Status.Connecting);
+        sc.addAnd(sc.getEntity().getState(), Op.IN, com.cloud.host.Status.Up, com.cloud.host.Status.Connecting);
         List<HostVO> ssvms = sc.list();
         for (HostVO ssvm : ssvms) {
         	if (ssvm.getId() == ssAHostId) {
@@ -575,8 +575,10 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
 
         SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId,
                 systemAcct.getDomainId(), systemAcct.getId(), role, _serviceOffering.getOfferHA());
+        secStorageVm = _secStorageVmDao.persist(secStorageVm);
         try {
-            secStorageVm = _itMgr.allocate(secStorageVm, template, _serviceOffering, networks, plan, null, systemAcct);
+            _itMgr.allocate(name, template, _serviceOffering, networks, plan, null);
+            secStorageVm = _secStorageVmDao.findById(secStorageVm.getId());
         } catch (InsufficientCapacityException e) {
             s_logger.warn("InsufficientCapacity", e);
             throw new CloudRuntimeException("Insufficient capacity exception", e);
@@ -890,14 +892,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
     }
 
     @Override
-    public Long convertToId(String vmName) {
-        if (!VirtualMachineName.isValidSystemVmName(vmName, _instance, "s")) {
-            return null;
-        }
-        return VirtualMachineName.getSystemVmId(vmName);
-    }
-
-    @Override
     public boolean stopSecStorageVm(long secStorageVmId) {
         SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
         if (secStorageVm == null) {
@@ -1011,24 +1005,11 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
     }
 
     @Override
-    public SecondaryStorageVmVO findByName(String name) {
-        if (!VirtualMachineName.isValidSecStorageVmName(name, null)) {
-            return null;
-        }
-        return findById(VirtualMachineName.getSystemVmId(name));
-    }
-
-    @Override
     public SecondaryStorageVmVO findById(long id) {
         return _secStorageVmDao.findById(id);
     }
 
     @Override
-    public SecondaryStorageVmVO persist(SecondaryStorageVmVO vm) {
-        return _secStorageVmDao.persist(vm);
-    }
-
-    @Override
     public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<SecondaryStorageVmVO> profile, DeployDestination dest, ReservationContext context) {
 
     	SecondaryStorageVmVO vm = profile.getVirtualMachine();
@@ -1377,7 +1358,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
         if (dcId != null) {
             sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
         }
-		sc.addAnd(sc.getEntity().getStatus(), Op.IN, com.cloud.host.Status.Up, com.cloud.host.Status.Connecting);
+        sc.addAnd(sc.getEntity().getState(), Op.IN, com.cloud.host.Status.Up, com.cloud.host.Status.Connecting);
 		sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.SecondaryStorageVM);
 	    return sc.list();
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/541f9d7f/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index ddba735..d766f7a 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -26,6 +26,9 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
 import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
 import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
@@ -46,9 +49,6 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
@@ -59,7 +59,6 @@ import com.cloud.configuration.Config;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.ClusterVO;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.domain.dao.DomainDao;
@@ -80,9 +79,9 @@ import com.cloud.projects.Project.ListProjectResourcesCriteria;
 import com.cloud.resource.ResourceManager;
 import com.cloud.server.ResourceTag.TaggedResourceType;
 import com.cloud.storage.CreateSnapshotPayload;
+import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.Snapshot;
 import com.cloud.storage.Snapshot.Type;
-import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.SnapshotPolicyVO;
 import com.cloud.storage.SnapshotScheduleVO;
 import com.cloud.storage.SnapshotVO;
@@ -269,7 +268,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "creating snapshot", async = true)
     public Snapshot createSnapshot(Long volumeId, Long policyId, Long snapshotId, Account snapshotOwner) {
-        VolumeInfo volume = this.volFactory.getVolume(volumeId);
+        VolumeInfo volume = volFactory.getVolume(volumeId);
         if (volume == null) {
         	throw new InvalidParameterValueException("No such volume exist");
         }
@@ -283,7 +282,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
         // does the caller have the authority to act on this volume
         _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
 
-        SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Primary);
+        SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Primary);
 
         try {
         	postCreateSnapshot(volumeId, snapshot.getId(), policyId);
@@ -316,12 +315,12 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
 
     @Override
     public Snapshot backupSnapshot(Long snapshotId) {
-    	 SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Image);
+    	 SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Image);
     	 if (snapshot != null) {
     		 throw new CloudRuntimeException("Already in the backup snapshot:" + snapshotId);
     	 }
 
-         return this.snapshotSrv.backupSnapshot(snapshot);
+         return snapshotSrv.backupSnapshot(snapshot);
     }
 
     /*
@@ -480,14 +479,14 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
         Account caller = CallContext.current().getCallingAccount();
 
         // Verify parameters
-        SnapshotVO snapshotCheck = this._snapshotDao.findById(snapshotId);
+        SnapshotVO snapshotCheck = _snapshotDao.findById(snapshotId);
         if (snapshotCheck == null) {
             throw new InvalidParameterValueException("unable to find a snapshot with id " + snapshotId);
         }
 
         _accountMgr.checkAccess(caller, null, true, snapshotCheck);
         SnapshotStrategy snapshotStrategy = null;
-        for (SnapshotStrategy strategy : this.snapshotStrategies) {
+        for (SnapshotStrategy strategy : snapshotStrategies) {
         	if (strategy.canHandle(snapshotCheck)) {
         		snapshotStrategy = strategy;
         		break;
@@ -496,7 +495,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
         try {
         	boolean result = snapshotStrategy.deleteSnapshot(snapshotId);
         	if (result) {
-        		if (snapshotCheck.getState() == Snapshot.State.BackedUp) {
+                if (snapshotCheck.getState() == Snapshot.State.BackedUp) {
         			UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_DELETE, snapshotCheck.getAccountId(),
         					snapshotCheck.getDataCenterId(), snapshotId, snapshotCheck.getName(), null, null, 0L,
         					snapshotCheck.getClass().getName(), snapshotCheck.getUuid());
@@ -515,9 +514,9 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
 
     @Override
     public String getSecondaryStorageURL(SnapshotVO snapshot) {
-        SnapshotDataStoreVO snapshotStore = this._snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Image);
+        SnapshotDataStoreVO snapshotStore = _snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Image);
         if (snapshotStore != null){
-            DataStore store = this.dataStoreMgr.getDataStore(snapshotStore.getDataStoreId(), DataStoreRole.Image);
+            DataStore store = dataStoreMgr.getDataStore(snapshotStore.getDataStoreId(), DataStoreRole.Image);
             if ( store != null ){
                 return store.getUri();
             }
@@ -614,7 +613,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
         }
 
         if (snapshotTypeStr != null) {
-            Type snapshotType = SnapshotVO.getSnapshotType((String) snapshotTypeStr);
+            Type snapshotType = SnapshotVO.getSnapshotType(snapshotTypeStr);
             if (snapshotType == null) {
                 throw new InvalidParameterValueException("Unsupported snapshot type " + snapshotTypeStr);
             }
@@ -624,7 +623,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
                 sc.setParameters("snapshotTypeEQ", snapshotType.ordinal());
             }
         } else if (intervalTypeStr != null && volumeId != null) {
-            Type type = SnapshotVO.getSnapshotType((String) intervalTypeStr);
+            Type type = SnapshotVO.getSnapshotType(intervalTypeStr);
             if (type == null) {
                 throw new InvalidParameterValueException("Unsupported snapstho interval type " + intervalTypeStr);
             }
@@ -657,7 +656,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
                 // This volume doesn't have any snapshots. Nothing do delete.
                 continue;
             }
-            List<DataStore> ssHosts = this.dataStoreMgr.getImageStoresByScope(new ZoneScope(dcId));
+            List<DataStore> ssHosts = dataStoreMgr.getImageStoresByScope(new ZoneScope(dcId));
             for (DataStore ssHost : ssHosts) {
                 String snapshotDir = TemplateConstants.DEFAULT_SNAPSHOT_ROOT_DIR + "/" + accountId + "/" + volumeId;
                 DeleteSnapshotsDirCommand cmd = new DeleteSnapshotsDirCommand(ssHost.getTO(), snapshotDir);
@@ -977,7 +976,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
         CreateSnapshotPayload payload = (CreateSnapshotPayload)volume.getpayload();
         Long snapshotId = payload.getSnapshotId();
         Account snapshotOwner = payload.getAccount();
-        SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotId, volume.getDataStore());
+        SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, volume.getDataStore());
         boolean processed = false;
 
         try {
@@ -1019,7 +1018,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
 
         String value = _configDao.getValue(Config.BackupSnapshotWait.toString());
         _backupsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue()));
-        backup = Boolean.parseBoolean(this._configDao.getValue(Config.BackupSnapshotAferTakingSnapshot.toString()));
+        backup = Boolean.parseBoolean(_configDao.getValue(Config.BackupSnapshotAferTakingSnapshot.toString()));
 
         Type.HOURLY.setMax(NumbersUtil.parseInt(_configDao.getValue("snapshot.max.hourly"), HOURLYMAX));
         Type.DAILY.setMax(NumbersUtil.parseInt(_configDao.getValue("snapshot.max.daily"), DAILYMAX));
@@ -1104,7 +1103,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
     @Override
     public Snapshot allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException {
         Account caller = CallContext.current().getCallingAccount();
-        VolumeInfo volume = this.volFactory.getVolume(volumeId);
+        VolumeInfo volume = volFactory.getVolume(volumeId);
         supportedByHypervisor(volume);
 
         // Verify permissions

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/541f9d7f/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 674f29c..adcf475 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1135,7 +1135,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
             throw new InvalidParameterValueException("This operation not permitted for this hypervisor of the vm");
         }
 
-        if(vmInstance.getState().equals(State.Stopped)){
+        if (vmInstance.getState().equals(State.Stopped)) {
             upgradeStoppedVirtualMachine(vmId, newServiceOfferingId);
             return true;
         }
@@ -1173,7 +1173,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
 
         // Dynamically upgrade the running vms
         boolean success = false;
-        if(vmInstance.getState().equals(State.Running)){
+        if (vmInstance.getState().equals(State.Running)) {
             int retry = _scaleRetry;
             ExcludeList excludes = new ExcludeList();
             boolean enableDynamicallyScaleVm = Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), vmInstance.getDataCenterId()));
@@ -1492,14 +1492,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
     }
 
     @Override
-    public Long convertToId(String vmName) {
-        if (!VirtualMachineName.isValidVmName(vmName, _instance)) {
-            return null;
-        }
-        return VirtualMachineName.getVmId(vmName);
-    }
-
-    @Override
     public boolean expunge(UserVmVO vm, long callerUserId, Account caller) {
         try {
             // expunge the vm
@@ -3097,24 +3089,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
     }
 
     @Override
-    public UserVmVO persist(UserVmVO vm) {
-        return _vmDao.persist(vm);
-    }
-
-    @Override
     public UserVmVO findById(long id) {
         return _vmDao.findById(id);
     }
 
     @Override
-    public UserVmVO findByName(String name) {
-        if (!VirtualMachineName.isValidVmName(name)) {
-            return null;
-        }
-        return findById(VirtualMachineName.getVmId(name));
-    }
-
-    @Override
     @ActionEvent(eventType = EventTypes.EVENT_VM_STOP, eventDescription = "stopping Vm", async = true)
     public UserVm stopVirtualMachine(long vmId, boolean forced)
             throws ConcurrentOperationException {
@@ -3854,11 +3833,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
         }
 
         // check if host is UP
-        if (destinationHost.getStatus() != com.cloud.host.Status.Up
+        if (destinationHost.getState() != com.cloud.host.Status.Up
                 || destinationHost.getResourceState() != ResourceState.Enabled) {
             throw new InvalidParameterValueException(
                     "Cannot migrate VM, destination host is not in correct state, has status: "
-                            + destinationHost.getStatus() + ", state: "
+                            + destinationHost.getState() + ", state: "
                             + destinationHost.getResourceState());
         }
 
@@ -3982,10 +3961,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
         }
 
         // Check if destination host is up.
-        if (destinationHost.getStatus() != com.cloud.host.Status.Up ||
+        if (destinationHost.getState() != com.cloud.host.Status.Up ||
                 destinationHost.getResourceState() != ResourceState.Enabled){
             throw new CloudRuntimeException("Cannot migrate VM, destination host is not in correct state, has " +
-                    "status: " + destinationHost.getStatus() + ", state: " + destinationHost.getResourceState());
+                    "status: " + destinationHost.getState() + ", state: " + destinationHost.getResourceState());
         }
 
         List<VolumeVO> vmVolumes = _volsDao.findUsableVolumesForInstance(vm.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/541f9d7f/server/src/com/cloud/vm/VirtualMachineGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineGuru.java b/server/src/com/cloud/vm/VirtualMachineGuru.java
index 3141507..df34e0e 100644
--- a/server/src/com/cloud/vm/VirtualMachineGuru.java
+++ b/server/src/com/cloud/vm/VirtualMachineGuru.java
@@ -26,17 +26,8 @@ import com.cloud.exception.ResourceUnavailableException;
  *
  */
 public interface VirtualMachineGuru<T extends VirtualMachine> {
-    /**
-     * Find the virtual machine by name.
-     * @param name
-     * @return virtual machine.
-     */
-    T findByName(String name);
-    
     T findById(long id);
     
-    T persist(T vm);
-    
     boolean finalizeVirtualMachineProfile(VirtualMachineProfile<T> profile, DeployDestination dest, ReservationContext context);
     
     /**
@@ -64,16 +55,6 @@ public interface VirtualMachineGuru<T extends VirtualMachine> {
     void finalizeExpunge(T vm);
     
     /**
-     * Returns the id parsed from the name.  If it cannot parse the name,
-     * then return null.  This method is used to determine if this is
-     * the right handler for this vm.
-     * 
-     * @param vmName vm name coming form the agent.
-     * @return id if the handler works for this vm and can parse id.  null if not.
-     */
-    Long convertToId(String vmName);
-    
-    /**
      * Prepare Vm for Stop
      * @param profile
      * @return


Mime
View raw message