Don't allow to upgrade networkOfferingId and networkDomain for Shared network offerings

This commit is contained in:
Alena Prokharchyk 2011-11-08 12:32:35 -08:00
parent 8836a08e60
commit eac54e3ad4
2 changed files with 12 additions and 1 deletions

View File

@ -34,7 +34,6 @@ import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.NetworkOfferingResponse;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.Availability;
import com.cloud.user.Account;
@Implementation(description="Updates a network offering.", responseObject=NetworkOfferingResponse.class)

View File

@ -3282,6 +3282,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
if (networkOfferingId != oldNetworkOfferingId) {
//don't allow to update shared network
if (offering.getGuestType() != GuestType.Isolated) {
throw new InvalidParameterValueException("NetworkOfferingId can be upgraded only for the network of type " + GuestType.Isolated);
}
//check if the network is upgradable
if (!canUpgrade(oldNetworkOfferingId, networkOfferingId)) {
throw new InvalidParameterValueException("Can't upgrade from network offering " + oldNetworkOfferingId + " to " + networkOfferingId + "; check logs for more information");
@ -3299,6 +3304,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
+ "and the hyphen ('-'); can't start or end with \"-\"");
}
//don't allow to update shared network
if (offering.getGuestType() == GuestType.Shared) {
throw new InvalidParameterValueException("Can't upgrade the networkDomain for the network of type " + GuestType.Isolated);
}
long offeringId = oldNetworkOfferingId;
if (networkOfferingId != null) {
offeringId = networkOfferingId;
@ -3532,6 +3542,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
NetworkOffering oldNetworkOffering = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId);
NetworkOffering newNetworkOffering = _networkOfferingDao.findById(newNetworkOfferingId);
//can upgrade only Isolated networks
//security group service should be the same
if (areServicesSupportedByNetworkOffering(oldNetworkOfferingId, Service.SecurityGroup) != areServicesSupportedByNetworkOffering(newNetworkOfferingId, Service.SecurityGroup)) {
s_logger.debug("Offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different securityGroupProperty, can't upgrade");