Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 23CC5FCC0 for ; Sat, 11 May 2013 10:41:25 +0000 (UTC) Received: (qmail 85323 invoked by uid 500); 11 May 2013 10:41:25 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 85123 invoked by uid 500); 11 May 2013 10:41:21 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 85098 invoked by uid 99); 11 May 2013 10:41:20 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 May 2013 10:41:20 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id DDCCE88C1DA; Sat, 11 May 2013 10:41:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: muralireddy@apache.org To: commits@cloudstack.apache.org Message-Id: <13ce565173b0475a9fe978ee3f098d96@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/portablepublicip to bf3cb27 Date: Sat, 11 May 2013 10:41:19 +0000 (UTC) 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 Authored: Sat May 11 16:08:40 2013 +0530 Committer: Murali Reddy 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 listPortableIpRanges(ListPortableIpRangesCmd cmd); + + List 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 portableIps = _configService.listPortableIps(range.getId()); + if (portableIps != null && !portableIps.isEmpty()) { + List portableIpResponses = new ArrayList(); + 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 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 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 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 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) */