Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -41,6 +41,7 @@
import org.apache.cloudstack.api.response.SecurityGroupResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.TemplateResponse;
import org.apache.cloudstack.api.response.UserDataResponse;
import org.apache.cloudstack.api.response.UserResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.VpcResponse;
Expand Down Expand Up @@ -151,6 +152,9 @@ public class ListVMsCmd extends BaseListRetrieveOnlyResourceCountCmd implements
@Parameter(name = ApiConstants.USER_DATA, type = CommandType.BOOLEAN, description = "Whether to return the VMs' user data or not. By default, user data will not be returned.", since = "4.18.0.0")
private Boolean showUserData;

@Parameter(name = ApiConstants.USER_DATA_ID, type = CommandType.UUID, entityType = UserDataResponse.class, required = false, description = "the instances by userdata")
Comment thread
Pearl1594 marked this conversation as resolved.
Outdated
private Long userdataId;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -245,6 +249,10 @@ protected boolean isViewDetailsEmpty() {
return CollectionUtils.isEmpty(viewDetails);
}

public Long getUserdataId() {
return userdataId;
}

public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
if (isViewDetailsEmpty()) {
if (_queryService.ReturnVmStatsOnVmList.value()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,7 @@ private Pair<List<Long>, Integer> searchForUserVMIdsAndCount(ListVMsCmd cmd) {
Long storageId = null;
StoragePoolVO pool = null;
Long userId = cmd.getUserId();
Long userdataId = cmd.getUserdataId();
Map<String, String> tags = cmd.getTags();

boolean isAdmin = false;
Expand Down Expand Up @@ -1339,6 +1340,10 @@ private Pair<List<Long>, Integer> searchForUserVMIdsAndCount(ListVMsCmd cmd) {
userVmSearchBuilder.and("templateId", userVmSearchBuilder.entity().getTemplateId(), Op.EQ);
}

if (userdataId != null) {
userVmSearchBuilder.and("userdataId", userVmSearchBuilder.entity().getUserDataId(), Op.EQ);
}

if (hypervisor != null) {
userVmSearchBuilder.and("hypervisorType", userVmSearchBuilder.entity().getHypervisorType(), Op.EQ);
}
Expand Down Expand Up @@ -1531,6 +1536,10 @@ private Pair<List<Long>, Integer> searchForUserVMIdsAndCount(ListVMsCmd cmd) {
userVmSearchCriteria.setParameters("templateId", templateId);
}

if (userdataId != null) {
userVmSearchCriteria.setParameters("userdataId", userdataId);
}

if (display != null) {
userVmSearchCriteria.setParameters("display", display);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/config/section/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ export default {
related: [{
name: 'vm',
title: 'label.instances',
param: 'userdata'
param: 'userdataid'
}],
tabs: [
{
Expand Down