mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
listVirtualMachines: implemented search by templateId/isoId
Conflicts: api/src/com/cloud/api/ApiConstants.java api/src/com/cloud/api/commands/ListVMsCmd.java
This commit is contained in:
parent
c35153cefd
commit
befd6dd0c6
@ -183,6 +183,7 @@ public class ApiConstants {
|
|||||||
public static final String TARGET_IQN = "targetiqn";
|
public static final String TARGET_IQN = "targetiqn";
|
||||||
public static final String TEMPLATE_FILTER = "templatefilter";
|
public static final String TEMPLATE_FILTER = "templatefilter";
|
||||||
public static final String TEMPLATE_ID = "templateid";
|
public static final String TEMPLATE_ID = "templateid";
|
||||||
|
public static final String ISO_ID = "isoid";
|
||||||
public static final String TIMEOUT = "timeout";
|
public static final String TIMEOUT = "timeout";
|
||||||
public static final String TIMEZONE = "timezone";
|
public static final String TIMEZONE = "timezone";
|
||||||
public static final String TYPE = "type";
|
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_DEVICE_ID = "nvpdeviceid";
|
||||||
public static final String NICIRA_NVP_TRANSPORT_ZONE_UUID = "transportzoneuuid";
|
public static final String NICIRA_NVP_TRANSPORT_ZONE_UUID = "transportzoneuuid";
|
||||||
public static final String NICIRA_NVP_DEVICE_NAME = "niciradevicename";
|
public static final String NICIRA_NVP_DEVICE_NAME = "niciradevicename";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public enum HostDetails {
|
public enum HostDetails {
|
||||||
|
|||||||
@ -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, " +
|
@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" )
|
"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;
|
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 ///////////////////////
|
/////////////////// Accessors ///////////////////////
|
||||||
@ -140,7 +147,15 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
|
|||||||
public Long getStorageId() {
|
public Long getStorageId() {
|
||||||
return storageId;
|
return storageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getTemplateId() {
|
||||||
|
return templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getIsoId() {
|
||||||
|
return isoId;
|
||||||
|
}
|
||||||
|
|
||||||
public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
|
public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
|
||||||
EnumSet<VMDetails> dv;
|
EnumSet<VMDetails> dv;
|
||||||
if (viewDetails==null || viewDetails.size() <=0){
|
if (viewDetails==null || viewDetails.size() <=0){
|
||||||
|
|||||||
@ -79,6 +79,8 @@ public class Criteria {
|
|||||||
public static final String NETWORKID = "networkId";
|
public static final String NETWORKID = "networkId";
|
||||||
public static final String HYPERVISOR = "hypervisor";
|
public static final String HYPERVISOR = "hypervisor";
|
||||||
public static final String STORAGE_ID="storageid";
|
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) {
|
public Criteria(String orderBy, Boolean ascending, Long offset, Long limit) {
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
|
|||||||
@ -2931,6 +2931,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
c.addCriteria(Criteria.GROUPID, cmd.getGroupId());
|
c.addCriteria(Criteria.GROUPID, cmd.getGroupId());
|
||||||
c.addCriteria(Criteria.FOR_VIRTUAL_NETWORK, cmd.getForVirtualNetwork());
|
c.addCriteria(Criteria.FOR_VIRTUAL_NETWORK, cmd.getForVirtualNetwork());
|
||||||
c.addCriteria(Criteria.NETWORKID, cmd.getNetworkId());
|
c.addCriteria(Criteria.NETWORKID, cmd.getNetworkId());
|
||||||
|
c.addCriteria(Criteria.TEMPLATE_ID, cmd.getTemplateId());
|
||||||
|
c.addCriteria(Criteria.ISO_ID, cmd.getIsoId());
|
||||||
|
|
||||||
if (domainId != null) {
|
if (domainId != null) {
|
||||||
c.addCriteria(Criteria.DOMAINID, domainId);
|
c.addCriteria(Criteria.DOMAINID, domainId);
|
||||||
@ -2980,6 +2982,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
Object networkId = c.getCriteria(Criteria.NETWORKID);
|
Object networkId = c.getCriteria(Criteria.NETWORKID);
|
||||||
Object hypervisor = c.getCriteria(Criteria.HYPERVISOR);
|
Object hypervisor = c.getCriteria(Criteria.HYPERVISOR);
|
||||||
Object storageId = c.getCriteria(Criteria.STORAGE_ID);
|
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("displayName", sb.entity().getDisplayName(), SearchCriteria.Op.LIKE);
|
||||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
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("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ);
|
||||||
sb.and("hostIdEQ", sb.entity().getHostId(), SearchCriteria.Op.EQ);
|
sb.and("hostIdEQ", sb.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||||
sb.and("hostIdIN", sb.entity().getHostId(), SearchCriteria.Op.IN);
|
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) {
|
if (groupId != null && (Long) groupId == -1) {
|
||||||
SearchBuilder<InstanceGroupVMMapVO> vmSearch = _groupVMMapDao.createSearchBuilder();
|
SearchBuilder<InstanceGroupVMMapVO> vmSearch = _groupVMMapDao.createSearchBuilder();
|
||||||
@ -3065,6 +3071,14 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
if (id != null) {
|
if (id != null) {
|
||||||
sc.setParameters("id", id);
|
sc.setParameters("id", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (templateId != null) {
|
||||||
|
sc.setParameters("templateId", templateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isoId != null) {
|
||||||
|
sc.setParameters("isoId", isoId);
|
||||||
|
}
|
||||||
|
|
||||||
if (networkId != null) {
|
if (networkId != null) {
|
||||||
sc.setJoinParameters("nicSearch", "networkId", networkId);
|
sc.setJoinParameters("nicSearch", "networkId", networkId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user