This is an automated email from the ASF dual-hosted git repository.

pearl11594 pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.19 by this push:
     new 02d0dca24b2 List only VMs associated to a userdata (#10569)
02d0dca24b2 is described below

commit 02d0dca24b2cac976a6deef181a4774368b4005f
Author: Pearl Dsilva <pearl1...@gmail.com>
AuthorDate: Mon Mar 17 17:14:57 2025 -0400

    List only VMs associated to a userdata (#10569)
    
    * List only VMs associated to a userdata
    
    * add since param
---
 .../org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java    | 8 ++++++++
 server/src/main/java/com/cloud/api/query/QueryManagerImpl.java   | 9 +++++++++
 ui/src/config/section/compute.js                                 | 2 +-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java 
b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java
index 37b702e166a..a6c5bafbd51 100644
--- 
a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java
+++ 
b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java
@@ -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()) {
diff --git a/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java 
b/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
index 16cbd5ebe1b..0e99af41338 100644
--- a/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
@@ -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);
         }
diff --git a/ui/src/config/section/compute.js b/ui/src/config/section/compute.js
index ba7b3d75eb8..0d5c8de6628 100644
--- a/ui/src/config/section/compute.js
+++ b/ui/src/config/section/compute.js
@@ -919,7 +919,7 @@ export default {
       related: [{
         name: 'vm',
         title: 'label.instances',
-        param: 'userdata'
+        param: 'userdataid'
       }],
       tabs: [
         {

Reply via email to