VPC: CS-15725 - don't allow regular offering upgrade to the offering that can be used inside vpc only

This commit is contained in:
Alena Prokharchyk 2012-07-27 11:28:42 -07:00
parent 78a00c03e1
commit c0b58130d3
2 changed files with 15 additions and 4 deletions

View File

@ -3400,9 +3400,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
sc.addAnd("systemOnly", SearchCriteria.Op.EQ, false);
// if networkId is specified, list offerings available for upgrade only (for this network)
Network network = null;
if (networkId != null) {
// check if network exists and the caller can operate with it
Network network = _networkMgr.getNetwork(networkId);
network = _networkMgr.getNetwork(networkId);
if (network == null) {
throw new InvalidParameterValueException("Unable to find the network by id", null);
}
@ -3462,7 +3463,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
boolean listBySupportedServices = (supportedServicesStr != null && !supportedServicesStr.isEmpty() && !offerings.isEmpty());
boolean checkIfProvidersAreEnabled = (zoneId != null);
boolean parseOfferings = (listBySupportedServices || sourceNatSupported != null || checkIfProvidersAreEnabled
|| forVpc != null);
|| forVpc != null || network != null);
if (parseOfferings) {
List<NetworkOfferingVO> supportedOfferings = new ArrayList<NetworkOfferingVO>();
@ -3511,7 +3512,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
if (forVpc != null) {
addOffering = addOffering && (isOfferingForVpc(offering) == forVpc.booleanValue());
addOffering = addOffering && (isOfferingForVpc(offering) == forVpc.booleanValue());
} else if (network != null){
addOffering = addOffering && (isOfferingForVpc(offering) == (network.getVpcId() != null));
}
if (addOffering) {

View File

@ -4668,6 +4668,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
idList.add(new IdentityProxy(networkOffering, networkOfferingId, "networkOfferingId"));
throw new InvalidParameterValueException("Network offering with specified id is not in " + NetworkOffering.State.Enabled + " state, can't upgrade to it", idList);
}
//can't update from vpc to non-vpc network offering
boolean forVpcNew = _configMgr.isOfferingForVpc(networkOffering);
boolean vorVpcOriginal = _configMgr.isOfferingForVpc(_configMgr.getNetworkOffering(oldNetworkOfferingId));
if (forVpcNew != vorVpcOriginal) {
String errMsg = forVpcNew ? "a vpc offering " : "not a vpc offering";
throw new InvalidParameterValueException("Can't update as the new offering is " + errMsg);
}
//perform below validation if the network is vpc network
if (network.getVpcId() != null) {
@ -4730,7 +4738,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount);
// 1) Shutdown all the elements and cleanup all the rules. Don't allow to shutdown network in intermediate
// states - Shutdown and Implementing
// states - Shutdown and Implementing
boolean validStateToShutdown = (network.getState() == Network.State.Implemented || network.getState() == Network.State.Setup || network.getState() == Network.State.Allocated);
if (restartNetwork) {
if (validStateToShutdown) {