VPC: don't allow vm to be a part of more than one VPC

This commit is contained in:
Alena Prokharchyk 2012-07-05 15:28:30 -07:00
parent 24023fd14d
commit 21cdd08948
1 changed files with 9 additions and 0 deletions

View File

@ -2341,6 +2341,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>();
short defaultNetworkNumber = 0;
boolean securityGroupEnabled = false;
boolean vpcNetwork = false;
for (NetworkVO network : networkList) {
if (network.getDataCenterId() != zone.getId()) {
throw new InvalidParameterValueException("Network id=" + network.getId() + " doesn't belong to zone " + zone.getId());
@ -2368,6 +2369,14 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
if (_networkMgr.isSecurityGroupSupportedInNetwork(network)) {
securityGroupEnabled = true;
}
//vm can't be a part of more than 1 VPC network
if (network.getVpcId() != null) {
if (vpcNetwork) {
throw new InvalidParameterValueException("Vm can't be a part of more than 1 VPC network");
}
vpcNetwork = true;
}
}
if (securityGroupIdList != null && !securityGroupIdList.isEmpty() && !securityGroupEnabled) {