Skip to content

Commit eac54e3

Browse files
Alena ProkharchykAlena Prokharchyk
authored andcommitted
Don't allow to upgrade networkOfferingId and networkDomain for Shared network offerings
1 parent 8836a08 commit eac54e3

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import com.cloud.api.ServerApiException;
3535
import com.cloud.api.response.NetworkOfferingResponse;
3636
import com.cloud.offering.NetworkOffering;
37-
import com.cloud.offering.NetworkOffering.Availability;
3837
import com.cloud.user.Account;
3938

4039
@Implementation(description="Updates a network offering.", responseObject=NetworkOfferingResponse.class)

‎server/src/com/cloud/network/NetworkManagerImpl.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,6 +3282,11 @@ public Network updateNetwork(long networkId, String name, String displayText, Ac
32823282
}
32833283

32843284
if (networkOfferingId != oldNetworkOfferingId) {
3285+
//don't allow to update shared network
3286+
if (offering.getGuestType() != GuestType.Isolated) {
3287+
throw new InvalidParameterValueException("NetworkOfferingId can be upgraded only for the network of type " + GuestType.Isolated);
3288+
}
3289+
32853290
//check if the network is upgradable
32863291
if (!canUpgrade(oldNetworkOfferingId, networkOfferingId)) {
32873292
throw new InvalidParameterValueException("Can't upgrade from network offering " + oldNetworkOfferingId + " to " + networkOfferingId + "; check logs for more information");
@@ -3299,6 +3304,11 @@ public Network updateNetwork(long networkId, String name, String displayText, Ac
32993304
+ "and the hyphen ('-'); can't start or end with \"-\"");
33003305
}
33013306

3307+
//don't allow to update shared network
3308+
if (offering.getGuestType() == GuestType.Shared) {
3309+
throw new InvalidParameterValueException("Can't upgrade the networkDomain for the network of type " + GuestType.Isolated);
3310+
}
3311+
33023312
long offeringId = oldNetworkOfferingId;
33033313
if (networkOfferingId != null) {
33043314
offeringId = networkOfferingId;
@@ -3532,6 +3542,8 @@ protected boolean canUpgrade(long oldNetworkOfferingId, long newNetworkOfferingI
35323542
NetworkOffering oldNetworkOffering = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId);
35333543
NetworkOffering newNetworkOffering = _networkOfferingDao.findById(newNetworkOfferingId);
35343544

3545+
//can upgrade only Isolated networks
3546+
35353547
//security group service should be the same
35363548
if (areServicesSupportedByNetworkOffering(oldNetworkOfferingId, Service.SecurityGroup) != areServicesSupportedByNetworkOffering(newNetworkOfferingId, Service.SecurityGroup)) {
35373549
s_logger.debug("Offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different securityGroupProperty, can't upgrade");

0 commit comments

Comments
 (0)