Search in sources :

Example 1 with ConditionResponse

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

the class ApiResponseHelper method createAutoScalePolicyResponse.

@Override
public AutoScalePolicyResponse createAutoScalePolicyResponse(AutoScalePolicy policy) {
    AutoScalePolicyResponse response = new AutoScalePolicyResponse();
    response.setId(policy.getUuid());
    response.setDuration(policy.getDuration());
    response.setQuietTime(policy.getQuietTime());
    response.setAction(policy.getAction());
    List<ConditionVO> vos = ApiDBUtils.getAutoScalePolicyConditions(policy.getId());
    ArrayList<ConditionResponse> conditions = new ArrayList<ConditionResponse>(vos.size());
    for (ConditionVO vo : vos) {
        conditions.add(createConditionResponse(vo));
    }
    response.setConditions(conditions);
    response.setObjectName("autoscalepolicy");
    // Populates the account information in the response
    populateOwner(response, policy);
    return response;
}
Also used : AutoScalePolicyResponse(org.apache.cloudstack.api.response.AutoScalePolicyResponse) ConditionResponse(org.apache.cloudstack.api.response.ConditionResponse) ConditionVO(com.cloud.network.as.ConditionVO) ArrayList(java.util.ArrayList)

Example 2 with ConditionResponse

use of org.apache.cloudstack.api.response.ConditionResponse 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 3 with ConditionResponse

use of org.apache.cloudstack.api.response.ConditionResponse 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 4 with ConditionResponse

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

the class ApiResponseHelper method createConditionResponse.

@Override
public ConditionResponse createConditionResponse(Condition condition) {
    ConditionResponse response = new ConditionResponse();
    response.setId(condition.getUuid());
    List<CounterResponse> counterResponseList = new ArrayList<CounterResponse>();
    counterResponseList.add(createCounterResponse(ApiDBUtils.getCounter(condition.getCounterid())));
    response.setCounterResponse(counterResponseList);
    response.setRelationalOperator(condition.getRelationalOperator().toString());
    response.setThreshold(condition.getThreshold());
    response.setObjectName("condition");
    populateOwner(response, condition);
    return response;
}
Also used : ConditionResponse(org.apache.cloudstack.api.response.ConditionResponse) ArrayList(java.util.ArrayList) CounterResponse(org.apache.cloudstack.api.response.CounterResponse)

Aggregations

ConditionResponse (org.apache.cloudstack.api.response.ConditionResponse)4 ArrayList (java.util.ArrayList)3 Condition (com.cloud.network.as.Condition)2 ConditionVO (com.cloud.network.as.ConditionVO)1 AutoScalePolicyResponse (org.apache.cloudstack.api.response.AutoScalePolicyResponse)1 CounterResponse (org.apache.cloudstack.api.response.CounterResponse)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1