cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [1/3] git commit: updated refs/heads/distributedrouter to e41fe92
Date Tue, 04 Mar 2014 12:52:39 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/distributedrouter [created] e41fe92d5


-introduces 'DistributedRouter' as capability to 'Connectivity' service.
-create VPC offering to permit 'DistributedRouter' as capability to
connectivity service


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

Branch: refs/heads/distributedrouter
Commit: 9b0a1fbf9f6d8141624fb64719142d241a8b3156
Parents: 9be51e1
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Tue Mar 4 16:42:17 2014 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Tue Mar 4 16:42:17 2014 +0530

----------------------------------------------------------------------
 api/src/com/cloud/network/Network.java          |  3 +-
 api/src/com/cloud/network/vpc/VpcOffering.java  |  5 ++
 .../network/vpc/VpcProvisioningService.java     |  6 +-
 .../org/apache/cloudstack/api/ApiConstants.java |  2 +-
 .../command/admin/vpc/CreateVPCOfferingCmd.java | 10 +++-
 .../api/response/VpcOfferingResponse.java       |  8 +++
 .../com/cloud/network/vpc/VpcOfferingVO.java    | 12 +++-
 .../management/ContrailManagerImpl.java         |  2 +-
 server/src/com/cloud/api/ApiResponseHelper.java |  1 +
 .../com/cloud/network/vpc/VpcManagerImpl.java   | 63 +++++++++++++++++---
 setup/db/db/schema-430to440.sql                 |  2 +
 11 files changed, 99 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b0a1fbf/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..3283a55 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.DistributedRouter);
 
         private final String name;
         private final Capability[] caps;
@@ -186,6 +186,7 @@ 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 DistributedRouter = new Capability("DistributedRouter");
 
         private final String name;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b0a1fbf/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..a0a1b15 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 the offering provides a distributed router capable of one-hop forwarding
+     */
+    boolean supportsDistributedRouter();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b0a1fbf/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..e545275 100644
--- a/api/src/com/cloud/network/vpc/VpcProvisioningService.java
+++ b/api/src/com/cloud/network/vpc/VpcProvisioningService.java
@@ -23,8 +23,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/9b0a1fbf/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 7b7f9ca..a5aeeb6 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -550,7 +550,7 @@ public class ApiConstants {
     public static final String PASSIVE = "passive";
     public static final String VERSION = "version";
     public static final String START = "start";
-
+    public static final String DISTRIBUTED_VPC_ROUTER = "distributedvpcrouter";
     public enum HostDetails {
         all, capacity, events, stats, min;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b0a1fbf/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..5b3090b 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
@@ -66,6 +66,9 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
         + "If not specified, the provider for the service will be mapped to the default provider
on the physical network")
     private Map<String, String> serviceProviderList;
 
+    @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_OFFERING_ID,
                type = CommandType.UUID,
                entityType = ServiceOfferingResponse.class,
@@ -112,13 +115,18 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
         return serviceProviderMap;
     }
 
+    public Map<String, List<String>> getServiceCapabilitystList() {
+        return serviceCapabilitystList;
+    }
+
     public Long getServiceOfferingId() {
         return serviceOfferingId;
     }
 
     @Override
     public void create() throws ResourceAllocationException {
-        VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(getVpcOfferingName(), getDisplayText(),
getSupportedServices(), getServiceProviders(), getServiceOfferingId());
+        VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(getVpcOfferingName(), getDisplayText(),
+                getSupportedServices(), getServiceProviders(), getServiceCapabilitystList(),
getServiceOfferingId());
         if (vpcOff != null) {
             setEntityId(vpcOff.getId());
             setEntityUuid(vpcOff.getUuid());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b0a1fbf/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..89697f0 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.DISTRIBUTED_VPC_ROUTER)
+    @Param(description = " indicates if the vpc offering supports distributed router for
one-hop forwarding")
+    private Boolean supportsDistributedRouter;
+
     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 setSupportsDistributedRouter(Boolean supportsDistributedRouter) {
+        this.supportsDistributedRouter = supportsDistributedRouter;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b0a1fbf/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..53f6f60 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_distributed_router")
+    boolean supportsDistributedRouter=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 supportsDistributedRouter) {
         this(name, displayText, serviceOfferingId);
         this.isDefault = isDefault;
+        this.supportsDistributedRouter = supportsDistributedRouter;
     }
 
     @Override
@@ -145,4 +150,9 @@ public class VpcOfferingVO implements VpcOffering {
     public Long getServiceOfferingId() {
         return serviceOfferingId;
     }
+
+    @Override
+    public boolean supportsDistributedRouter() {
+        return supportsDistributedRouter;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b0a1fbf/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java
b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java
index 01be7db..bf083fd 100644
--- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java
+++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java
@@ -281,7 +281,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
         for (String svc: services) {
             serviceProviderMap.put(svc, providerSet);
         }
-        vpcOffer = _vpcProvSvc.createVpcOffering(juniperVPCOfferingName, juniperVPCOfferingDisplayText,
services, serviceProviderMap, null);
+        vpcOffer = _vpcProvSvc.createVpcOffering(juniperVPCOfferingName, juniperVPCOfferingDisplayText,
services, serviceProviderMap, null, null);
         ((VpcOfferingVO)vpcOffer).setState(VpcOffering.State.Enabled);
         long id = vpcOffer.getId();
         _vpcOffDao.update(id, (VpcOfferingVO)vpcOffer);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b0a1fbf/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..73c9c6b 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -2748,6 +2748,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setDisplayText(offering.getDisplayText());
         response.setIsDefault(offering.isDefault());
         response.setState(offering.getState().name());
+        response.setSupportsDistributedRouter(offering.supportsDistributedRouter());
 
         Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
         List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b0a1fbf/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 403b95e..0a04356 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -18,8 +18,10 @@ 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 +233,7 @@ 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 +252,7 @@ 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 +301,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,20 +376,25 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
             }
         }
 
-        VpcOffering offering = createVpcOffering(name, displayText, svcProviderMap, false,
null, serviceOfferingId);
+        boolean supportsDistributedRouter = isVpcOfferingSupportsDistributedRouter(serviceCapabilitystList);
+
+        VpcOffering offering = createVpcOffering(name, displayText, svcProviderMap, false,
null,
+                serviceOfferingId,supportsDistributedRouter);
         CallContext.current().setEventDetails(" Id: " + offering.getId() + " Name: " + name);
 
         return offering;
     }
 
     @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) {
+    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 supportsDistributedRouter) {
         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, supportsDistributedRouter);
 
                 if (state != null) {
                     offering.setState(state);
@@ -413,6 +422,44 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
         });
     }
 
+    private boolean isVpcOfferingSupportsDistributedRouter(Map serviceCapabilitystList) {
+        boolean supportsDistributedRouter = 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("DistributedRouter")) {
+                    throw new InvalidParameterValueException("Invalid Capability:" + capabilityName
+ " specified. Only 'DistributedRouter' capability can be specified.");
+                }
+
+                if (!capabilityValue.equalsIgnoreCase("true") && capabilityValue.equalsIgnoreCase("false"))
{
+                    throw new InvalidParameterValueException("Invalid Capability value:"
+ capabilityValue + " specified.");
+                }
+                supportsDistributedRouter = capabilityValue.equalsIgnoreCase("true");
+            }
+        }
+        return supportsDistributedRouter;
+    }
+
     @Override
     public Vpc getActiveVpc(long vpcId) {
         return _vpcDao.getActiveVpcById(vpcId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b0a1fbf/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index 0ded7a9..59156cc 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -542,3 +542,5 @@ ALTER TABLE `cloud`.`s2s_vpn_gateway` ADD COLUMN `display` tinyint(1)
NOT NULL D
 
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (225,
UUID(), 9, 'FreeBSD 10 (32-bit)');
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (226,
UUID(), 9, 'FreeBSD 10 (64-bit)');
+
+ALTER TABLE `cloud`.`vpc_offerings` ADD COLUMN supports_distributed_router boolean default
false;


Mime
View raw message