Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public class ListHostsCmd extends BaseListCmd {
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING, description = "CPU Arch of the host", since = "4.20.1")
private String arch;

@Parameter(name = ApiConstants.VERSION, type = CommandType.STRING, description = "the host version", since = "4.20.3")
private String version;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -197,6 +200,10 @@ public CPU.CPUArch getArch() {
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
}

public String getVersion() {
return version;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public class ListMgmtsCmd extends BaseListCmd {
since = "4.20.1.0")
private Boolean peers;

@Parameter(name = ApiConstants.VERSION, type = CommandType.STRING,
description = "the version of the management server", since = "4.20.3")
private String version;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand All @@ -61,6 +65,10 @@ public Boolean getPeers() {
return BooleanUtils.toBooleanDefaultIfNull(peers, false);
}

public String getVersion() {
return version;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
10 changes: 10 additions & 0 deletions server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2309,6 +2309,7 @@ public Pair<List<Long>, Integer> searchForServerIdsAndCount(ListHostsCmd cmd) {
Long pageSize = cmd.getPageSizeVal();
Hypervisor.HypervisorType hypervisorType = cmd.getHypervisor();
final CPU.CPUArch arch = cmd.getArch();
String version = cmd.getVersion();

Filter searchFilter = new Filter(HostVO.class, "id", Boolean.TRUE, startIndex, pageSize);

Expand All @@ -2325,6 +2326,7 @@ public Pair<List<Long>, Integer> searchForServerIdsAndCount(ListHostsCmd cmd) {
hostSearchBuilder.and("resourceState", hostSearchBuilder.entity().getResourceState(), SearchCriteria.Op.EQ);
hostSearchBuilder.and("hypervisor_type", hostSearchBuilder.entity().getHypervisorType(), SearchCriteria.Op.EQ);
hostSearchBuilder.and("arch", hostSearchBuilder.entity().getArch(), SearchCriteria.Op.EQ);
hostSearchBuilder.and("version", hostSearchBuilder.entity().getVersion(), SearchCriteria.Op.EQ);

if (keyword != null) {
hostSearchBuilder.and().op("keywordName", hostSearchBuilder.entity().getName(), SearchCriteria.Op.LIKE);
Expand Down Expand Up @@ -2409,6 +2411,10 @@ public Pair<List<Long>, Integer> searchForServerIdsAndCount(ListHostsCmd cmd) {
sc.setParameters("arch", arch);
}

if (version != null) {
sc.setParameters("version", version);
}

Pair<List<HostVO>, Integer> uniqueHostPair = hostDao.searchAndCount(sc, searchFilter);
Integer count = uniqueHostPair.second();
List<Long> hostIds = uniqueHostPair.first().stream().map(HostVO::getId).collect(Collectors.toList());
Expand Down Expand Up @@ -5397,6 +5403,7 @@ public ListResponse<ManagementServerResponse> listManagementServers(ListMgmtsCmd
protected Pair<List<ManagementServerJoinVO>, Integer> listManagementServersInternal(ListMgmtsCmd cmd) {
Long id = cmd.getId();
String name = cmd.getHostName();
String version = cmd.getVersion();

SearchBuilder<ManagementServerJoinVO> sb = managementServerJoinDao.createSearchBuilder();
SearchCriteria<ManagementServerJoinVO> sc = sb.create();
Expand All @@ -5406,6 +5413,9 @@ protected Pair<List<ManagementServerJoinVO>, Integer> listManagementServersInter
if (name != null) {
sc.addAnd("name", SearchCriteria.Op.EQ, name);
}
if (version != null) {
sc.addAnd("version", SearchCriteria.Op.EQ, version);
}
return managementServerJoinDao.searchAndCount(sc, null);
}

Expand Down