CLOUDSTACK-3343 UI/API should also return the mode(Strict/Preferred) when listing the ServiceOffering that uses ImplicitDedicationPlanner

Changes:
- API is fixed to return the service_offering details
This commit is contained in:
Prachi Damle 2013-07-28 22:09:54 -07:00
parent 6f9c26ea49
commit 027d4873b4
3 changed files with 22 additions and 2 deletions

View File

@ -17,8 +17,7 @@
package org.apache.cloudstack.api.response;
import java.util.Date;
import javax.persistence.Column;
import java.util.Map;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
@ -102,6 +101,10 @@ public class ServiceOfferingResponse extends BaseResponse {
@SerializedName(ApiConstants.DEPLOYMENT_PLANNER) @Param(description="deployment strategy used to deploy VM.")
private String deploymentPlanner;
@SerializedName(ApiConstants.SERVICE_OFFERING_DETAILS)
@Param(description = "additional key/value details tied with this service offering", since = "4.2.0")
private Map<String, String> details;
public String getId() {
return id;
}
@ -276,4 +279,8 @@ public class ServiceOfferingResponse extends BaseResponse {
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public void setDetails(Map<String, String> details) {
this.details = details;
}
}

View File

@ -222,6 +222,7 @@ import com.cloud.server.StatsCollector;
import com.cloud.server.TaggedResourceService;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.service.dao.ServiceOfferingDetailsDao;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.GuestOS;
import com.cloud.storage.GuestOSCategoryVO;
@ -403,6 +404,7 @@ public class ApiDBUtils {
static AffinityGroupJoinDao _affinityGroupJoinDao;
static GlobalLoadBalancingRulesService _gslbService;
static NetworkACLDao _networkACLDao;
static ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
@Inject private ManagementServer ms;
@Inject public AsyncJobManager asyncMgr;
@ -512,6 +514,7 @@ public class ApiDBUtils {
@Inject private AffinityGroupJoinDao affinityGroupJoinDao;
@Inject private GlobalLoadBalancingRulesService gslbService;
@Inject private NetworkACLDao networkACLDao;
@Inject private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
@PostConstruct
void init() {
@ -621,6 +624,7 @@ public class ApiDBUtils {
// Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
_statsCollector = StatsCollector.getInstance();
_networkACLDao = networkACLDao;
_serviceOfferingDetailsDao = serviceOfferingDetailsDao;
}
// ///////////////////////////////////////////////////////////
@ -1682,4 +1686,9 @@ public class ApiDBUtils {
String providerDnsName = _configDao.getValue(Config.CloudDnsName.key());
return providerDnsName;
}
public static Map<String, String> getServiceOfferingDetails(long serviceOfferingId) {
Map<String, String> details = _serviceOfferingDetailsDao.findDetails(serviceOfferingId);
return details.isEmpty() ? null : details;
}
}

View File

@ -17,15 +17,18 @@
package com.cloud.api.query.dao;
import java.util.List;
import java.util.Map;
import javax.ejb.Local;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.query.vo.ServiceOfferingJoinVO;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import com.cloud.offering.ServiceOffering;
import com.cloud.offering.NetworkOffering.Detail;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
@ -79,6 +82,7 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
offeringResponse.setBytesWriteRate(offering.getBytesWriteRate());
offeringResponse.setIopsReadRate(offering.getIopsReadRate());
offeringResponse.setIopsWriteRate(offering.getIopsWriteRate());
offeringResponse.setDetails(ApiDBUtils.getServiceOfferingDetails(offering.getId()));
offeringResponse.setObjectName("serviceoffering");
return offeringResponse;