cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [3/5] git commit: updated refs/heads/regionvpc to 71774f5
Date Fri, 24 Jan 2014 19:08:53 GMT
adds check to ensure 'Connectivity' service provider supports
'StretchedL2Subnet' and 'RegionLevelVpc' capabilities when specified in
createNetworkOffering and createVpcOffering respectivley


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

Branch: refs/heads/regionvpc
Commit: 5a019848ced9045aa186e70e57378625140704bf
Parents: eb84ab5
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Fri Jan 24 17:56:04 2014 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Fri Jan 24 18:05:36 2014 +0530

----------------------------------------------------------------------
 .../configuration/ConfigurationManagerImpl.java | 19 +++++++-
 .../com/cloud/network/vpc/VpcManagerImpl.java   | 51 ++++++++++++++++++++
 2 files changed, 68 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a019848/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 3176636..e66fae8 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.configuration;
 
+import com.cloud.network.element.NetworkElement;
 import java.net.URI;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -3712,7 +3713,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
             throw new InvalidParameterValueException("Capabilities for 'Connectivity' service
can be specified " +
                     "only when Connectivity service is enabled for network offering.");
         }
-        validateConnectivityServiceCapablities(connectivityServiceCapabilityMap);
+        validateConnectivityServiceCapablities(serviceProviderMap.get(Service.Connectivity),
connectivityServiceCapabilityMap);
 
         Map<Service, Map<Capability, String>> serviceCapabilityMap = new HashMap<Service,
Map<Capability, String>>();
         serviceCapabilityMap.put(Service.Lb, lbServiceCapabilityMap);
@@ -3853,7 +3854,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
         }
     }
 
-    void validateConnectivityServiceCapablities(Map<Capability, String> connectivityServiceCapabilityMap)
{
+    void validateConnectivityServiceCapablities(Set<Provider> providers, Map<Capability,
String> connectivityServiceCapabilityMap) {
         if (connectivityServiceCapabilityMap != null && !connectivityServiceCapabilityMap.isEmpty())
{
             for (Capability capability: connectivityServiceCapabilityMap.keySet()) {
                 if (capability == Capability.StretchedL2Subnet) {
@@ -3868,6 +3869,20 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
                 }
             }
         }
+
+        if (providers != null && !providers.isEmpty()) {
+            for (Provider provider: providers) {
+                NetworkElement element = _networkModel.getElementImplementingProvider(provider.getName());
+                Map<Service, Map<Capability, String>> capabilities = element.getCapabilities();
+                if (capabilities != null && !capabilities.isEmpty()) {
+                    Map<Capability, String> connectivityCapabilities =  capabilities.get(Service.Connectivity);
+                    if (connectivityCapabilities == null || (connectivityCapabilities !=
null && !connectivityCapabilities.keySet().contains(Capability.StretchedL2Subnet)))
{
+                        throw new InvalidParameterValueException("Provider: " + provider.getName()
+ " does not support "
+                                + Capability.StretchedL2Subnet.getName());
+                    }
+                }
+            }
+        }
     }
     @Override
     @DB

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a019848/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 599d0ec..6bd7b42 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -17,6 +17,7 @@
 package com.cloud.network.vpc;
 
 
+import com.cloud.network.element.NetworkElement;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -379,6 +380,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
             }
         }
 
+        validateConnectivtyServiceCapablitlies(svcProviderMap.get(Service.Connectivity),
serviceCapabilitystList);
         boolean offersRegionLevelVPC = isVpcOfferingForRegionLevelVpc(serviceCapabilitystList);
 
         VpcOffering offering = createVpcOffering(name, displayText, svcProviderMap, false,
null, serviceOfferingId, offersRegionLevelVPC);
@@ -422,6 +424,55 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
         });
     }
 
+    private void validateConnectivtyServiceCapablitlies(Set<Provider> providers, Map
serviceCapabilitystList) {
+
+        if (serviceCapabilitystList != null && !serviceCapabilitystList.isEmpty())
{
+            Collection serviceCapabilityCollection = serviceCapabilitystList.values();
+            Iterator iter = serviceCapabilityCollection.iterator();
+            Map<Network.Capability, String> capabilityMap = null;
+
+            while (iter.hasNext()) {
+                HashMap<String, String> svcCapabilityMap = (HashMap<String, String>)iter.next();
+                Network.Capability capability = null;
+                String svc = svcCapabilityMap.get("service");
+                String capabilityName = svcCapabilityMap.get("capabilitytype");
+                String capabilityValue = svcCapabilityMap.get("capabilityvalue");
+                if (capabilityName != null) {
+                    capability = Network.Capability.getCapability(capabilityName);
+                }
+
+                if ((capability == null) || (capabilityName == null) || (capabilityValue
== null)) {
+                    throw new InvalidParameterValueException("Invalid capability:" + capabilityName
+ " capability value:" + capabilityValue);
+                }
+
+                if (!svc.equalsIgnoreCase(Service.Connectivity.getName())) {
+                    throw new InvalidParameterValueException("Invalid Service:" + svc + "
specified. Only for 'Connectivity' service capabilities can be specified");
+                }
+
+                if (!capabilityName.equalsIgnoreCase("RegionLevelVpc")) {
+                    throw new InvalidParameterValueException("Invalid Capability:" + capabilityName
+ " specified. Only 'RegionLevelVpc' capability can be specified.");
+                }
+
+                if (!capabilityValue.equalsIgnoreCase("true") && capabilityValue.equalsIgnoreCase("false"))
{
+                    throw new InvalidParameterValueException("Invalid Capability value:"
+ capabilityValue + " specified.");
+                }
+            }
+        }
+
+        if (providers != null && !providers.isEmpty()) {
+            for (Provider provider: providers) {
+                NetworkElement element = _ntwkModel.getElementImplementingProvider(provider.getName());
+                Map<Service, Map<Network.Capability, String>> capabilities =
element.getCapabilities();
+                if (capabilities != null && !capabilities.isEmpty()) {
+                    Map<Network.Capability, String> connectivityCapabilities =  capabilities.get(Service.Connectivity);
+                    if (connectivityCapabilities == null || (connectivityCapabilities !=
null && !connectivityCapabilities.keySet().contains(Network.Capability.RegionLevelVpc)))
{
+                        throw new InvalidParameterValueException("Provider: " + provider.getName()
+ " does not support "
+                                + Network.Capability.RegionLevelVpc.getName());
+                    }
+                }
+            }
+        }
+    }
     private boolean isVpcOfferingForRegionLevelVpc(Map serviceCapabilitystList) {
         boolean offersRegionLevelVPC = false;
         if (serviceCapabilitystList != null && !serviceCapabilitystList.isEmpty())
{


Mime
View raw message