cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject git commit: updated refs/heads/4.2 to 9895d01
Date Mon, 12 Aug 2013 12:41:23 GMT
Updated Branches:
  refs/heads/4.2 608c63a53 -> 9895d01a5


CLOUDSTACK-4111: Prompt "Acquire New IP - Cross Zones - YES/NO" wizard
only when there is portable IP range added at region level.

region response will now have details if portable IP service is enabled
or not. Portable IP service for a region is turned off by default. when
adming adds a portable ip range portable ip service is enabled for the
region.


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

Branch: refs/heads/4.2
Commit: 9895d01a53254336f070925878602af0c4dcd51d
Parents: 608c63a
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Mon Aug 12 18:09:13 2013 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Mon Aug 12 18:11:13 2013 +0530

----------------------------------------------------------------------
 .../cloudstack/api/response/RegionResponse.java | 15 +++++++-
 .../org/apache/cloudstack/region/Region.java    |  4 +-
 .../org/apache/cloudstack/region/RegionVO.java  | 39 +++++++++++++++++---
 server/src/com/cloud/api/ApiResponseHelper.java |  2 +
 .../configuration/ConfigurationManagerImpl.java | 15 +++++++-
 setup/db/db/schema-412to420.sql                 |  2 +
 6 files changed, 67 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9895d01a/api/src/org/apache/cloudstack/api/response/RegionResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/RegionResponse.java b/api/src/org/apache/cloudstack/api/response/RegionResponse.java
index f8bfe53..acaa272 100644
--- a/api/src/org/apache/cloudstack/api/response/RegionResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/RegionResponse.java
@@ -35,6 +35,12 @@ public class RegionResponse extends BaseResponse {
     @SerializedName(ApiConstants.END_POINT) @Param(description="the end point of the region")
     private String endPoint;
 
+    @SerializedName("gslbserviceenabled") @Param(description="true if GSLB service is enabled
in the region, false otherwise")
+    private boolean gslbServiceEnabled;
+
+    @SerializedName("portableipserviceenabled") @Param(description="true if security groups
support is enabled, false otherwise")
+    private boolean portableipServiceEnabled;
+
 	public Integer getId() {
 		return id;
 	}
@@ -59,4 +65,11 @@ public class RegionResponse extends BaseResponse {
 		this.endPoint = endPoint;
 	}
 
-  }
+    public void setGslbServiceEnabled(boolean gslbServiceEnabled) {
+        this.gslbServiceEnabled = gslbServiceEnabled;
+    }
+
+    public void setPortableipServiceEnabled(boolean portableipServiceEnabled) {
+        this.portableipServiceEnabled = portableipServiceEnabled;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9895d01a/api/src/org/apache/cloudstack/region/Region.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/region/Region.java b/api/src/org/apache/cloudstack/region/Region.java
index 7119f1b..c696fb2 100644
--- a/api/src/org/apache/cloudstack/region/Region.java
+++ b/api/src/org/apache/cloudstack/region/Region.java
@@ -31,10 +31,11 @@ public interface Region  {
 	public void setName(String name);
 
 	public String getEndPoint();
-	
 
     public boolean checkIfServiceEnabled(Service service);
 
+    public void enableService(Service service);
+
     /**
      * A region level service, is a service that constitute services across one or more zones
in the region or a service
      * made available to all the zones in the region.
@@ -45,6 +46,7 @@ public interface Region  {
         private static List<Service> regionServices = new ArrayList<Service>();
 
         public static final Service Gslb = new Service("Gslb");
+        public static final Service PortableIp = new Service("PortableIp");
 
         public Service(String name ) {
             this.name = name;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9895d01a/engine/schema/src/org/apache/cloudstack/region/RegionVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/region/RegionVO.java b/engine/schema/src/org/apache/cloudstack/region/RegionVO.java
index 6890bc8..36db8dd 100644
--- a/engine/schema/src/org/apache/cloudstack/region/RegionVO.java
+++ b/engine/schema/src/org/apache/cloudstack/region/RegionVO.java
@@ -35,7 +35,12 @@ public class RegionVO implements Region{
 
     @Column(name="end_point")
     private String endPoint;
-    
+
+    @Column(name="gslb_service_enabled")
+    private boolean gslbEnabled;
+
+    @Column(name="portableip_service_enabled")
+    private boolean portableipEnabled;
 
     public boolean getGslbEnabled() {
         return gslbEnabled;
@@ -45,9 +50,6 @@ public class RegionVO implements Region{
         this.gslbEnabled = gslbEnabled;
     }
 
-    @Column(name="gslb_service_enabled")
-    private boolean gslbEnabled;
-
     public RegionVO() {
     }
     
@@ -78,10 +80,35 @@ public class RegionVO implements Region{
 		this.endPoint = endPoint;
 	}
 
-
     @Override
     public boolean checkIfServiceEnabled(Service service) {
-        return gslbEnabled;
+        if (Service.Gslb.equals(service)) {
+            return gslbEnabled;
+        } else if (Service.PortableIp.equals(service)) {
+            return portableipEnabled;
+        } else {
+             assert false: "Unknown Region level Service";
+            return false;
+        }
+    }
+
+    @Override
+    public void enableService(org.apache.cloudstack.region.Region.Service service) {
+        if (Service.Gslb.equals(service)) {
+            this.gslbEnabled = true;
+        } else if (Service.PortableIp.equals(service)) {
+            this.portableipEnabled = true;
+        } else {
+            assert false: "Unknown Region level Service";
+            return;
+        }
+    }
+
+    public boolean getPortableipEnabled() {
+        return portableipEnabled;
     }
 
+    public void setPortableipEnabled(boolean portableipEnabled) {
+        this.portableipEnabled = portableipEnabled;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9895d01a/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 142b445..2547bd6 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -2808,6 +2808,8 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setName(region.getName());
         response.setEndPoint(region.getEndPoint());
         response.setObjectName("region");
+        response.setGslbServiceEnabled(region.checkIfServiceEnabled(Region.Service.Gslb));
+        response.setPortableipServiceEnabled(region.checkIfServiceEnabled(Region.Service.PortableIp));
         return response;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9895d01a/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 b9b0b28..7f3ff10 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -77,6 +77,7 @@ import org.apache.cloudstack.region.PortableIpRangeDao;
 import org.apache.cloudstack.region.PortableIpRangeVO;
 import org.apache.cloudstack.region.PortableIpVO;
 import org.apache.cloudstack.region.Region;
+import org.apache.cloudstack.region.RegionVO;
 import org.apache.cloudstack.region.dao.RegionDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
@@ -5026,7 +5027,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
         String netmask = cmd.getNetmask();
         String vlanId = cmd.getVlan();
 
-        Region region = _regionDao.findById(regionId);
+        RegionVO region = _regionDao.findById(regionId);
         if (region == null) {
             throw new InvalidParameterValueException("Invalid region ID: " + regionId);
         }
@@ -5086,6 +5087,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
             startIpLong++;
         }
 
+        // implicitly enable portable IP service for the region
+        region.setPortableipEnabled(true);
+        _regionDao.update(region.getId(), region);
+
         txn.commit();
         portableIpLock.unlock();
         return portableIpRange;
@@ -5097,6 +5102,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
     eventDescription = "deleting portable ip range", async = false)
     public boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd) {
         long rangeId = cmd.getId();
+
         PortableIpRangeVO portableIpRange = _portableIpRangeDao.findById(rangeId);
         if (portableIpRange == null) {
             throw new InvalidParameterValueException("Please specify a valid portable IP
range id.");
@@ -5109,12 +5115,17 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
         if (fullIpRange != null && freeIpRange != null) {
             if (fullIpRange.size() == freeIpRange.size()) {
                 _portableIpRangeDao.expunge(portableIpRange.getId());
+                List<PortableIpRangeVO> pipranges = _portableIpRangeDao.listAll();
+                if (pipranges == null || pipranges.isEmpty()) {
+                    RegionVO region = _regionDao.findById(portableIpRange.getRegionId());
+                    region.setPortableipEnabled(false);
+                    _regionDao.update(region.getId(), region);
+                }
                 return true;
             } else {
                 throw new InvalidParameterValueException("Can't delete portable IP range
as there are IP's assigned.");
             }
         }
-
         return false;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9895d01a/setup/db/db/schema-412to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-412to420.sql b/setup/db/db/schema-412to420.sql
index 247a6ea..71bd5a9 100644
--- a/setup/db/db/schema-412to420.sql
+++ b/setup/db/db/schema-412to420.sql
@@ -531,6 +531,8 @@ CREATE VIEW `cloud`.`event_view` AS
             left join
         `cloud`.`event` eve ON event.start_id = eve.id;
 
+ALTER TABLE `cloud`.`region` ADD COLUMN `portableip_service_enabled` tinyint(1) unsigned
NOT NULL DEFAULT 0 COMMENT 'Is Portable IP service enalbed in the Region';
+
 ALTER TABLE `cloud`.`region` ADD COLUMN `gslb_service_enabled` tinyint(1) unsigned NOT NULL
DEFAULT 1 COMMENT 'Is GSLB service enalbed in the Region';
 
 ALTER TABLE `cloud`.`external_load_balancer_devices` ADD COLUMN `is_gslb_provider` int(1)
unsigned NOT NULL DEFAULT 0 COMMENT '1 if load balancer appliance is acting as gslb service
provider in the zone';


Mime
View raw message