Repository: cloudstack
Updated Branches:
  refs/heads/master 3433eb7c0 -> 07f916dfc


CLOUDSTACK-7159 Added "state" parameter to the "listPublicIpAddresses" API call

Signed-off-by: Ilia Shakitko <i.shaki...@tech.leaseweb.com>
Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com>


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

Branch: refs/heads/master
Commit: 07f916dfc6fb30dc928b258beeaa761253e43ab9
Parents: 3433eb7
Author: Ilia Shakitko <i.shaki...@tech.leaseweb.com>
Authored: Tue Aug 5 17:58:46 2014 +0200
Committer: Rohit Yadav <rohit.ya...@shapeblue.com>
Committed: Tue Aug 5 18:13:38 2014 +0200

----------------------------------------------------------------------
 .../user/address/ListPublicIpAddressesCmd.java  | 35 +++++++++++---------
 .../com/cloud/server/ManagementServerImpl.java  | 10 ++++++
 2 files changed, 29 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07f916df/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java
 
b/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java
index 07ccfe9..5720a50 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java
@@ -53,6 +53,9 @@ public class ListPublicIpAddressesCmd extends 
BaseListTaggedResourcesCmd {
     @Parameter(name = ApiConstants.ALLOCATED_ONLY, type = CommandType.BOOLEAN, 
description = "limits search results to allocated public IP addresses")
     private Boolean allocatedOnly;
 
+    @Parameter(name = ApiConstants.STATE, type = CommandType.STRING, 
description = "lists all public IP addresses by state")
+    private String state;
+
     @Parameter(name = ApiConstants.FOR_VIRTUAL_NETWORK, type = 
CommandType.BOOLEAN, description = "the virtual network for the IP address")
     private Boolean forVirtualNetwork;
 
@@ -150,6 +153,22 @@ public class ListPublicIpAddressesCmd extends 
BaseListTaggedResourcesCmd {
         return super.getDisplay();
     }
 
+    public Boolean isForLoadBalancing() {
+        return forLoadBalancing;
+    }
+
+    public Boolean getForVirtualNetwork() {
+        return forVirtualNetwork;
+    }
+
+    public Boolean getForLoadBalancing() {
+        return forLoadBalancing;
+    }
+
+    public String getState() {
+        return state;
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////
@@ -178,20 +197,4 @@ public class ListPublicIpAddressesCmd extends 
BaseListTaggedResourcesCmd {
     public ApiCommandJobType getInstanceType() {
         return ApiCommandJobType.IpAddress;
     }
-
-    public Boolean isForLoadBalancing() {
-        return forLoadBalancing;
-    }
-
-    public Boolean getAllocatedOnly() {
-        return allocatedOnly;
-    }
-
-    public Boolean getForVirtualNetwork() {
-        return forVirtualNetwork;
-    }
-
-    public Boolean getForLoadBalancing() {
-        return forLoadBalancing;
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07f916df/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java 
b/server/src/com/cloud/server/ManagementServerImpl.java
index 1413272..7b5422e 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -1730,9 +1730,14 @@ public class ManagementServerImpl extends ManagerBase 
implements ManagementServe
         Boolean forDisplay = cmd.getDisplay();
         Map<String, String> tags = cmd.getTags();
 
+        String state = cmd.getState();
         Boolean isAllocated = cmd.isAllocatedOnly();
         if (isAllocated == null) {
             isAllocated = Boolean.TRUE;
+
+            if (state != null) {
+                isAllocated = Boolean.FALSE;
+            }
         }
 
         Filter searchFilter = new Filter(IPAddressVO.class, "address", false, 
cmd.getStartIndex(), cmd.getPageSizeVal());
@@ -1763,6 +1768,7 @@ public class ManagementServerImpl extends ManagerBase 
implements ManagementServe
         sb.and("isSourceNat", sb.entity().isSourceNat(), SearchCriteria.Op.EQ);
         sb.and("isStaticNat", sb.entity().isOneToOneNat(), 
SearchCriteria.Op.EQ);
         sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
+        sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
         sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ);
 
         if (forLoadBalancing != null && forLoadBalancing) {
@@ -1865,6 +1871,10 @@ public class ManagementServerImpl extends ManagerBase 
implements ManagementServe
             sc.setParameters("display", forDisplay);
         }
 
+        if (state != null) {
+            sc.setParameters("state", state);
+        }
+
         Pair<List<IPAddressVO>, Integer> result = 
_publicIpAddressDao.searchAndCount(sc, searchFilter);
         return new Pair<List<? extends IpAddress>, Integer>(result.first(), 
result.second());
     }

Reply via email to