cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [14/17] git commit: updated refs/heads/regionvpc to cf18fe1
Date Tue, 28 Jan 2014 09:26:45 GMT
make zone id optional parameter in createVpc, zone id can be null only
if vpc offfering supports region level VPC


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

Branch: refs/heads/regionvpc
Commit: 843a04cb2d788d8c794b179ad877bc9a4336ee74
Parents: f5bca33
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Mon Jan 27 14:41:02 2014 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Mon Jan 27 14:45:23 2014 +0530

----------------------------------------------------------------------
 api/src/com/cloud/network/vpc/Vpc.java          |  5 +++++
 api/src/com/cloud/network/vpc/VpcService.java   |  2 +-
 .../org/apache/cloudstack/api/ApiConstants.java |  2 ++
 .../api/command/user/vpc/CreateVPCCmd.java      |  2 +-
 .../cloudstack/api/response/VpcResponse.java    |  8 ++++++++
 .../schema/src/com/cloud/network/vpc/VpcVO.java | 14 ++++++++++++--
 server/src/com/cloud/api/ApiResponseHelper.java |  2 +-
 .../com/cloud/network/vpc/VpcManagerImpl.java   | 20 +++++++++++++++-----
 server/test/com/cloud/vpc/VpcApiUnitTest.java   |  2 +-
 .../test/com/cloud/vpc/dao/MockVpcDaoImpl.java  |  4 ++--
 setup/db/db/schema-430to440.sql                 |  1 +
 11 files changed, 49 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/api/src/com/cloud/network/vpc/Vpc.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/Vpc.java b/api/src/com/cloud/network/vpc/Vpc.java
index fb5f2cc..41b6889 100644
--- a/api/src/com/cloud/network/vpc/Vpc.java
+++ b/api/src/com/cloud/network/vpc/Vpc.java
@@ -72,4 +72,9 @@ public interface Vpc extends ControlledEntity, Identity, InternalIdentity
{
      */
     boolean isRestartRequired();
 
+    /**
+     *
+     * @return true if VPC spans multiple zones in the region
+     */
+    boolean isRegionLevelVpc();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/api/src/com/cloud/network/vpc/VpcService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java
index e28f351..6ce95c1 100644
--- a/api/src/com/cloud/network/vpc/VpcService.java
+++ b/api/src/com/cloud/network/vpc/VpcService.java
@@ -46,7 +46,7 @@ public interface VpcService {
      * @return
      * @throws ResourceAllocationException TODO
      */
-    public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String
displayText, String cidr, String networkDomain)
+    public Vpc createVpc(Long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String
displayText, String cidr, String networkDomain)
         throws ResourceAllocationException;
 
     /**

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/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 82b3619..3e445b0 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -550,6 +550,8 @@ public class ApiConstants {
     public static final String START = "start";
     public static final String SUPPORTS_REGION_LEVEL_VPC = "supportsregionLevelvpc";
     public static final String SUPPORTS_STRECHED_L2_SUBNET = "supportsstrechedl2subnet";
+    public static final String REGION_LEVEL_VPC = "regionlevelvpc";
+
     public enum HostDetails {
         all, capacity, events, stats, min;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
index d4c52b8..45fecde 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
@@ -60,7 +60,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd {
     private Long projectId;
 
     @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class,
-               required = true, description = "the ID of the availability zone")
+               description = "the ID of the availability zone")
     private Long zoneId;
 
     @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description
= "the name of the VPC")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/api/src/org/apache/cloudstack/api/response/VpcResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/VpcResponse.java b/api/src/org/apache/cloudstack/api/response/VpcResponse.java
index fd9b710..d928dca 100644
--- a/api/src/org/apache/cloudstack/api/response/VpcResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/VpcResponse.java
@@ -107,6 +107,10 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
     @Param(description = "the list of resource tags associated with the project", responseObject
= ResourceTagResponse.class)
     private List<ResourceTagResponse> tags;
 
+    @SerializedName((ApiConstants.REGION_LEVEL_VPC))
+    @Param(description = "true if VPC is region level")
+    private Boolean regionLevelVpc;
+
     public void setId(String id) {
         this.id = id;
     }
@@ -191,4 +195,8 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
     public void setTags(List<ResourceTagResponse> tags) {
         this.tags = tags;
     }
+
+    public void setRegionLevelVpc(Boolean regionLevelVpc) {
+        this.regionLevelVpc = regionLevelVpc;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/engine/schema/src/com/cloud/network/vpc/VpcVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/VpcVO.java b/engine/schema/src/com/cloud/network/vpc/VpcVO.java
index 23bcf93..395a495 100644
--- a/engine/schema/src/com/cloud/network/vpc/VpcVO.java
+++ b/engine/schema/src/com/cloud/network/vpc/VpcVO.java
@@ -45,7 +45,7 @@ public class VpcVO implements Vpc {
     String displayText;
 
     @Column(name = "zone_id")
-    long zoneId;
+    Long zoneId;
 
     @Column(name = "cidr")
     private String cidr = null;
@@ -75,11 +75,15 @@ public class VpcVO implements Vpc {
     @Column(name = "restart_required")
     boolean restartRequired = false;
 
+    @Column(name = "region_level_vpc")
+    boolean regionLevelVpc = false;
+
     public VpcVO() {
         this.uuid = UUID.randomUUID().toString();
     }
 
-    public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId,
long vpcOffId, String cidr, String networkDomain) {
+    public VpcVO(Long zoneId, String name, String displayText, long accountId, long domainId,
long vpcOffId,
+                 String cidr, String networkDomain, boolean regionLevelVpc) {
         this.zoneId = zoneId;
         this.name = name;
         this.displayText = displayText;
@@ -90,6 +94,7 @@ public class VpcVO implements Vpc {
         this.state = State.Enabled;
         this.networkDomain = networkDomain;
         this.vpcOfferingId = vpcOffId;
+        this.regionLevelVpc = regionLevelVpc;
     }
 
     @Override
@@ -177,4 +182,9 @@ public class VpcVO implements Vpc {
     public boolean isRestartRequired() {
         return restartRequired;
     }
+
+    @Override
+    public boolean isRegionLevelVpc() {
+        return regionLevelVpc;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/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 d330415..cb37647 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -2786,7 +2786,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setCidr(vpc.getCidr());
         response.setRestartRequired(vpc.isRestartRequired());
         response.setNetworkDomain(vpc.getNetworkDomain());
-
+        response.setRegionLevelVpc(vpc.isRegionLevelVpc());
         Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(vpc.getVpcOfferingId());
         List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
         for (Service service : serviceProviderMap.keySet()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/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 6bd7b42..1906bc5 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -682,7 +682,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc",
create = true)
-    public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String
displayText, String cidr, String networkDomain)
+    public Vpc createVpc(Long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String
displayText, String cidr, String networkDomain)
         throws ResourceAllocationException {
         Account caller = CallContext.current().getCallingAccount();
         Account owner = _accountMgr.getAccount(vpcOwnerId);
@@ -705,6 +705,15 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
             throw ex;
         }
 
+        boolean isRegionLevelVpcOff = vpcOff.offersRegionLevelVPC();
+        if (zoneId == null && !isRegionLevelVpcOff) {
+            throw new InvalidParameterValueException("VPC Offering does not support region
level VPC. So specify zone id in which VPC is to be created");
+        }
+
+        if (isRegionLevelVpcOff && networkDomain == null) {
+            throw new InvalidParameterValueException("Network domain must be specified for
region level VPC");
+        }
+
         //Validate zone
         DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
         if (zone == null) {
@@ -728,12 +737,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
             }
         }
 
-        return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr, networkDomain);
+        return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr, networkDomain,
isRegionLevelVpcOff);
     }
 
     @DB
-    protected Vpc createVpc(final long zoneId, final long vpcOffId, final Account vpcOwner,
final String vpcName, final String displayText, final String cidr,
-        final String networkDomain) {
+    protected Vpc createVpc(final Long zoneId, final long vpcOffId, final Account vpcOwner,
final String vpcName,
+                            final String displayText, final String cidr,final String networkDomain,
final boolean regionLevelVpc) {
 
         //Validate CIDR
         if (!NetUtils.isValidCIDR(cidr)) {
@@ -755,7 +764,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
         return Transaction.execute(new TransactionCallback<VpcVO>() {
             @Override
             public VpcVO doInTransaction(TransactionStatus status) {
-                VpcVO vpc = new VpcVO(zoneId, vpcName, displayText, vpcOwner.getId(), vpcOwner.getDomainId(),
vpcOffId, cidr, networkDomain);
+                VpcVO vpc = new VpcVO(zoneId, vpcName, displayText, vpcOwner.getId(), vpcOwner.getDomainId(),
+                        vpcOffId, cidr, networkDomain, regionLevelVpc);
                 vpc = _vpcDao.persist(vpc, finalizeServicesAndProvidersForVpc(zoneId, vpcOffId));
                 _resourceLimitMgr.incrementResourceCount(vpcOwner.getId(), ResourceType.vpc);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/server/test/com/cloud/vpc/VpcApiUnitTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/VpcApiUnitTest.java b/server/test/com/cloud/vpc/VpcApiUnitTest.java
index bc982a9..0e927df 100644
--- a/server/test/com/cloud/vpc/VpcApiUnitTest.java
+++ b/server/test/com/cloud/vpc/VpcApiUnitTest.java
@@ -85,7 +85,7 @@ public class VpcApiUnitTest extends TestCase {
     public void validateNtwkOffForVpc() {
         //validate network offering
         //1) correct network offering
-        VpcVO vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain");
+        VpcVO vo = new VpcVO(new Long(1), "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc
domain", false);
         boolean result = false;
         try {
             _vpcService.validateNtwkOffForNtwkInVpc(2L, 1, "0.0.0.0", "111-", vo, "10.1.1.1",
new AccountVO(), null);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java b/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java
index 7a0c7a0..4563343 100644
--- a/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java
+++ b/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java
@@ -98,9 +98,9 @@ public class MockVpcDaoImpl extends GenericDaoBase<VpcVO, Long> implements
VpcDa
     public VpcVO findById(Long id) {
         VpcVO vo = null;
         if (id.longValue() == 1) {
-            vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain");
+            vo = new VpcVO(new Long(1), "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc
domain", false);
         } else if (id.longValue() == 2) {
-            vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain");
+            vo = new VpcVO(new Long(1), "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc
domain", false);
             vo.setState(State.Inactive);
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843a04cb/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index 34390a2..b7de223 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -447,3 +447,4 @@ INSERT INTO `cloud`.`configuration`(category, instance, component, name,
value,
 
 ALTER TABLE `cloud`.`vpc_offerings` ADD COLUMN supports_region_level_vpc boolean default
false;
 ALTER TABLE `cloud`.`network_offerings` ADD COLUMN supports_streched_l2 boolean default false;
+ALTER TABLE `cloud`.`vpc` ADD COLUMN region_level_vpc boolean default false;


Mime
View raw message