Search in sources :

Example 1 with AutoScaleVmProfile

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

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

the class CreateAutoScaleVmProfileCmd method create.

@Override
public void create() throws ResourceAllocationException {
    AutoScaleVmProfile result = _autoScaleService.createAutoScaleVmProfile(this);
    if (result != null) {
        setEntityId(result.getId());
        setEntityUuid(result.getUuid());
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Autoscale Vm Profile");
    }
}
Also used : AutoScaleVmProfile(com.cloud.network.as.AutoScaleVmProfile) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 3 with AutoScaleVmProfile

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

use of com.cloud.network.as.AutoScaleVmProfile 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 5 with AutoScaleVmProfile

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

Aggregations

AutoScaleVmProfile (com.cloud.network.as.AutoScaleVmProfile)6 ArrayList (java.util.ArrayList)3 AutoScaleVmProfileResponse (org.apache.cloudstack.api.response.AutoScaleVmProfileResponse)3 AutoScalePolicy (com.cloud.network.as.AutoScalePolicy)2 Condition (com.cloud.network.as.Condition)2 Counter (com.cloud.network.as.Counter)2 LbAutoScalePolicy (com.cloud.network.lb.LoadBalancingRule.LbAutoScalePolicy)2 LbAutoScaleVmGroup (com.cloud.network.lb.LoadBalancingRule.LbAutoScaleVmGroup)2 LbAutoScaleVmProfile (com.cloud.network.lb.LoadBalancingRule.LbAutoScaleVmProfile)2 LbCondition (com.cloud.network.lb.LoadBalancingRule.LbCondition)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 DataCenter (com.cloud.dc.DataCenter)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 AutoScalePolicyConditionMapVO (com.cloud.network.as.AutoScalePolicyConditionMapVO)1 AutoScaleVmGroup (com.cloud.network.as.AutoScaleVmGroup)1 AutoScaleVmGroupPolicyMapVO (com.cloud.network.as.AutoScaleVmGroupPolicyMapVO)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 User (com.cloud.user.User)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1