bug 7553: cloudStack - server-side - make listRouters API return “serviceofferingname” and “serviceofferingid”.

This commit is contained in:
Jessica Wang 2011-05-31 17:40:30 -07:00
parent 0685782fa9
commit 8c4e831cfb
3 changed files with 37 additions and 0 deletions

View File

@ -113,6 +113,12 @@ public class DomainRouterResponse extends BaseResponse {
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain associated with the router")
private String domainName;
@SerializedName("serviceofferingid") @Param(description="the ID of the service offering of the virtual machine")
private Long serviceOfferingId;
@SerializedName("serviceofferingname") @Param(description="the name of the service offering of the virtual machine")
private String serviceOfferingName;
@ -353,4 +359,19 @@ public class DomainRouterResponse extends BaseResponse {
this.linkLocalNetworkId = linkLocalNetworkId;
}
public Long getServiceOfferingId() {
return serviceOfferingId;
}
public void setServiceOfferingId(Long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public String getServiceOfferingName() {
return serviceOfferingName;
}
public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}
}

View File

@ -123,6 +123,10 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
this.role = role;
}
@Override
public long getServiceOfferingId() {
return serviceOfferingId;
}
public void setServiceOfferingId(long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}

View File

@ -1223,6 +1223,8 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public DomainRouterResponse createDomainRouterResponse(VirtualRouter router) {
Map<Long, ServiceOffering> serviceOfferings = new HashMap<Long, ServiceOffering>();
DomainRouterResponse routerResponse = new DomainRouterResponse();
routerResponse.setId(router.getId());
routerResponse.setZoneId(router.getDataCenterId());
@ -1236,7 +1238,17 @@ public class ApiResponseHelper implements ResponseGenerator {
routerResponse.setHostId(router.getHostId());
routerResponse.setHostName(ApiDBUtils.findHostById(router.getHostId()).getName());
}
// Service Offering Info
ServiceOffering offering = serviceOfferings.get(router.getServiceOfferingId());
if (offering == null) {
offering = ApiDBUtils.findServiceOfferingById(router.getServiceOfferingId());
serviceOfferings.put(offering.getId(), offering);
}
routerResponse.setServiceOfferingId(offering.getId());
routerResponse.setServiceOfferingName(offering.getName());
Account accountTemp = ApiDBUtils.findAccountById(router.getAccountId());
if (accountTemp != null) {
routerResponse.setAccountName(accountTemp.getAccountName());