Search in sources :

Example 1 with AutoScaleVmGroup

use of com.cloud.network.as.AutoScaleVmGroup 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 AutoScaleVmGroup

use of com.cloud.network.as.AutoScaleVmGroup 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 AutoScaleVmGroup

use of com.cloud.network.as.AutoScaleVmGroup in project cloudstack by apache.

the class LoadBalancerTO method setAutoScaleVmGroup.

public void setAutoScaleVmGroup(LbAutoScaleVmGroup lbAutoScaleVmGroup) {
    List<LbAutoScalePolicy> lbAutoScalePolicies = lbAutoScaleVmGroup.getPolicies();
    List<AutoScalePolicyTO> autoScalePolicyTOs = new ArrayList<AutoScalePolicyTO>(lbAutoScalePolicies.size());
    for (LbAutoScalePolicy lbAutoScalePolicy : lbAutoScalePolicies) {
        List<LbCondition> lbConditions = lbAutoScalePolicy.getConditions();
        List<ConditionTO> conditionTOs = new ArrayList<ConditionTO>(lbConditions.size());
        for (LbCondition lbCondition : lbConditions) {
            Counter counter = lbCondition.getCounter();
            CounterTO counterTO = new CounterTO(counter.getName(), counter.getSource().toString(), "" + counter.getValue());
            Condition condition = lbCondition.getCondition();
            ConditionTO conditionTO = new ConditionTO(condition.getThreshold(), condition.getRelationalOperator().toString(), counterTO);
            conditionTOs.add(conditionTO);
        }
        AutoScalePolicy autoScalePolicy = lbAutoScalePolicy.getPolicy();
        autoScalePolicyTOs.add(new AutoScalePolicyTO(autoScalePolicy.getId(), autoScalePolicy.getDuration(), autoScalePolicy.getQuietTime(), autoScalePolicy.getAction(), conditionTOs, lbAutoScalePolicy.isRevoked()));
    }
    LbAutoScaleVmProfile lbAutoScaleVmProfile = lbAutoScaleVmGroup.getProfile();
    AutoScaleVmProfile autoScaleVmProfile = lbAutoScaleVmProfile.getProfile();
    AutoScaleVmProfileTO autoScaleVmProfileTO = new AutoScaleVmProfileTO(lbAutoScaleVmProfile.getZoneId(), lbAutoScaleVmProfile.getDomainId(), lbAutoScaleVmProfile.getCsUrl(), lbAutoScaleVmProfile.getAutoScaleUserApiKey(), lbAutoScaleVmProfile.getAutoScaleUserSecretKey(), lbAutoScaleVmProfile.getServiceOfferingId(), lbAutoScaleVmProfile.getTemplateId(), lbAutoScaleVmProfile.getVmName(), lbAutoScaleVmProfile.getNetworkId(), autoScaleVmProfile.getOtherDeployParams(), autoScaleVmProfile.getCounterParams(), autoScaleVmProfile.getDestroyVmGraceperiod());
    AutoScaleVmGroup autoScaleVmGroup = lbAutoScaleVmGroup.getVmGroup();
    autoScaleVmGroupTO = new AutoScaleVmGroupTO(autoScaleVmGroup.getUuid(), autoScaleVmGroup.getMinMembers(), autoScaleVmGroup.getMaxMembers(), autoScaleVmGroup.getMemberPort(), autoScaleVmGroup.getInterval(), autoScalePolicyTOs, autoScaleVmProfileTO, autoScaleVmGroup.getState(), lbAutoScaleVmGroup.getCurrentState());
}
Also used : LbCondition(com.cloud.network.lb.LoadBalancingRule.LbCondition) Condition(com.cloud.network.as.Condition) LbAutoScaleVmGroup(com.cloud.network.lb.LoadBalancingRule.LbAutoScaleVmGroup) AutoScaleVmGroup(com.cloud.network.as.AutoScaleVmGroup) LbAutoScaleVmProfile(com.cloud.network.lb.LoadBalancingRule.LbAutoScaleVmProfile) LbAutoScalePolicy(com.cloud.network.lb.LoadBalancingRule.LbAutoScalePolicy) ArrayList(java.util.ArrayList) LbAutoScaleVmProfile(com.cloud.network.lb.LoadBalancingRule.LbAutoScaleVmProfile) AutoScaleVmProfile(com.cloud.network.as.AutoScaleVmProfile) Counter(com.cloud.network.as.Counter) LbAutoScalePolicy(com.cloud.network.lb.LoadBalancingRule.LbAutoScalePolicy) AutoScalePolicy(com.cloud.network.as.AutoScalePolicy) LbCondition(com.cloud.network.lb.LoadBalancingRule.LbCondition)

Example 4 with AutoScaleVmGroup

use of com.cloud.network.as.AutoScaleVmGroup in project cloudstack by apache.

the class CreateAutoScaleVmGroupCmd method create.

@Override
public void create() throws ResourceAllocationException {
    AutoScaleVmGroup result = _autoScaleService.createAutoScaleVmGroup(this);
    if (result != null) {
        setEntityId(result.getId());
        setEntityUuid(result.getUuid());
    } else {
        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)

Example 5 with AutoScaleVmGroup

use of com.cloud.network.as.AutoScaleVmGroup 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)

Aggregations

AutoScaleVmGroup (com.cloud.network.as.AutoScaleVmGroup)7 ServerApiException (org.apache.cloudstack.api.ServerApiException)5 AutoScaleVmGroupResponse (org.apache.cloudstack.api.response.AutoScaleVmGroupResponse)5 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 ArrayList (java.util.ArrayList)2 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 AutoScalePolicy (com.cloud.network.as.AutoScalePolicy)1 AutoScaleVmProfile (com.cloud.network.as.AutoScaleVmProfile)1 Condition (com.cloud.network.as.Condition)1 Counter (com.cloud.network.as.Counter)1 LbAutoScalePolicy (com.cloud.network.lb.LoadBalancingRule.LbAutoScalePolicy)1 LbAutoScaleVmGroup (com.cloud.network.lb.LoadBalancingRule.LbAutoScaleVmGroup)1 LbAutoScaleVmProfile (com.cloud.network.lb.LoadBalancingRule.LbAutoScaleVmProfile)1 LbCondition (com.cloud.network.lb.LoadBalancingRule.LbCondition)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1