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/portablepublicip to bf3cb27
Date Sat, 11 May 2013 10:41:19 GMT
Updated Branches:
  refs/heads/portablepublicip e7b2fb225 -> bf3cb274c


add the status of each portable IP (its state, details of associated data
center/VPC/guest network etc) in the PortableIpRangeResponse returned by
listPortableIpRanges API


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

Branch: refs/heads/portablepublicip
Commit: bf3cb274cfeb1ef41c63794ced83c7c6940f34cc
Parents: e7b2fb2
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Sat May 11 16:08:40 2013 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Sat May 11 16:08:40 2013 +0530

----------------------------------------------------------------------
 .../cloud/configuration/ConfigurationService.java  |    3 +
 .../org/apache/cloudstack/api/ApiConstants.java    |    1 +
 .../apache/cloudstack/api/ResponseGenerator.java   |    3 +
 .../admin/region/ListPortableIpRangesCmd.java      |   13 ++++
 .../api/response/PortableIpRangeResponse.java      |    7 ++
 server/src/com/cloud/api/ApiResponseHelper.java    |   47 +++++++++++++++
 .../configuration/ConfigurationManagerImpl.java    |   11 ++++
 .../cloud/vpc/MockConfigurationManagerImpl.java    |    8 ++-
 8 files changed, 92 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf3cb274/api/src/com/cloud/configuration/ConfigurationService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/configuration/ConfigurationService.java b/api/src/com/cloud/configuration/ConfigurationService.java
index 83b9aa2..19b0a42 100644
--- a/api/src/com/cloud/configuration/ConfigurationService.java
+++ b/api/src/com/cloud/configuration/ConfigurationService.java
@@ -58,6 +58,7 @@ import com.cloud.offering.DiskOffering;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.user.Account;
+import org.apache.cloudstack.region.PortableIp;
 import org.apache.cloudstack.region.PortableIpRange;
 
 public interface ConfigurationService {
@@ -287,4 +288,6 @@ public interface ConfigurationService {
     boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd);
 
     List<? extends PortableIpRange> listPortableIpRanges(ListPortableIpRangesCmd cmd);
+
+    List<? extends PortableIp> listPortableIps(long id);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf3cb274/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 1165c7b..e2a76e3 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -152,6 +152,7 @@ public class ApiConstants {
     public static final String POLICY_ID = "policyid";
     public static final String PORT = "port";
     public static final String PORTAL = "portal";
+    public static final String PORTABLE_IP_ADDRESS = "portableipaddress";
     public static final String PORT_FORWARDING_SERVICE_ID = "portforwardingserviceid";
     public static final String PRIVATE_INTERFACE = "privateinterface";
     public static final String PRIVATE_IP = "privateip";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf3cb274/api/src/org/apache/cloudstack/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
index aec74fd..003daae 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -102,6 +102,7 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse;
 import org.apache.cloudstack.api.response.VpcResponse;
 import org.apache.cloudstack.api.response.VpnUsersResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.region.PortableIp;
 import org.apache.cloudstack.region.PortableIpRange;
 import org.apache.cloudstack.region.Region;
 import org.apache.cloudstack.usage.Usage;
@@ -399,4 +400,6 @@ public interface ResponseGenerator {
     Long getAffinityGroupId(String name, long entityOwnerId);
 
     PortableIpRangeResponse createPortableIPRangeResponse(PortableIpRange range);
+
+    PortableIpResponse createPortableIPResponse(PortableIp portableIp);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf3cb274/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java
index 6de81d2..75bcce0 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java
@@ -21,7 +21,9 @@ import javax.inject.Inject;
 import org.apache.cloudstack.api.*;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.PortableIpRangeResponse;
+import org.apache.cloudstack.api.response.PortableIpResponse;
 import org.apache.cloudstack.api.response.RegionResponse;
+import org.apache.cloudstack.region.PortableIp;
 import org.apache.cloudstack.region.PortableIpRange;
 import org.apache.cloudstack.region.Region;
 import org.apache.cloudstack.region.RegionService;
@@ -85,6 +87,17 @@ public class ListPortableIpRangesCmd extends BaseListCmd {
         if (portableIpRanges != null && !portableIpRanges.isEmpty()) {
             for (PortableIpRange range : portableIpRanges) {
                 PortableIpRangeResponse rangeResponse = _responseGenerator.createPortableIPRangeResponse(range);
+
+                List<? extends PortableIp> portableIps = _configService.listPortableIps(range.getId());
+                if (portableIps != null && !portableIps.isEmpty()) {
+                    List<PortableIpResponse> portableIpResponses = new ArrayList<PortableIpResponse>();
+                    for (PortableIp portableIP: portableIps) {
+                        PortableIpResponse portableIpresponse =  _responseGenerator.createPortableIPResponse(portableIP);
+                        portableIpResponses.add(portableIpresponse);
+                    }
+                    rangeResponse.setPortableIpResponses(portableIpResponses);
+                }
+
                 rangeResponse.setObjectName("portableiprange");
                 responses.add(rangeResponse);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf3cb274/api/src/org/apache/cloudstack/api/response/PortableIpRangeResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/PortableIpRangeResponse.java b/api/src/org/apache/cloudstack/api/response/PortableIpRangeResponse.java
index e4a5884..e7a15b8 100644
--- a/api/src/org/apache/cloudstack/api/response/PortableIpRangeResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/PortableIpRangeResponse.java
@@ -55,6 +55,10 @@ public class PortableIpRangeResponse extends BaseResponse {
     @SerializedName(ApiConstants.END_IP) @Param(description="the end ip of the portable IP
range")
     private String endIp;
 
+    @SerializedName(ApiConstants.PORTABLE_IP_ADDRESS)
+    @Param(description="List of portable IP and association with zone/network/vpc details
that are part of GSLB rule", responseObject = PortableIpResponse.class)
+    private List<PortableIpResponse> portableIpResponses;
+
     public void setId(String id) {
         this.id = id;
     }
@@ -83,4 +87,7 @@ public class PortableIpRangeResponse extends BaseResponse {
         this.vlan = vlan;
     }
 
+    public void setPortableIpResponses(List<PortableIpResponse> portableIpResponses)
{
+        this.portableIpResponses = portableIpResponses;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf3cb274/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 0377aad..53506f3 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -127,6 +127,7 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse;
 import org.apache.cloudstack.api.response.VpcResponse;
 import org.apache.cloudstack.api.response.VpnUsersResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.region.PortableIp;
 import org.apache.cloudstack.region.PortableIpRange;
 import org.apache.cloudstack.region.Region;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
@@ -3732,4 +3733,50 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setRegionId(ipRange.getRegionId());
         return response;
     }
+
+    @Override
+    public PortableIpResponse createPortableIPResponse(PortableIp portableIp) {
+        PortableIpResponse response = new PortableIpResponse();
+        response.setAddress(portableIp.getAddress());
+        Long accountId =  portableIp.getAllocatedInDomainId();
+        if (accountId != null) {
+            Account account = ApiDBUtils.findAccountById(accountId);
+            response.setAllocatedToAccountId(account.getAccountName());
+            Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
+            response.setAllocatedInDomainId(domain.getUuid());
+        }
+
+        response.setAllocatedTime(portableIp.getAllocatedTime());
+
+        if (portableIp.getAssociatedDataCenterId() != null) {
+            DataCenter zone = ApiDBUtils.findZoneById(portableIp.getAssociatedDataCenterId());
+            if (zone != null) {
+                response.setAssociatedDataCenterId(zone.getUuid());
+            }
+        }
+
+        if (portableIp.getPhysicalNetworkId() != null) {
+            PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(portableIp.getPhysicalNetworkId());
+            if (pnw != null) {
+                response.setPhysicalNetworkId(pnw.getUuid());
+            }
+        }
+
+        if (portableIp.getAssociatedWithNetworkId() != null) {
+            Network ntwk = ApiDBUtils.findNetworkById(portableIp.getAssociatedWithNetworkId());
+            if (ntwk != null) {
+                response.setAssociatedWithNetworkId(ntwk.getUuid());
+            }
+        }
+
+        if (portableIp.getAssociatedWithVpcId() != null) {
+            Vpc vpc = ApiDBUtils.findVpcById(portableIp.getAssociatedWithVpcId());
+            if (vpc != null) {
+                response.setAssociatedWithVpcId(vpc.getUuid());
+            }
+        }
+
+        response.setState(portableIp.getState().name());
+        return response;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf3cb274/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 520a3ed..daaf596 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -4391,6 +4391,17 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
         return _portableIpRangeDao.listAll();
     }
 
+    @Override
+    public List<? extends PortableIp> listPortableIps(long id) {
+
+        PortableIpRangeVO portableIpRange = _portableIpRangeDao.findById(id);
+        if (portableIpRange == null) {
+            throw new InvalidParameterValueException("Please specify a valid portable IP
range id.");
+        }
+
+        return _portableIpDao.listByRangeId(portableIpRange.getId());
+    }
+
     private boolean checkOverlapPortableIpRange(int regionId, String newStartIpStr, String
newEndIpStr) {
         long newStartIp = NetUtils.ip2Long(newStartIpStr);
         long newEndIp = NetUtils.ip2Long(newEndIpStr);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf3cb274/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
index 81aec37..d00062c 100755
--- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
@@ -50,6 +50,7 @@ import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
 import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
 import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
 import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
+import org.apache.cloudstack.region.PortableIp;
 import org.apache.cloudstack.region.PortableIpRange;
 import org.springframework.stereotype.Component;
 
@@ -394,7 +395,7 @@ public class MockConfigurationManagerImpl extends ManagerBase implements
Configu
 
     @Override
     public boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd) {
-        return false;
+        return false;// TODO Auto-generated method stub
     }
 
     @Override
@@ -402,6 +403,11 @@ public class MockConfigurationManagerImpl extends ManagerBase implements
Configu
         return null;// TODO Auto-generated method stub
     }
 
+    @Override
+    public List<? extends PortableIp> listPortableIps(long id) {
+        return null;// TODO Auto-generated method stub
+    }
+
     /* (non-Javadoc)
      * @see com.cloud.utils.component.Manager#configure(java.lang.String, java.util.Map)
      */


Mime
View raw message