cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [8/11] git commit: VPC: CS-15447 - fail vpc creation when vpc provider is not enabled at least in one physical network in the target zone
Date Fri, 06 Jul 2012 18:11:02 GMT
VPC: CS-15447 - fail vpc creation when vpc provider is not enabled at least in one physical
network in the target zone


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/07eb6e3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/07eb6e3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/07eb6e3c

Branch: refs/heads/vpc
Commit: 07eb6e3cf76be45ce1e27afa9df48444b7b95b86
Parents: b4fec75
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Thu Jul 5 13:33:46 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Fri Jul 6 11:08:28 2012 -0700

----------------------------------------------------------------------
 .../src/com/cloud/network/NetworkManagerImpl.java  |    6 ++--
 .../src/com/cloud/network/vpc/VpcManagerImpl.java  |   19 ++++++++++++++-
 2 files changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/07eb6e3c/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 1e677a0..c46bdf4 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -2079,7 +2079,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
         List<Provider> providersToImplement = getNetworkProviders(network.getId());
         for (NetworkElement element : _networkElements) {
             if (providersToImplement.contains(element.getProvider())) {
-                if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network), "VirtualRouter"))
{
+                if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network), element.getProvider().getName()))
{
                 	// The physicalNetworkId will not get translated into a uuid by the reponse
serializer,
                 	// because the serializer would look up the NetworkVO class's table and
retrieve the
                 	// network id instead of the physical network id.
@@ -3515,7 +3515,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
         for (NetworkElement element : _networkElements) {
             if (providersToShutdown.contains(element.getProvider())) {
                 try {
-                    if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network),
"VirtualRouter")) {
+                    if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network),
element.getProvider().getName())) {
                         s_logger.warn("Unable to complete shutdown of the network elements
due to element: " + element.getName() + " either doesn't exist or not enabled in the physical
network "
                                 + getPhysicalNetworkId(network));
                         success = false;
@@ -3602,7 +3602,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
         for (NetworkElement element : _networkElements) {
             if (providersToDestroy.contains(element.getProvider())) {
                 try {
-                    if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network),
"VirtualRouter")) {
+                    if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network),
element.getProvider().getName())) {
                         s_logger.warn("Unable to complete destroy of the network elements
due to element: " + element.getName() + " either doesn't exist or not enabled in the physical
network "
                                 + getPhysicalNetworkId(network));
                         success = false;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/07eb6e3c/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 5cc8f86..be6b2d9 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -56,6 +56,7 @@ import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.PhysicalNetwork;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.element.VpcProvider;
 import com.cloud.network.vpc.VpcOffering.State;
 import com.cloud.network.vpc.Dao.PrivateIpDao;
@@ -132,6 +133,8 @@ public class VpcManagerImpl implements VpcManager, Manager{
     NetworkOfferingServiceMapDao _ntwkOffServiceDao ;
     @Inject
     VpcOfferingServiceMapDao _vpcOffServiceDao;
+    @Inject
+    PhysicalNetworkDao _pNtwkDao;
     
     private final ScheduledExecutorService _executor = Executors.newScheduledThreadPool(1,
new NamedThreadFactory("VpcChecker"));
     
@@ -502,7 +505,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
             if (networkDomain == null) {
                 networkDomain = "cs" + Long.toHexString(owner.getId()) + _ntwkMgr.getDefaultNetworkDomain();
             }
-        } 
+        }
         
         return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr, networkDomain);
     }
@@ -511,6 +514,20 @@ public class VpcManagerImpl implements VpcManager, Manager{
     public Vpc createVpc(long zoneId, long vpcOffId, Account vpcOwner, String vpcName, String
displayText, String cidr, 
             String networkDomain) {
         
+        //the provider has to be enabled at least in one network in the zone
+        boolean providerEnabled = false;
+        for (PhysicalNetwork pNtwk : _pNtwkDao.listByZone(zoneId)) {
+            if (_ntwkMgr.isProviderEnabledInPhysicalNetwork(pNtwk.getId(), Provider.VPCVirtualRouter.getName()))
{
+                providerEnabled = true;
+                break;
+            }
+        }
+        
+        if (!providerEnabled) {
+            throw new InvalidParameterValueException("Provider " + Provider.VPCVirtualRouter.getName()
+
+                    " should be enabled in at least one physical network of the zone specified");
+        }
+        
         //Validate CIDR
         if (!NetUtils.isValidCIDR(cidr)) {
             throw new InvalidParameterValueException("Invalid CIDR specified " + cidr);


Mime
View raw message