cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [40/50] [abbrv] git commit: updated refs/heads/regionvpc to edf12eb
Date Tue, 11 Mar 2014 14:27:02 GMT
introduce 'RegionLevelVpc' as capability of 'Connectivity' service. Add
support for CreateVPCOffering to take the 'regionlevelvpc' as capability
of service 'connectivity'.


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

Branch: refs/heads/regionvpc
Commit: c2edeace94de6994697e0af6ffabc87335536e7f
Parents: 991e1eb
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Fri Jan 24 11:15:38 2014 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Tue Mar 11 19:42:58 2014 +0530

----------------------------------------------------------------------
 api/src/com/cloud/network/Network.java          |  4 +-
 api/src/com/cloud/network/vpc/VpcOffering.java  |  5 ++
 .../network/vpc/VpcProvisioningService.java     |  7 ++-
 .../org/apache/cloudstack/api/ApiConstants.java |  1 +
 .../command/admin/vpc/CreateVPCOfferingCmd.java |  8 ++-
 .../api/response/VpcOfferingResponse.java       |  8 +++
 .../com/cloud/network/vpc/VpcOfferingVO.java    | 12 +++-
 server/src/com/cloud/api/ApiResponseHelper.java |  2 +-
 .../com/cloud/network/vpc/VpcManagerImpl.java   | 61 +++++++++++++++++---
 9 files changed, 95 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2edeace/api/src/com/cloud/network/Network.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java
index 6dc6752..88f23f0 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -57,7 +57,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>,
I
         public static final Service PortForwarding = new Service("PortForwarding");
         public static final Service SecurityGroup = new Service("SecurityGroup");
         public static final Service NetworkACL = new Service("NetworkACL", Capability.SupportedProtocols);
-        public static final Service Connectivity = new Service("Connectivity");
+        public static final Service Connectivity = new Service("Connectivity", Capability.RegionLevelVpc);
 
         private final String name;
         private final Capability[] caps;
@@ -186,6 +186,8 @@ public interface Network extends ControlledEntity, StateObject<Network.State>,
I
         public static final Capability SslTermination = new Capability("SslTermination");
         public static final Capability LbSchemes = new Capability("LbSchemes");
         public static final Capability DhcpAccrossMultipleSubnets = new Capability("DhcpAccrossMultipleSubnets");
+        public static final Capability StretchedL2Subnet = new Capability("StretchedL2Subnet");
+        public static final Capability RegionLevelVpc = new Capability("RegionLevelVpc");
 
         private final String name;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2edeace/api/src/com/cloud/network/vpc/VpcOffering.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/VpcOffering.java b/api/src/com/cloud/network/vpc/VpcOffering.java
index 6e75a2f..a56a685 100644
--- a/api/src/com/cloud/network/vpc/VpcOffering.java
+++ b/api/src/com/cloud/network/vpc/VpcOffering.java
@@ -55,4 +55,9 @@ public interface VpcOffering extends InternalIdentity, Identity {
      */
     Long getServiceOfferingId();
 
+    /**
+     *
+     * @return true if VPC created with the offering can span multiple zones in the region
+     */
+    boolean offersRegionLevelVPC();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2edeace/api/src/com/cloud/network/vpc/VpcProvisioningService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/VpcProvisioningService.java b/api/src/com/cloud/network/vpc/VpcProvisioningService.java
index 174b71f..82a7baa 100644
--- a/api/src/com/cloud/network/vpc/VpcProvisioningService.java
+++ b/api/src/com/cloud/network/vpc/VpcProvisioningService.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.network.vpc;
 
+
 import java.util.List;
 import java.util.Map;
 
@@ -23,8 +24,10 @@ public interface VpcProvisioningService {
 
     public VpcOffering getVpcOffering(long vpcOfferingId);
 
-    public VpcOffering createVpcOffering(String name, String displayText, List<String>
supportedServices, Map<String, List<String>> serviceProviders,
-        Long serviceOfferingId);
+    public VpcOffering createVpcOffering(String name, String displayText, List<String>
supportedServices,
+                                         Map<String, List<String>> serviceProviders,
+                                         Map serviceCapabilitystList,
+                                         Long serviceOfferingId);
 
     List<? extends VpcOffering> listVpcOfferings(Long id, String name, String displayText,
List<String> supportedServicesStr, Boolean isDefault, String keyword,
         String state, Long startIndex, Long pageSizeVal);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2edeace/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 0a3fafd..3785250 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -586,6 +586,7 @@ public class ApiConstants {
     public static final String VGPU = "vgpu";
     public static final String VGPUTYPE = "vgputype";
     public static final String REMAININGCAPACITY = "remainingcapacity";
+    public static final String SUPPORTS_REGION_LEVEL_VPC = "supportsregionLevelvpc";
 
     public enum HostDetails {
         all, capacity, events, stats, min;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2edeace/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java
index 6b2c4ba..60b403c 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java
@@ -23,6 +23,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.network.Network;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
@@ -62,6 +64,9 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
                description = "services supported by the vpc offering")
     private List<String> supportedServices;
 
+    @Parameter(name = ApiConstants.SERVICE_CAPABILITY_LIST, type = CommandType.MAP, description
= "desired service capabilities as part of vpc offering")
+    private Map serviceCapabilitystList;
+
     @Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST, type = CommandType.MAP, description
= "provider to service mapping. "
         + "If not specified, the provider for the service will be mapped to the default provider
on the physical network")
     private Map<String, String> serviceProviderList;
@@ -118,7 +123,8 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
 
     @Override
     public void create() throws ResourceAllocationException {
-        VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(getVpcOfferingName(), getDisplayText(),
getSupportedServices(), getServiceProviders(), getServiceOfferingId());
+        VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(getVpcOfferingName(), getDisplayText(),
getSupportedServices(),
+                getServiceProviders(), serviceCapabilitystList, getServiceOfferingId());
         if (vpcOff != null) {
             setEntityId(vpcOff.getId());
             setEntityUuid(vpcOff.getUuid());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2edeace/api/src/org/apache/cloudstack/api/response/VpcOfferingResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/VpcOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/VpcOfferingResponse.java
index 17e4dfd..27432bc 100644
--- a/api/src/org/apache/cloudstack/api/response/VpcOfferingResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/VpcOfferingResponse.java
@@ -59,6 +59,10 @@ public class VpcOfferingResponse extends BaseResponse {
     @Param(description = "the list of supported services", responseObject = ServiceResponse.class)
     private List<ServiceResponse> services;
 
+    @SerializedName((ApiConstants.SUPPORTS_REGION_LEVEL_VPC))
+    @Param(description = " indicated if the offering can support region level vpc")
+    private Boolean supportsRegionLevelVpc;
+
     public void setId(String id) {
         this.id = id;
     }
@@ -86,4 +90,8 @@ public class VpcOfferingResponse extends BaseResponse {
     public void setState(String state) {
         this.state = state;
     }
+
+    public void setSupportsRegionLevelVpc(Boolean supports) {
+        this.supportsRegionLevelVpc = supports;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2edeace/engine/schema/src/com/cloud/network/vpc/VpcOfferingVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/VpcOfferingVO.java b/engine/schema/src/com/cloud/network/vpc/VpcOfferingVO.java
index 3a676e6..43ad514 100644
--- a/engine/schema/src/com/cloud/network/vpc/VpcOfferingVO.java
+++ b/engine/schema/src/com/cloud/network/vpc/VpcOfferingVO.java
@@ -67,6 +67,9 @@ public class VpcOfferingVO implements VpcOffering {
     @Column(name = "service_offering_id")
     Long serviceOfferingId;
 
+    @Column(name = "supports_region_level_vpc")
+    boolean offersRegionLevelVPC = false;
+
     public VpcOfferingVO() {
         this.uuid = UUID.randomUUID().toString();
     }
@@ -80,9 +83,11 @@ public class VpcOfferingVO implements VpcOffering {
         this.state = State.Disabled;
     }
 
-    public VpcOfferingVO(String name, String displayText, boolean isDefault, Long serviceOfferingId)
{
+    public VpcOfferingVO(String name, String displayText, boolean isDefault, Long serviceOfferingId,
+                         boolean offersRegionLevelVPC) {
         this(name, displayText, serviceOfferingId);
         this.isDefault = isDefault;
+        this.offersRegionLevelVPC = offersRegionLevelVPC;
     }
 
     @Override
@@ -145,4 +150,9 @@ public class VpcOfferingVO implements VpcOffering {
     public Long getServiceOfferingId() {
         return serviceOfferingId;
     }
+
+    @Override
+    public boolean offersRegionLevelVPC() {
+        return offersRegionLevelVPC;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2edeace/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 81bfe21..74e973a 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -2748,7 +2748,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setDisplayText(offering.getDisplayText());
         response.setIsDefault(offering.isDefault());
         response.setState(offering.getState().name());
-
+        response.setSupportsRegionLevelVpc(offering.supportsRegionLevelVpc());
         Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
         List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
         for (Service service : serviceProviderMap.keySet()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2edeace/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 762cc6f..b8d6478 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -16,10 +16,13 @@
 // under the License.
 package com.cloud.network.vpc;
 
+
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -231,7 +234,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
                             svcProviderMap.put(svc, defaultProviders);
                         }
                     }
-                    createVpcOffering(VpcOffering.defaultVPCOfferingName, VpcOffering.defaultVPCOfferingName,
svcProviderMap, true, State.Enabled, null);
+                    createVpcOffering(VpcOffering.defaultVPCOfferingName, VpcOffering.defaultVPCOfferingName,
+                            svcProviderMap, true, State.Enabled, null, false);
                 }
 
                 //configure default vpc offering with Netscaler as LB Provider
@@ -250,7 +254,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
                             svcProviderMap.put(svc, defaultProviders);
                         }
                     }
-                    createVpcOffering(VpcOffering.defaultVPCNSOfferingName, VpcOffering.defaultVPCNSOfferingName,
svcProviderMap, false, State.Enabled, null);
+                    createVpcOffering(VpcOffering.defaultVPCNSOfferingName, VpcOffering.defaultVPCNSOfferingName,
+                            svcProviderMap, false, State.Enabled, null, false);
                 }
             }
         });
@@ -299,8 +304,10 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_CREATE, eventDescription = "creating
vpc offering", create = true)
-    public VpcOffering createVpcOffering(String name, String displayText, List<String>
supportedServices, Map<String, List<String>> serviceProviders,
-        Long serviceOfferingId) {
+    public VpcOffering createVpcOffering(String name, String displayText, List<String>
supportedServices,
+                                         Map<String, List<String>> serviceProviders,
+                                         Map serviceCapabilitystList,
+                                         Long serviceOfferingId) {
         Map<Network.Service, Set<Network.Provider>> svcProviderMap = new HashMap<Network.Service,
Set<Network.Provider>>();
         Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
         defaultProviders.add(Provider.VPCVirtualRouter);
@@ -372,7 +379,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
             }
         }
 
-        VpcOffering offering = createVpcOffering(name, displayText, svcProviderMap, false,
null, serviceOfferingId);
+        boolean offersRegionLevelVPC = isVpcOfferingForRegionLevelVpc(serviceCapabilitystList);
+
+        VpcOffering offering = createVpcOffering(name, displayText, svcProviderMap, false,
null, serviceOfferingId, offersRegionLevelVPC);
         CallContext.current().setEventDetails(" Id: " + offering.getId() + " Name: " + name);
 
         return offering;
@@ -380,12 +389,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
 
     @DB
     protected VpcOffering createVpcOffering(final String name, final String displayText,
final Map<Network.Service, Set<Network.Provider>> svcProviderMap,
-        final boolean isDefault, final State state, final Long serviceOfferingId) {
+        final boolean isDefault, final State state, final Long serviceOfferingId, final boolean
offersRegionLevelVPC) {
         return Transaction.execute(new TransactionCallback<VpcOffering>() {
             @Override
             public VpcOffering doInTransaction(TransactionStatus status) {
                 // create vpc offering object
-                VpcOfferingVO offering = new VpcOfferingVO(name, displayText, isDefault,
serviceOfferingId);
+                VpcOfferingVO offering = new VpcOfferingVO(name, displayText, isDefault,
serviceOfferingId, offersRegionLevelVPC);
 
                 if (state != null) {
                     offering.setState(state);
@@ -413,6 +422,44 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
         });
     }
 
+    private boolean isVpcOfferingForRegionLevelVpc(Map serviceCapabilitystList) {
+        boolean offersRegionLevelVPC = false;
+        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.");
+                }
+                offersRegionLevelVPC = capabilityValue.equalsIgnoreCase("true");
+            }
+        }
+        return offersRegionLevelVPC;
+    }
+
     @Override
     public Vpc getActiveVpc(long vpcId) {
         return _vpcDao.getActiveVpcById(vpcId);


Mime
View raw message