Search in sources :

Example 1 with AutoScaleVmGroupResponse

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

the class EnableAutoScaleVmGroupCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    AutoScaleVmGroup result = _autoScaleService.enableAutoScaleVmGroup(getId());
    if (result != null) {
        AutoScaleVmGroupResponse response = _responseGenerator.createAutoScaleVmGroupResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable AutoScale Vm Group");
    }
}
Also used : AutoScaleVmGroup(com.cloud.network.as.AutoScaleVmGroup) ServerApiException(org.apache.cloudstack.api.ServerApiException) AutoScaleVmGroupResponse(org.apache.cloudstack.api.response.AutoScaleVmGroupResponse)

Example 2 with AutoScaleVmGroupResponse

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

the class CreateAutoScaleVmGroupCmd method execute.

@Override
public void execute() {
    boolean success = false;
    AutoScaleVmGroup vmGroup = null;
    try {
        success = _autoScaleService.configureAutoScaleVmGroup(this);
        if (success) {
            vmGroup = _entityMgr.findById(AutoScaleVmGroup.class, getEntityId());
            AutoScaleVmGroupResponse responseObject = _responseGenerator.createAutoScaleVmGroupResponse(vmGroup);
            setResponseObject(responseObject);
            responseObject.setResponseName(getCommandName());
        }
    } catch (Exception ex) {
        // TODO what will happen if Resource Layer fails in a step inbetween
        s_logger.warn("Failed to create autoscale vm group", ex);
    } finally {
        if (!success || vmGroup == null) {
            _autoScaleService.deleteAutoScaleVmGroup(getEntityId());
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Autoscale Vm Group");
        }
    }
}
Also used : AutoScaleVmGroup(com.cloud.network.as.AutoScaleVmGroup) ServerApiException(org.apache.cloudstack.api.ServerApiException) AutoScaleVmGroupResponse(org.apache.cloudstack.api.response.AutoScaleVmGroupResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException)

Example 3 with AutoScaleVmGroupResponse

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

the class UpdateAutoScaleVmGroupCmd method execute.

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

Example 4 with AutoScaleVmGroupResponse

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

the class ListAutoScaleVmGroupsCmd method execute.

@Override
public void execute() {
    if (id != null && (loadBalancerId != null || profileId != null || policyId != null))
        throw new InvalidParameterValueException("When id is specified other parameters need not be specified");
    List<? extends AutoScaleVmGroup> autoScaleGroups = _autoScaleService.listAutoScaleVmGroups(this);
    ListResponse<AutoScaleVmGroupResponse> response = new ListResponse<AutoScaleVmGroupResponse>();
    List<AutoScaleVmGroupResponse> responses = new ArrayList<AutoScaleVmGroupResponse>();
    if (autoScaleGroups != null) {
        for (AutoScaleVmGroup autoScaleVmGroup : autoScaleGroups) {
            AutoScaleVmGroupResponse autoScaleVmGroupResponse = _responseGenerator.createAutoScaleVmGroupResponse(autoScaleVmGroup);
            autoScaleVmGroupResponse.setObjectName("autoscalevmgroup");
            responses.add(autoScaleVmGroupResponse);
        }
    }
    response.setResponses(responses);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) AutoScaleVmGroup(com.cloud.network.as.AutoScaleVmGroup) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) AutoScaleVmGroupResponse(org.apache.cloudstack.api.response.AutoScaleVmGroupResponse)

Example 5 with AutoScaleVmGroupResponse

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

the class DisableAutoScaleVmGroupCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    AutoScaleVmGroup result = _autoScaleService.disableAutoScaleVmGroup(getId());
    if (result != null) {
        AutoScaleVmGroupResponse response = _responseGenerator.createAutoScaleVmGroupResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disable AutoScale Vm Group");
    }
}
Also used : AutoScaleVmGroup(com.cloud.network.as.AutoScaleVmGroup) ServerApiException(org.apache.cloudstack.api.ServerApiException) AutoScaleVmGroupResponse(org.apache.cloudstack.api.response.AutoScaleVmGroupResponse)

Aggregations

AutoScaleVmGroupResponse (org.apache.cloudstack.api.response.AutoScaleVmGroupResponse)6 AutoScaleVmGroup (com.cloud.network.as.AutoScaleVmGroup)5 ServerApiException (org.apache.cloudstack.api.ServerApiException)4 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 ArrayList (java.util.ArrayList)2 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 AutoScalePolicy (com.cloud.network.as.AutoScalePolicy)1 AutoScaleVmProfileVO (com.cloud.network.as.AutoScaleVmProfileVO)1 FirewallRuleVO (com.cloud.network.rules.FirewallRuleVO)1 AutoScalePolicyResponse (org.apache.cloudstack.api.response.AutoScalePolicyResponse)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1