Skip to content

Commit 2fc5a3c

Browse files
David GrizzantiPrasanna Santhanam
authored andcommitted
CLOUDSTACK-420: listZones missing name parameter
When calling the listZones API command, you can now supply a name to pull a specific zone by name. Updated two classes to include name paramater and query data centers/zones by name if suppled: - server/src/com/cloud/api/query/QueryManagerImpl.java - api/src/org/apache/cloudstack/api/command/user/zone/ListZonesByCmd.java Signed-off-by: Prasanna Santhanam <tsp@apache.org>
1 parent 48ce06b commit 2fc5a3c

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎api/src/org/apache/cloudstack/api/command/user/zone/ListZonesByCmd.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public class ListZonesByCmd extends BaseListCmd {
5353
description="the ID of the domain associated with the zone")
5454
private Long domainId;
5555

56+
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the zone")
57+
private String name;
58+
5659
@Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the zones")
5760
private Boolean showCapacities;
5861

@@ -72,6 +75,10 @@ public Long getDomainId(){
7275
return domainId;
7376
}
7477

78+
public String getName(){
79+
return name;
80+
}
81+
7582
public Boolean getShowCapacities() {
7683
return showCapacities;
7784
}

‎server/src/com/cloud/api/query/QueryManagerImpl.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,12 +2190,15 @@ private Pair<List<DataCenterJoinVO>, Integer> listDataCentersInternal(ListZonesB
21902190
Long domainId = cmd.getDomainId();
21912191
Long id = cmd.getId();
21922192
String keyword = cmd.getKeyword();
2193+
String name = cmd.getName();
21932194

21942195
Filter searchFilter = new Filter(DataCenterJoinVO.class, null, false, cmd.getStartIndex(), cmd.getPageSizeVal());
21952196
SearchCriteria<DataCenterJoinVO> sc = _dcJoinDao.createSearchCriteria();
21962197

21972198
if (id != null) {
21982199
sc.addAnd("id", SearchCriteria.Op.EQ, id);
2200+
} else if (name != null) {
2201+
sc.addAnd("name", SearchCriteria.Op.EQ, name);
21992202
} else {
22002203
if (keyword != null) {
22012204
SearchCriteria<DataCenterJoinVO> ssc = _dcJoinDao.createSearchCriteria();

0 commit comments

Comments
 (0)