Skip to content

Commit 774b2eb

Browse files
author
Jessica Wang
committed
CLOUDSTACK-2120: mixed zone management - API: extend listSystemVMs API to to take in zonetype.
1 parent 45dbd9c commit 774b2eb

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public class ListSystemVMsCmd extends BaseListCmd {
7474
description="the storage ID where vm's volumes belong to", since="3.0.1")
7575
private Long storageId;
7676

77+
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
78+
private String zoneType;
79+
7780
/////////////////////////////////////////////////////
7881
/////////////////// Accessors ///////////////////////
7982
/////////////////////////////////////////////////////
@@ -110,6 +113,10 @@ public Long getStorageId() {
110113
return storageId;
111114
}
112115

116+
public String getZoneType() {
117+
return zoneType;
118+
}
119+
113120
/////////////////////////////////////////////////////
114121
/////////////// API Implementation///////////////////
115122
/////////////////////////////////////////////////////

server/src/com/cloud/server/ManagementServerImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,6 +2640,7 @@ public SecondaryStorageVmVO destroySecondaryStorageVm(long instanceId) {
26402640
public Pair<List<? extends VirtualMachine>, Integer> searchForSystemVm(ListSystemVMsCmd cmd) {
26412641
String type = cmd.getSystemVmType();
26422642
Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId());
2643+
String zoneType = cmd.getZoneType();
26432644
Long id = cmd.getId();
26442645
String name = cmd.getSystemVmName();
26452646
String state = cmd.getState();
@@ -2666,6 +2667,12 @@ public Pair<List<? extends VirtualMachine>, Integer> searchForSystemVm(ListSyste
26662667
sb.join("volumeSearch", volumeSearch, sb.entity().getId(), volumeSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
26672668
}
26682669

2670+
if(zoneType != null) {
2671+
SearchBuilder<DataCenterVO> zoneSb = _dcDao.createSearchBuilder();
2672+
zoneSb.and("zoneNetworkType", zoneSb.entity().getNetworkType(), SearchCriteria.Op.EQ);
2673+
sb.join("zoneSb", zoneSb, sb.entity().getDataCenterId(), zoneSb.entity().getId(), JoinBuilder.JoinType.INNER);
2674+
}
2675+
26692676
SearchCriteria<VMInstanceVO> sc = sb.create();
26702677

26712678
if (keyword != null) {
@@ -2706,6 +2713,10 @@ public Pair<List<? extends VirtualMachine>, Integer> searchForSystemVm(ListSyste
27062713
sc.setJoinParameters("volumeSearch", "poolId", storageId);
27072714
}
27082715

2716+
if(zoneType != null) {
2717+
sc.setJoinParameters("zoneSb", "zoneNetworkType", zoneType);
2718+
}
2719+
27092720
Pair<List<VMInstanceVO>, Integer> result = _vmInstanceDao.searchAndCount(sc, searchFilter);
27102721
return new Pair<List<? extends VirtualMachine>, Integer>(result.first(), result.second());
27112722
}

0 commit comments

Comments
 (0)