mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4874: rever the previous commits. Service offering details are already being returned in "serviceofferingdetails" field of the service offering response
This commit is contained in:
parent
f3e968b983
commit
e52e7a5634
|
|
@ -521,7 +521,7 @@ public class ApiConstants {
|
|||
public static final String ROUTING = "isrouting";
|
||||
public static final String MAX_CONNECTIONS = "maxconnections";
|
||||
public static final String SERVICE_STATE = "servicestate";
|
||||
public static final String RESOURCE_TAGS = "resourcetags";
|
||||
public static final String RESOURCE_DETAIL = "resourcedetail";
|
||||
public static final String EXPUNGE = "expunge";
|
||||
|
||||
public enum HostDetails {
|
||||
|
|
|
|||
|
|
@ -63,9 +63,6 @@ public class ListServiceOfferingsCmd extends BaseListCmd {
|
|||
|
||||
@Parameter(name=ApiConstants.SYSTEM_VM_TYPE, type=CommandType.STRING, description="the system VM type. Possible types are \"consoleproxy\", \"secondarystoragevm\" or \"domainrouter\".")
|
||||
private String systemVmType;
|
||||
|
||||
@Parameter(name = ApiConstants.RESOURCE_TAGS, type = CommandType.MAP, description = "List service offerings by resource tags (key/value pairs)", since="4.3")
|
||||
private Map resourceTag;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -95,25 +92,6 @@ public class ListServiceOfferingsCmd extends BaseListCmd {
|
|||
public String getSystemVmType(){
|
||||
return systemVmType;
|
||||
}
|
||||
|
||||
public Map<String, String> getResourceTags() {
|
||||
Map<String, String> tagsMap = null;
|
||||
if (resourceTag != null && !resourceTag.isEmpty()) {
|
||||
tagsMap = new HashMap<String, String>();
|
||||
Collection<?> servicesCollection = resourceTag.values();
|
||||
Iterator<?> iter = servicesCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> services = (HashMap<String, String>) iter.next();
|
||||
String key = services.get("key");
|
||||
String value = services.get("value");
|
||||
if (value == null) {
|
||||
throw new InvalidParameterValueException("No value is passed in for key " + key);
|
||||
}
|
||||
tagsMap.put(key, value);
|
||||
}
|
||||
}
|
||||
return tagsMap;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@
|
|||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
|
@ -107,13 +105,8 @@ public class ServiceOfferingResponse extends BaseResponse {
|
|||
@Param(description = "additional key/value details tied with this service offering", since = "4.2.0")
|
||||
private Map<String, String> details;
|
||||
|
||||
@SerializedName(ApiConstants.RESOURCE_TAGS) @Param(description="the list of resource tags associated with service offering." +
|
||||
" The resource tags are not used for Volume/VM placement on the specific host.",
|
||||
responseObject = ResourceTagResponse.class, since="4.3")
|
||||
private Set<ResourceTagResponse> resourceTags;
|
||||
|
||||
public ServiceOfferingResponse(){
|
||||
resourceTags = new LinkedHashSet<ResourceTagResponse>();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
|
@ -295,7 +288,4 @@ public class ServiceOfferingResponse extends BaseResponse {
|
|||
this.details = details;
|
||||
}
|
||||
|
||||
public void addTag(ResourceTagResponse tag){
|
||||
this.resourceTags.add(tag);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2390,22 +2390,8 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
|||
Long domainId = cmd.getDomainId();
|
||||
Boolean isSystem = cmd.getIsSystem();
|
||||
String vmTypeStr = cmd.getSystemVmType();
|
||||
Map<String, String> resourceTags = cmd.getResourceTags();
|
||||
|
||||
SearchBuilder<ServiceOfferingJoinVO> sb = _srvOfferingJoinDao.createSearchBuilder();
|
||||
if (resourceTags != null && !resourceTags.isEmpty()) {
|
||||
SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
|
||||
for (int count=0; count < resourceTags.size(); count++) {
|
||||
tagSearch.or().op("key" + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ);
|
||||
tagSearch.and("value" + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ);
|
||||
tagSearch.cp();
|
||||
}
|
||||
tagSearch.and("resourceType", tagSearch.entity().getResourceType(), SearchCriteria.Op.EQ);
|
||||
sb.groupBy(sb.entity().getId());
|
||||
sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
SearchCriteria<ServiceOfferingJoinVO> sc = sb.create();
|
||||
SearchCriteria<ServiceOfferingJoinVO> sc = _srvOfferingJoinDao.createSearchCriteria();
|
||||
|
||||
if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && isSystem) {
|
||||
throw new InvalidParameterValueException("Only ROOT admins can access system's offering");
|
||||
|
|
@ -2515,17 +2501,6 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
|||
if (vmTypeStr != null) {
|
||||
sc.addAnd("vm_type", SearchCriteria.Op.EQ, vmTypeStr);
|
||||
}
|
||||
|
||||
|
||||
if (resourceTags != null && !resourceTags.isEmpty()) {
|
||||
int count = 0;
|
||||
sc.setJoinParameters("tagSearch", "resourceType", TaggedResourceType.ServiceOffering.toString());
|
||||
for (String key : resourceTags.keySet()) {
|
||||
sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), key);
|
||||
sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), resourceTags.get(key));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return _srvOfferingJoinDao.searchAndCount(sc, searchFilter);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue