You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/07/27 23:01:31 UTC
[1/50] [abbrv] git commit: VPC: CS-15725 - don't allow regular
offering upgrade to the offering that can be used inside vpc only
Updated Branches:
refs/heads/vpc 00af51700 -> fe2681fa1
VPC: CS-15725 - don't allow regular offering upgrade to the offering that can be used inside vpc only
Conflicts:
server/src/com/cloud/network/NetworkManagerImpl.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/fe2681fa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/fe2681fa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/fe2681fa
Branch: refs/heads/vpc
Commit: fe2681fa102f1a515a98cc57a7e049095b758360
Parents: 807a9ed
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Fri Jul 27 11:28:42 2012 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Fri Jul 27 13:59:08 2012 -0700
----------------------------------------------------------------------
.../configuration/ConfigurationManagerImpl.java | 9 ++++++---
.../src/com/cloud/network/NetworkManagerImpl.java | 11 ++++++++++-
2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/fe2681fa/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 3a44b55..f1a73de 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -3356,9 +3356,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=" + networkId);
}
@@ -3418,7 +3419,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>();
@@ -3467,7 +3468,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) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/fe2681fa/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 9b8e5b7..36db1dc 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -4693,6 +4693,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
throw ex;
}
+
+ //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) {
Vpc vpc = _vpcMgr.getVpc(network.getVpcId());
@@ -4752,7 +4761,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) {