incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [3/30] git commit: listVirtualMachines: implemented search by templateId/isoId
Date Fri, 03 Aug 2012 01:54:13 GMT
listVirtualMachines: implemented search by templateId/isoId

Conflicts:

	api/src/com/cloud/api/ApiConstants.java
	api/src/com/cloud/api/commands/ListVMsCmd.java


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/befd6dd0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/befd6dd0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/befd6dd0

Branch: refs/heads/master
Commit: befd6dd0c65c55b758c030d7482fd51a60e1f3e4
Parents: c35153c
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Thu Aug 2 15:20:38 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Thu Aug 2 18:15:13 2012 -0700

----------------------------------------------------------------------
 api/src/com/cloud/api/ApiConstants.java        |    2 ++
 api/src/com/cloud/api/commands/ListVMsCmd.java |   17 ++++++++++++++++-
 server/src/com/cloud/server/Criteria.java      |    2 ++
 server/src/com/cloud/vm/UserVmManagerImpl.java |   14 ++++++++++++++
 4 files changed, 34 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/befd6dd0/api/src/com/cloud/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java
index e410576..08b9465 100755
--- a/api/src/com/cloud/api/ApiConstants.java
+++ b/api/src/com/cloud/api/ApiConstants.java
@@ -183,6 +183,7 @@ public class ApiConstants {
     public static final String TARGET_IQN = "targetiqn";
     public static final String TEMPLATE_FILTER = "templatefilter";
     public static final String TEMPLATE_ID = "templateid";
+    public static final String ISO_ID = "isoid";
     public static final String TIMEOUT = "timeout";
     public static final String TIMEZONE = "timezone";
     public static final String TYPE = "type";
@@ -364,6 +365,7 @@ public class ApiConstants {
     public static final String NICIRA_NVP_DEVICE_ID = "nvpdeviceid";
     public static final String NICIRA_NVP_TRANSPORT_ZONE_UUID = "transportzoneuuid";
     public static final String NICIRA_NVP_DEVICE_NAME = "niciradevicename";
+    
 
     
     public enum HostDetails {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/befd6dd0/api/src/com/cloud/api/commands/ListVMsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVMsCmd.java b/api/src/com/cloud/api/commands/ListVMsCmd.java
index acc459b..f8b694a 100755
--- a/api/src/com/cloud/api/commands/ListVMsCmd.java
+++ b/api/src/com/cloud/api/commands/ListVMsCmd.java
@@ -87,7 +87,14 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
     @Parameter(name=ApiConstants.DETAILS, type=CommandType.LIST, collectionType=CommandType.STRING,
description="comma separated list of host details requested, " +
     		"value can be a list of [all, group, nics, stats, secgrp, tmpl, servoff, iso, volume,
min]. If no parameter is passed in, the details will be defaulted to all" )
     private List<String> viewDetails; 
-   
+
+    @IdentityMapper(entityTableName="vm_template")
+    @Parameter(name=ApiConstants.TEMPLATE_ID, type=CommandType.LONG, description="list vms
by template")
+    private Long templateId;
+    
+    @IdentityMapper(entityTableName="vm_template")
+    @Parameter(name=ApiConstants.ISO_ID, type=CommandType.LONG, description="list vms by
iso")
+    private Long isoId;
 
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
@@ -140,7 +147,15 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
     public Long getStorageId() {
         return storageId;
     }
+
+    public Long getTemplateId() {
+        return templateId;
+    }
     
+    public Long getIsoId() {
+        return isoId;
+    }
+
     public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
         EnumSet<VMDetails> dv;
         if (viewDetails==null || viewDetails.size() <=0){

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/befd6dd0/server/src/com/cloud/server/Criteria.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/Criteria.java b/server/src/com/cloud/server/Criteria.java
index 95a1539..3a1f740 100755
--- a/server/src/com/cloud/server/Criteria.java
+++ b/server/src/com/cloud/server/Criteria.java
@@ -79,6 +79,8 @@ public class Criteria {
     public static final String NETWORKID = "networkId";
     public static final String HYPERVISOR = "hypervisor";
     public static final String STORAGE_ID="storageid";
+    public static final String TEMPLATE_ID = "templateid";
+    public static final String ISO_ID = "isoid";
 
 	public Criteria(String orderBy, Boolean ascending, Long offset, Long limit) {
 		this.offset = offset;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/befd6dd0/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index fa988af..c514a98 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -2931,6 +2931,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
         c.addCriteria(Criteria.GROUPID, cmd.getGroupId());
         c.addCriteria(Criteria.FOR_VIRTUAL_NETWORK, cmd.getForVirtualNetwork());
         c.addCriteria(Criteria.NETWORKID, cmd.getNetworkId());
+        c.addCriteria(Criteria.TEMPLATE_ID, cmd.getTemplateId());
+        c.addCriteria(Criteria.ISO_ID, cmd.getIsoId());
 
         if (domainId != null) {
             c.addCriteria(Criteria.DOMAINID, domainId);
@@ -2980,6 +2982,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
         Object networkId = c.getCriteria(Criteria.NETWORKID);
         Object hypervisor = c.getCriteria(Criteria.HYPERVISOR);
         Object storageId = c.getCriteria(Criteria.STORAGE_ID);
+        Object templateId = c.getCriteria(Criteria.TEMPLATE_ID);
+        Object isoId = c.getCriteria(Criteria.ISO_ID);
 
         sb.and("displayName", sb.entity().getDisplayName(), SearchCriteria.Op.LIKE);
         sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
@@ -2992,6 +2996,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
         sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ);
         sb.and("hostIdEQ", sb.entity().getHostId(), SearchCriteria.Op.EQ);
         sb.and("hostIdIN", sb.entity().getHostId(), SearchCriteria.Op.IN);
+        sb.and("templateId", sb.entity().getTemplateId(), SearchCriteria.Op.EQ);
+        sb.and("isoId", sb.entity().getTemplateId(), SearchCriteria.Op.EQ);
 
         if (groupId != null && (Long) groupId == -1) {
             SearchBuilder<InstanceGroupVMMapVO> vmSearch = _groupVMMapDao.createSearchBuilder();
@@ -3065,6 +3071,14 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
         if (id != null) {
             sc.setParameters("id", id);
         }
+        
+        if (templateId != null) {
+            sc.setParameters("templateId", templateId);
+        }
+        
+        if (isoId != null) {
+            sc.setParameters("isoId", isoId);
+        }
 
         if (networkId != null) {
             sc.setJoinParameters("nicSearch", "networkId", networkId);


Mime
View raw message