You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/08/22 20:56:55 UTC

git commit: VPC: CS-16100 - 1) when start VPC router, never pick up any other hypervisor besides vmWare and Xen 2) When start user vm in vpc network, throw an error when deploy from the tempalate of not supported hypervisor Reviewed-by: Frank Zhang

Updated Branches:
  refs/heads/master 4a2796d7c -> 3ada5e4a4


VPC: CS-16100 - 1) when start VPC router, never pick up any other hypervisor besides vmWare and Xen 2) When start user vm in vpc network, throw an error when deploy from the tempalate of not supported hypervisor
Reviewed-by: Frank Zhang

Conflicts:

	server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
	server/src/com/cloud/vm/UserVmManagerImpl.java


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

Branch: refs/heads/master
Commit: 3ada5e4a46346c8fbc9bfa870c749f5a32ef3db6
Parents: 4a2796d
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Wed Aug 22 11:10:39 2012 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Wed Aug 22 11:53:59 2012 -0700

----------------------------------------------------------------------
 .../router/VirtualNetworkApplianceManagerImpl.java |   39 +++++++++-----
 .../VpcVirtualNetworkApplianceManagerImpl.java     |    3 +-
 server/src/com/cloud/network/vpc/VpcManager.java   |    7 +++
 .../src/com/cloud/network/vpc/VpcManagerImpl.java  |   11 ++++-
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   17 ++++++-
 5 files changed, 60 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ada5e4a/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 5528f79..0d812a2 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -1351,7 +1351,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
                         new Pair<Boolean, PublicIp>(publicNetwork, sourceNatIp));
                 //don't start the router as we are holding the network lock that needs to be released at the end of router allocation
                 DomainRouterVO router = deployRouter(owner, dest, plan, params, isRedundant, vrProvider, offeringId,
-                        null, networks, false);
+                        null, networks, false, null);
 
                 _routerDao.addRouterToGuestNetwork(router, guestNetwork);
                 routers.add(router);
@@ -1369,7 +1369,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
 
     protected DomainRouterVO deployRouter(Account owner, DeployDestination dest, DeploymentPlan plan, Map<Param, Object> params,
             boolean isRedundant, VirtualRouterProvider vrProvider, long svcOffId,
-            Long vpcId, List<Pair<NetworkVO, NicProfile>> networks, boolean startRouter) throws ConcurrentOperationException,
+            Long vpcId, List<Pair<NetworkVO, NicProfile>> networks, boolean startRouter, List<HypervisorType> supportedHypervisors) throws ConcurrentOperationException,
             InsufficientAddressCapacityException, InsufficientServerCapacityException, InsufficientCapacityException,
             StorageUnavailableException, ResourceUnavailableException {
         
@@ -1382,12 +1382,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
 
         // Router is the network element, we don't know the hypervisor type yet.
         // Try to allocate the domR twice using diff hypervisors, and when failed both times, throw the exception up
-        List<HypervisorType> supportedHypervisors = getSupportedHypervisors(dest, plan);
+        List<HypervisorType> hypervisors = getHypervisors(dest, plan, supportedHypervisors);
 
         int allocateRetry = 0;
         int startRetry = 0;
         DomainRouterVO router = null;
-        for (Iterator<HypervisorType> iter = supportedHypervisors.iterator();iter.hasNext();) {
+        for (Iterator<HypervisorType> iter = hypervisors.iterator(); iter.hasNext();) {
             HypervisorType hType = iter.next();
             try {
                 s_logger.debug("Allocating the domR with the hypervisor type " + hType);
@@ -1446,33 +1446,44 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
     }
 
 
-    protected List<HypervisorType> getSupportedHypervisors(DeployDestination dest, DeploymentPlan plan) throws InsufficientServerCapacityException {
-        List<HypervisorType> supportedHypervisors = new ArrayList<HypervisorType>();
+    protected List<HypervisorType> getHypervisors(DeployDestination dest, DeploymentPlan plan, 
+            List<HypervisorType> supportedHypervisors) throws InsufficientServerCapacityException {
+        List<HypervisorType> hypervisors = new ArrayList<HypervisorType>();
         HypervisorType defaults = _resourceMgr.getDefaultHypervisor(dest.getDataCenter().getId());
         if (defaults != HypervisorType.None) {
-            supportedHypervisors.add(defaults);
+            hypervisors.add(defaults);
         }
 
         if (dest.getCluster() != null) {
             if (dest.getCluster().getHypervisorType() == HypervisorType.Ovm) {
-                supportedHypervisors.add(getClusterToStartDomainRouterForOvm(dest.getCluster().getPodId()));
+                hypervisors.add(getClusterToStartDomainRouterForOvm(dest.getCluster().getPodId()));
             } else {
-                supportedHypervisors.add(dest.getCluster().getHypervisorType());
+                hypervisors.add(dest.getCluster().getHypervisorType());
             }
         } else {
-            supportedHypervisors = _resourceMgr.getSupportedHypervisorTypes(dest.getDataCenter().getId(), true,
+            hypervisors = _resourceMgr.getSupportedHypervisorTypes(dest.getDataCenter().getId(), true,
                     plan.getPodId());
         }
 
-        if (supportedHypervisors.isEmpty()) {
+        //keep only elements defined in supported hypervisors
+        StringBuilder hTypesStr = new StringBuilder();
+        if (supportedHypervisors != null && !supportedHypervisors.isEmpty()) {
+            hypervisors.retainAll(supportedHypervisors);
+            for (HypervisorType hType : supportedHypervisors) {
+                hTypesStr.append(hType).append(" ");
+            }
+        }
+
+        if (hypervisors.isEmpty()) {
+            String errMsg = (hTypesStr.capacity() > 0) ? "supporting hypervisors " + hTypesStr.toString() : "";
             if (plan.getPodId() != null) {
                 throw new InsufficientServerCapacityException("Unable to create virtual router, " +
-                        "there are no clusters in the pod ", Pod.class, plan.getPodId());
+                        "there are no clusters in the pod " + errMsg, Pod.class, plan.getPodId());
             }
             throw new InsufficientServerCapacityException("Unable to create virtual router, " +
-                    "there are no clusters in the zone ", DataCenter.class, dest.getDataCenter().getId());
+                    "there are no clusters in the zone " + errMsg, DataCenter.class, dest.getDataCenter().getId());
         }
-        return supportedHypervisors;
+        return hypervisors;
     }
 
     protected List<Pair<NetworkVO, NicProfile>> createRouterNetworks(Account owner, boolean isRedundant,

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ada5e4a/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 98613b8..2d4d0bf 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -318,7 +318,8 @@ 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);
+                super.deployRouter(owner, dest, plan, params, isRedundant, vrProvider, svcOffId, vpcId, networks, true, 
+                        _vpcMgr.getSupportedVpcHypervisors());
         
         return router;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ada5e4a/server/src/com/cloud/network/vpc/VpcManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManager.java b/server/src/com/cloud/network/vpc/VpcManager.java
index 553891c..14fdbe9 100644
--- a/server/src/com/cloud/network/vpc/VpcManager.java
+++ b/server/src/com/cloud/network/vpc/VpcManager.java
@@ -24,6 +24,7 @@ import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
 import com.cloud.network.Network.Service;
@@ -136,4 +137,10 @@ public interface VpcManager extends VpcService{
      */
     void validateNtwkOffForVpc(NetworkOffering guestNtwkOff, List<Service> supportedSvcs);
 
+
+    /**
+     * @return
+     */
+    List<HypervisorType> getSupportedVpcHypervisors();
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ada5e4a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index e06c843..f4c47ed 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -54,6 +54,7 @@ import com.cloud.exception.PermissionDeniedException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.exception.UnsupportedServiceException;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.IPAddressVO;
 import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
@@ -1954,5 +1955,13 @@ public class VpcManagerImpl implements VpcManager, Manager{
         
         return _ntwkMgr.updateGuestNetwork(networkId, name, displayText, callerAccount, callerUser, domainSuffix,
                 ntwkOffId, changeCidr);
-    } 
+    }
+
+    @Override
+    public List<HypervisorType> getSupportedVpcHypervisors() {
+        List<HypervisorType> hTypes = new ArrayList<HypervisorType>();
+        hTypes.add(HypervisorType.XenServer);
+        hTypes.add(HypervisorType.VMware);
+        return hTypes;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ada5e4a/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 051791f..f1f32c3 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -33,6 +33,7 @@ import javax.naming.ConfigurationException;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
+import org.apache.tools.ant.taskdefs.Length.When;
 
 import com.cloud.acl.ControlledEntity.ACLType;
 import com.cloud.agent.AgentManager;
@@ -128,6 +129,7 @@ import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.LoadBalancerVMMapDao;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkServiceMapDao;
+import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.element.UserDataServiceProvider;
 import com.cloud.network.lb.LoadBalancingRulesManager;
 import com.cloud.network.rules.FirewallManager;
@@ -139,6 +141,7 @@ import com.cloud.network.security.SecurityGroup;
 import com.cloud.network.security.SecurityGroupManager;
 import com.cloud.network.security.dao.SecurityGroupDao;
 import com.cloud.network.security.dao.SecurityGroupVMMapDao;
+import com.cloud.network.vpc.VpcManager;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.NetworkOffering.Availability;
 import com.cloud.offering.ServiceOffering;
@@ -352,7 +355,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
     protected VolumeHostDao _volumeHostDao;
     @Inject
     ResourceTagDao _resourceTagDao;
-
+    @Inject
+    PhysicalNetworkDao _physicalNetworkDao;
+    @Inject
+    VpcManager _vpcMgr;
 
     protected ScheduledExecutorService _executor = null;
     protected int _expungeInterval;
@@ -2185,6 +2191,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         // Verify that caller can perform actions in behalf of vm owner
         _accountMgr.checkAccess(caller, null, true, owner);
 
+        List<HypervisorType> vpcSupportedHTypes = _vpcMgr.getSupportedVpcHypervisors();
         if (networkIdList == null || networkIdList.isEmpty()) {
             NetworkVO defaultNetwork = null;
 
@@ -2227,7 +2234,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                 if (network == null) {
                     throw new InvalidParameterValueException("Unable to find network by id " + networkIdList.get(0).longValue());
                 }
+                if (network.getVpcId() != null) {
+                    //Only XenServer and VmWare hypervisors are supported for vpc networks
+                    if (!vpcSupportedHTypes.contains(template.getHypervisorType())) {
+                        throw new InvalidParameterValueException("Can't create vm from template with hypervisor "
+                                + template.getHypervisorType() + " in vpc network " + network);
+                    }
 
+                }
+                
                 _networkMgr.checkNetworkPermissions(owner, network);
 
                 //don't allow to use system networks