mirror of https://github.com/apache/cloudstack.git
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
This commit is contained in:
parent
bc8bdf8723
commit
1fa67ff317
|
|
@ -1428,7 +1428,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);
|
||||
|
||||
|
|
@ -1447,7 +1447,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 {
|
||||
|
||||
|
|
@ -1460,12 +1460,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);
|
||||
|
|
@ -1525,33 +1525,44 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
return router;
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,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;
|
||||
|
|
@ -135,4 +136,10 @@ public interface VpcManager extends VpcService{
|
|||
*/
|
||||
void validateNtwkOffForVpc(NetworkOffering guestNtwkOff, List<Service> supportedSvcs);
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
List<HypervisorType> getSupportedVpcHypervisors();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,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;
|
||||
|
|
@ -1959,5 +1960,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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,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.offering.DiskOffering;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
|
|
@ -349,6 +349,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
ResourceTagDao _resourceTagDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
|
||||
protected ScheduledExecutorService _executor = null;
|
||||
protected int _expungeInterval;
|
||||
|
|
@ -2206,6 +2208,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;
|
||||
|
||||
|
|
@ -2256,7 +2259,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Unable to find network by id", null);
|
||||
}
|
||||
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, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_networkMgr.checkNetworkPermissions(owner, network);
|
||||
|
||||
//don't allow to use system networks
|
||||
|
|
|
|||
Loading…
Reference in New Issue