Search in sources :

Example 1 with ServiceOfferingResponse

use of com.cloud.api.response.ServiceOfferingResponse in project cosmic by MissionCriticalCloud.

the class CreateServiceOfferingCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final ServiceOffering result = _configService.createServiceOffering(this);
    if (result != null) {
        final ServiceOfferingResponse response = _responseGenerator.createServiceOfferingResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create service offering");
    }
}
Also used : ServiceOfferingResponse(com.cloud.api.response.ServiceOfferingResponse) ServerApiException(com.cloud.api.ServerApiException) ServiceOffering(com.cloud.offering.ServiceOffering)

Example 2 with ServiceOfferingResponse

use of com.cloud.api.response.ServiceOfferingResponse in project CloudStack-archive by CloudStack-extras.

the class ListServiceOfferingsCmd method execute.

@Override
public void execute() {
    List<? extends ServiceOffering> offerings = _mgr.searchForServiceOfferings(this);
    ListResponse<ServiceOfferingResponse> response = new ListResponse<ServiceOfferingResponse>();
    List<ServiceOfferingResponse> offeringResponses = new ArrayList<ServiceOfferingResponse>();
    for (ServiceOffering offering : offerings) {
        ServiceOfferingResponse offeringResponse = _responseGenerator.createServiceOfferingResponse(offering);
        offeringResponse.setObjectName("serviceoffering");
        offeringResponses.add(offeringResponse);
    }
    response.setResponses(offeringResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ServiceOfferingResponse(com.cloud.api.response.ServiceOfferingResponse) ListResponse(com.cloud.api.response.ListResponse) ServiceOffering(com.cloud.offering.ServiceOffering) ArrayList(java.util.ArrayList)

Example 3 with ServiceOfferingResponse

use of com.cloud.api.response.ServiceOfferingResponse in project CloudStack-archive by CloudStack-extras.

the class UpdateServiceOfferingCmd method execute.

@Override
public void execute() {
    //Note
    //Once an offering is created, we cannot update the domainId field (keeping consistent with zones logic)
    ServiceOffering result = _configService.updateServiceOffering(this);
    if (result != null) {
        ServiceOfferingResponse response = _responseGenerator.createServiceOfferingResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service offering");
    }
}
Also used : ServiceOfferingResponse(com.cloud.api.response.ServiceOfferingResponse) ServerApiException(com.cloud.api.ServerApiException) ServiceOffering(com.cloud.offering.ServiceOffering)

Example 4 with ServiceOfferingResponse

use of com.cloud.api.response.ServiceOfferingResponse in project CloudStack-archive by CloudStack-extras.

the class CreateServiceOfferingCmd method execute.

@Override
public void execute() {
    ServiceOffering result = _configService.createServiceOffering(this);
    if (result != null) {
        ServiceOfferingResponse response = _responseGenerator.createServiceOfferingResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create service offering");
    }
}
Also used : ServiceOfferingResponse(com.cloud.api.response.ServiceOfferingResponse) ServerApiException(com.cloud.api.ServerApiException) ServiceOffering(com.cloud.offering.ServiceOffering)

Example 5 with ServiceOfferingResponse

use of com.cloud.api.response.ServiceOfferingResponse in project cosmic by MissionCriticalCloud.

the class ServiceOfferingJoinDaoImpl method newServiceOfferingResponse.

@Override
public ServiceOfferingResponse newServiceOfferingResponse(final ServiceOfferingJoinVO offering) {
    final ServiceOfferingResponse offeringResponse = new ServiceOfferingResponse();
    offeringResponse.setId(offering.getUuid());
    offeringResponse.setName(offering.getName());
    offeringResponse.setIsSystemOffering(offering.isSystemUse());
    offeringResponse.setDefaultUse(offering.isDefaultUse());
    offeringResponse.setSystemVmType(offering.getSystemVmType());
    offeringResponse.setDisplayText(offering.getDisplayText());
    offeringResponse.setProvisioningType(offering.getProvisioningType().toString());
    offeringResponse.setCpuNumber(offering.getCpu());
    offeringResponse.setMemory(offering.getRamSize());
    offeringResponse.setCreated(offering.getCreated());
    offeringResponse.setStorageType(offering.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
    offeringResponse.setOfferHa(offering.isOfferHA());
    offeringResponse.setLimitCpuUse(offering.isLimitCpuUse());
    offeringResponse.setVolatileVm(offering.getVolatileVm());
    offeringResponse.setTags(offering.getTags());
    offeringResponse.setDomain(offering.getDomainName());
    offeringResponse.setDomainId(offering.getDomainUuid());
    offeringResponse.setNetworkRate(offering.getRateMbps());
    offeringResponse.setHostTag(offering.getHostTag());
    offeringResponse.setDeploymentPlanner(offering.getDeploymentPlanner());
    offeringResponse.setCustomizedIops(offering.isCustomizedIops());
    offeringResponse.setMinIops(offering.getMinIops());
    offeringResponse.setMaxIops(offering.getMaxIops());
    offeringResponse.setHypervisorSnapshotReserve(offering.getHypervisorSnapshotReserve());
    offeringResponse.setBytesReadRate(offering.getBytesReadRate());
    offeringResponse.setBytesWriteRate(offering.getBytesWriteRate());
    offeringResponse.setIopsReadRate(offering.getIopsReadRate());
    offeringResponse.setIopsWriteRate(offering.getIopsWriteRate());
    offeringResponse.setDetails(ApiDBUtils.getResourceDetails(offering.getId(), ResourceObjectType.ServiceOffering));
    offeringResponse.setObjectName("serviceoffering");
    offeringResponse.setIscutomized(offering.isDynamic());
    return offeringResponse;
}
Also used : ServiceOfferingResponse(com.cloud.api.response.ServiceOfferingResponse)

Aggregations

ServiceOfferingResponse (com.cloud.api.response.ServiceOfferingResponse)6 ServiceOffering (com.cloud.offering.ServiceOffering)5 ServerApiException (com.cloud.api.ServerApiException)4 ListResponse (com.cloud.api.response.ListResponse)1 ArrayList (java.util.ArrayList)1