Search in sources :

Example 1 with AutoScaleVmProfileResponse

use of org.apache.cloudstack.api.response.AutoScaleVmProfileResponse in project cloudstack by apache.

the class CreateAutoScaleVmProfileCmd method execute.

@Override
public void execute() {
    AutoScaleVmProfile result = _entityMgr.findById(AutoScaleVmProfile.class, getEntityId());
    AutoScaleVmProfileResponse response = _responseGenerator.createAutoScaleVmProfileResponse(result);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : AutoScaleVmProfile(com.cloud.network.as.AutoScaleVmProfile) AutoScaleVmProfileResponse(org.apache.cloudstack.api.response.AutoScaleVmProfileResponse)

Example 2 with AutoScaleVmProfileResponse

use of org.apache.cloudstack.api.response.AutoScaleVmProfileResponse in project cloudstack by apache.

the class UpdateAutoScaleVmProfileCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    CallContext.current().setEventDetails("AutoScale Policy Id: " + getId());
    AutoScaleVmProfile result = _autoScaleService.updateAutoScaleVmProfile(this);
    if (result != null) {
        AutoScaleVmProfileResponse response = _responseGenerator.createAutoScaleVmProfileResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update autoscale vm profile");
    }
}
Also used : AutoScaleVmProfile(com.cloud.network.as.AutoScaleVmProfile) ServerApiException(org.apache.cloudstack.api.ServerApiException) AutoScaleVmProfileResponse(org.apache.cloudstack.api.response.AutoScaleVmProfileResponse)

Example 3 with AutoScaleVmProfileResponse

use of org.apache.cloudstack.api.response.AutoScaleVmProfileResponse in project cloudstack by apache.

the class ListAutoScaleVmProfilesCmd method execute.

@Override
public void execute() {
    List<? extends AutoScaleVmProfile> autoScaleProfiles = _autoScaleService.listAutoScaleVmProfiles(this);
    ListResponse<AutoScaleVmProfileResponse> response = new ListResponse<AutoScaleVmProfileResponse>();
    List<AutoScaleVmProfileResponse> responses = new ArrayList<AutoScaleVmProfileResponse>();
    if (autoScaleProfiles != null) {
        for (AutoScaleVmProfile autoScaleVmProfile : autoScaleProfiles) {
            AutoScaleVmProfileResponse autoScaleVmProfileResponse = _responseGenerator.createAutoScaleVmProfileResponse(autoScaleVmProfile);
            autoScaleVmProfileResponse.setObjectName("autoscalevmprofile");
            responses.add(autoScaleVmProfileResponse);
        }
    }
    response.setResponses(responses);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : AutoScaleVmProfile(com.cloud.network.as.AutoScaleVmProfile) ListResponse(org.apache.cloudstack.api.response.ListResponse) AutoScaleVmProfileResponse(org.apache.cloudstack.api.response.AutoScaleVmProfileResponse) ArrayList(java.util.ArrayList)

Example 4 with AutoScaleVmProfileResponse

use of org.apache.cloudstack.api.response.AutoScaleVmProfileResponse in project cloudstack by apache.

the class ApiResponseHelper method createAutoScaleVmProfileResponse.

@Override
public AutoScaleVmProfileResponse createAutoScaleVmProfileResponse(AutoScaleVmProfile profile) {
    AutoScaleVmProfileResponse response = new AutoScaleVmProfileResponse();
    response.setId(profile.getUuid());
    if (profile.getZoneId() != null) {
        DataCenter zone = ApiDBUtils.findZoneById(profile.getZoneId());
        if (zone != null) {
            response.setZoneId(zone.getUuid());
        }
    }
    if (profile.getServiceOfferingId() != null) {
        ServiceOffering so = ApiDBUtils.findServiceOfferingById(profile.getServiceOfferingId());
        if (so != null) {
            response.setServiceOfferingId(so.getUuid());
        }
    }
    if (profile.getTemplateId() != null) {
        VMTemplateVO template = ApiDBUtils.findTemplateById(profile.getTemplateId());
        if (template != null) {
            response.setTemplateId(template.getUuid());
        }
    }
    response.setOtherDeployParams(profile.getOtherDeployParams());
    response.setCounterParams(profile.getCounterParams());
    response.setDestroyVmGraceperiod(profile.getDestroyVmGraceperiod());
    User user = ApiDBUtils.findUserById(profile.getAutoScaleUserId());
    if (user != null) {
        response.setAutoscaleUserId(user.getUuid());
    }
    response.setObjectName("autoscalevmprofile");
    // Populates the account information in the response
    populateOwner(response, profile);
    return response;
}
Also used : DataCenter(com.cloud.dc.DataCenter) User(com.cloud.user.User) VpnUser(com.cloud.network.VpnUser) ServiceOffering(com.cloud.offering.ServiceOffering) AutoScaleVmProfileResponse(org.apache.cloudstack.api.response.AutoScaleVmProfileResponse) VMTemplateVO(com.cloud.storage.VMTemplateVO)

Aggregations

AutoScaleVmProfileResponse (org.apache.cloudstack.api.response.AutoScaleVmProfileResponse)4 AutoScaleVmProfile (com.cloud.network.as.AutoScaleVmProfile)3 DataCenter (com.cloud.dc.DataCenter)1 VpnUser (com.cloud.network.VpnUser)1 ServiceOffering (com.cloud.offering.ServiceOffering)1 VMTemplateVO (com.cloud.storage.VMTemplateVO)1 User (com.cloud.user.User)1 ArrayList (java.util.ArrayList)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1