mirror of https://github.com/apache/cloudstack.git
List only VMs associated to a userdata (#10569)
* List only VMs associated to a userdata * add since param
This commit is contained in:
parent
35e809e7ce
commit
02d0dca24b
|
|
@ -41,6 +41,7 @@ import org.apache.cloudstack.api.response.ResourceIconResponse;
|
|||
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;
|
||||
|
|
@ -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", since = "4.20.1")
|
||||
private Long userdataId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -245,6 +249,10 @@ public class ListVMsCmd extends BaseListRetrieveOnlyResourceCountCmd implements
|
|||
return CollectionUtils.isEmpty(viewDetails);
|
||||
}
|
||||
|
||||
public Long getUserdataId() {
|
||||
return userdataId;
|
||||
}
|
||||
|
||||
public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
|
||||
if (isViewDetailsEmpty()) {
|
||||
if (_queryService.ReturnVmStatsOnVmList.value()) {
|
||||
|
|
|
|||
|
|
@ -1267,6 +1267,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||
Long storageId = null;
|
||||
StoragePoolVO pool = null;
|
||||
Long userId = cmd.getUserId();
|
||||
Long userdataId = cmd.getUserdataId();
|
||||
Map<String, String> tags = cmd.getTags();
|
||||
|
||||
boolean isAdmin = false;
|
||||
|
|
@ -1339,6 +1340,10 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||
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);
|
||||
}
|
||||
|
|
@ -1531,6 +1536,10 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||
userVmSearchCriteria.setParameters("templateId", templateId);
|
||||
}
|
||||
|
||||
if (userdataId != null) {
|
||||
userVmSearchCriteria.setParameters("userdataId", userdataId);
|
||||
}
|
||||
|
||||
if (display != null) {
|
||||
userVmSearchCriteria.setParameters("display", display);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -919,7 +919,7 @@ export default {
|
|||
related: [{
|
||||
name: 'vm',
|
||||
title: 'label.instances',
|
||||
param: 'userdata'
|
||||
param: 'userdataid'
|
||||
}],
|
||||
tabs: [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue