bug 7162: added search by id to listZones command

status 7162: resolved fixed
This commit is contained in:
alena 2010-11-15 10:48:03 -08:00
parent 1cd5526911
commit a01aad84ed
2 changed files with 18 additions and 1 deletions

View File

@ -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;
@ -57,6 +59,10 @@ public class ListZonesByCmd extends BaseListCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public Boolean isAvailable() {
return available;
}

View File

@ -1328,6 +1328,7 @@ public class ManagementServerImpl implements ManagementServer {
Account account = UserContext.current().getAccount();
List<DataCenterVO> 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
@ -1405,6 +1406,16 @@ public class ManagementServerImpl implements ManagementServer {
}
}
if (id != null) {
for (DataCenterVO zone : dcs) {
List<DataCenterVO> singleZone = new ArrayList<DataCenterVO>();
if (zone.getId() == id) {
singleZone.add(zone);
}
return singleZone;
}
}
return dcs;
}