mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Adding affinitygroupid search parameter to listVMsCmd
This commit is contained in:
parent
fc08c2372c
commit
ff4a4876c7
@ -479,6 +479,7 @@ public class ApiConstants {
|
||||
public static final String AFFINITY_GROUP_IDS = "affinitygroupids";
|
||||
public static final String AFFINITY_GROUP_NAMES = "affinitygroupnames";
|
||||
public static final String ASA_INSIDE_PORT_PROFILE = "insideportprofile";
|
||||
public static final String AFFINITY_GROUP_ID = "affinitygroupid";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
||||
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||
@ -110,6 +111,10 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.UUID, entityType=VpcResponse.class,
|
||||
description="list vms by vpc")
|
||||
private Long vpcId;
|
||||
|
||||
@Parameter(name = ApiConstants.AFFINITY_GROUP_ID, type = CommandType.UUID, entityType = AffinityGroupResponse.class, description = "list vms by affinity group")
|
||||
private Long affinityGroupId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -174,6 +179,10 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
public Long getAffinityGroupId() {
|
||||
return affinityGroupId;
|
||||
}
|
||||
|
||||
public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
|
||||
EnumSet<VMDetails> dv;
|
||||
if (viewDetails==null || viewDetails.size() <=0){
|
||||
|
||||
@ -638,6 +638,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
||||
c.addCriteria(Criteria.TEMPLATE_ID, cmd.getTemplateId());
|
||||
c.addCriteria(Criteria.ISO_ID, cmd.getIsoId());
|
||||
c.addCriteria(Criteria.VPC_ID, cmd.getVpcId());
|
||||
c.addCriteria(Criteria.AFFINITY_GROUP_ID, cmd.getAffinityGroupId());
|
||||
|
||||
if (domainId != null) {
|
||||
c.addCriteria(Criteria.DOMAINID, domainId);
|
||||
@ -693,6 +694,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
||||
Object templateId = c.getCriteria(Criteria.TEMPLATE_ID);
|
||||
Object isoId = c.getCriteria(Criteria.ISO_ID);
|
||||
Object vpcId = c.getCriteria(Criteria.VPC_ID);
|
||||
Object affinityGroupId = c.getCriteria(Criteria.AFFINITY_GROUP_ID);
|
||||
|
||||
sb.and("displayName", sb.entity().getDisplayName(), SearchCriteria.Op.LIKE);
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
@ -733,6 +735,10 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
||||
sb.and("poolId", sb.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||
}
|
||||
|
||||
if (affinityGroupId != null) {
|
||||
sb.and("affinityGroupId", sb.entity().getAffinityGroupId(), SearchCriteria.Op.EQ);
|
||||
}
|
||||
|
||||
// populate the search criteria with the values passed in
|
||||
SearchCriteria<UserVmJoinVO> sc = sb.create();
|
||||
|
||||
@ -830,6 +836,10 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
||||
sc.setParameters("poolId", storageId);
|
||||
}
|
||||
|
||||
if (affinityGroupId != null) {
|
||||
sc.setParameters("affinityGroupId", affinityGroupId);
|
||||
}
|
||||
|
||||
// search vm details by ids
|
||||
Pair<List<UserVmJoinVO>, Integer> uniqueVmPair = _userVmJoinDao.searchAndCount(sc, searchFilter);
|
||||
Integer count = uniqueVmPair.second();
|
||||
@ -1976,14 +1986,14 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
||||
domainRecord = _domainDao.findById(domainRecord.getParent());
|
||||
domainIds.add(domainRecord.getId());
|
||||
}
|
||||
|
||||
|
||||
SearchCriteria<DiskOfferingJoinVO> spc = _diskOfferingJoinDao.createSearchCriteria();
|
||||
|
||||
spc.addOr("domainId", SearchCriteria.Op.IN, domainIds.toArray());
|
||||
spc.addOr("domainId", SearchCriteria.Op.NULL); // include public offering as where
|
||||
sc.addAnd("domainId", SearchCriteria.Op.SC, spc);
|
||||
sc.addAnd("systemUse", SearchCriteria.Op.EQ, false); // non-root users should not see system offering at all
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
@ -2001,7 +2011,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
||||
if (name != null) {
|
||||
sc.addAnd("name", SearchCriteria.Op.EQ, name);
|
||||
}
|
||||
|
||||
|
||||
// FIXME: disk offerings should search back up the hierarchy for
|
||||
// available disk offerings...
|
||||
/*
|
||||
@ -2081,7 +2091,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
||||
// boolean includePublicOfferings = false;
|
||||
if ((caller.getType() == Account.ACCOUNT_TYPE_NORMAL || caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)
|
||||
|| caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
|
||||
// For non-root users.
|
||||
// For non-root users.
|
||||
if (isSystem) {
|
||||
throw new InvalidParameterValueException("Only root admins can access system's offering");
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ package com.cloud.server;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Criteria {
|
||||
|
||||
|
||||
private Long offset;
|
||||
private Long limit;
|
||||
private String orderBy;
|
||||
@ -82,6 +82,7 @@ public class Criteria {
|
||||
public static final String TEMPLATE_ID = "templateid";
|
||||
public static final String ISO_ID = "isoid";
|
||||
public static final String VPC_ID = "vpcId";
|
||||
public static final String AFFINITY_GROUP_ID = "affinitygroupid";
|
||||
|
||||
public Criteria(String orderBy, Boolean ascending, Long offset, Long limit) {
|
||||
this.offset = offset;
|
||||
@ -90,7 +91,7 @@ public class Criteria {
|
||||
this.ascending = ascending;
|
||||
criteria = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
|
||||
public Criteria() {
|
||||
criteria = new HashMap<String, Object>();
|
||||
this.ascending = false;
|
||||
@ -99,11 +100,11 @@ public class Criteria {
|
||||
public Long getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
public void addCriteria(String name, Object val) {
|
||||
criteria.put(name, val);
|
||||
}
|
||||
|
||||
|
||||
public Object getCriteria(String name) {
|
||||
return criteria.get(name);
|
||||
}
|
||||
@ -135,5 +136,5 @@ public class Criteria {
|
||||
public void setAscending(Boolean ascending) {
|
||||
this.ascending = ascending;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user