Search in sources :

Example 1 with Condition

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

the class ListConditionsCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    List<? extends Condition> conditions = null;
    conditions = _autoScaleService.listConditions(this);
    ListResponse<ConditionResponse> response = new ListResponse<ConditionResponse>();
    List<ConditionResponse> cndnResponses = new ArrayList<ConditionResponse>();
    for (Condition cndn : conditions) {
        ConditionResponse cndnResponse = _responseGenerator.createConditionResponse(cndn);
        cndnResponses.add(cndnResponse);
    }
    response.setResponses(cndnResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : Condition(com.cloud.network.as.Condition) ListResponse(org.apache.cloudstack.api.response.ListResponse) ConditionResponse(org.apache.cloudstack.api.response.ConditionResponse) ArrayList(java.util.ArrayList)

Example 2 with Condition

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

the class CreateConditionCmd method execute.

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

Example 3 with Condition

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

the class CreateAutoScalePolicyCmd method getEntityOwnerId.

@Override
public long getEntityOwnerId() {
    if (conditionAccountId != null) {
        return conditionAccountId;
    }
    long conditionId = getConditionIds().get(0);
    Condition condition = _entityMgr.findById(Condition.class, conditionId);
    if (condition == null) {
        // it is an invalid condition, return system account, error will be thrown later.
        conditionDomainId = Domain.ROOT_DOMAIN;
        conditionAccountId = Account.ACCOUNT_ID_SYSTEM;
    } else {
        conditionDomainId = condition.getDomainId();
        conditionAccountId = condition.getAccountId();
    }
    return conditionAccountId;
}
Also used : Condition(com.cloud.network.as.Condition)

Example 4 with Condition

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

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

the class CreateConditionCmd method create.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void create() throws ResourceAllocationException {
    Condition condition = null;
    condition = _autoScaleService.createCondition(this);
    if (condition != null) {
        setEntityId(condition.getId());
        setEntityUuid(condition.getUuid());
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create condition.");
    }
}
Also used : Condition(com.cloud.network.as.Condition) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Aggregations

Condition (com.cloud.network.as.Condition)6 ArrayList (java.util.ArrayList)3 AutoScalePolicy (com.cloud.network.as.AutoScalePolicy)2 AutoScaleVmProfile (com.cloud.network.as.AutoScaleVmProfile)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 ConditionResponse (org.apache.cloudstack.api.response.ConditionResponse)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 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1