From a01aad84ed2f7a4dabffaad680a79efc20dd2f12 Mon Sep 17 00:00:00 2001 From: alena Date: Mon, 15 Nov 2010 10:48:03 -0800 Subject: [PATCH] bug 7162: added search by id to listZones command status 7162: resolved fixed --- .../src/com/cloud/api/commands/ListZonesByCmd.java | 6 ++++++ .../src/com/cloud/server/ManagementServerImpl.java | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/api/commands/ListZonesByCmd.java b/server/src/com/cloud/api/commands/ListZonesByCmd.java index e0d1a4086ab..ebba4d5bb4e 100644 --- a/server/src/com/cloud/api/commands/ListZonesByCmd.java +++ b/server/src/com/cloud/api/commands/ListZonesByCmd.java @@ -47,6 +47,8 @@ public class ListZonesByCmd extends BaseListCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the zone") + private Long id; @Parameter(name=ApiConstants.AVAILABLE, type=CommandType.BOOLEAN, description="true if you want to retrieve all available Zones. False if you only want to return the Zones from which you have at least one VM. Default is false.") private Boolean available; @@ -56,6 +58,10 @@ public class ListZonesByCmd extends BaseListCmd { ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + + public Long getId() { + return id; + } public Boolean isAvailable() { return available; diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index d3f60472463..9af932208bc 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -1328,6 +1328,7 @@ public class ManagementServerImpl implements ManagementServer { Account account = UserContext.current().getAccount(); List dcs = null; Long domainId = cmd.getDomainId(); + Long id = cmd.getId(); if(domainId != null){ //for domainId != null //right now, we made the decision to only list zones associated with this domain @@ -1404,7 +1405,17 @@ public class ManagementServerImpl implements ManagementServer { } } } - + + if (id != null) { + for (DataCenterVO zone : dcs) { + List singleZone = new ArrayList(); + if (zone.getId() == id) { + singleZone.add(zone); + } + return singleZone; + } + } + return dcs; }