use of org.apache.cloudstack.api.response.AutoScalePolicyResponse in project cloudstack by apache.
the class ListAutoScalePoliciesCmd method execute.
@Override
public void execute() {
List<? extends AutoScalePolicy> autoScalePolicies = _autoScaleService.listAutoScalePolicies(this);
ListResponse<AutoScalePolicyResponse> response = new ListResponse<AutoScalePolicyResponse>();
List<AutoScalePolicyResponse> responses = new ArrayList<AutoScalePolicyResponse>();
if (autoScalePolicies != null) {
for (AutoScalePolicy autoScalePolicy : autoScalePolicies) {
AutoScalePolicyResponse autoScalePolicyResponse = _responseGenerator.createAutoScalePolicyResponse(autoScalePolicy);
autoScalePolicyResponse.setObjectName("autoscalepolicy");
responses.add(autoScalePolicyResponse);
}
}
response.setResponses(responses);
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.AutoScalePolicyResponse in project cloudstack by apache.
the class CreateAutoScalePolicyCmd method execute.
@Override
public void execute() {
AutoScalePolicy result = _entityMgr.findById(AutoScalePolicy.class, getEntityId());
AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.AutoScalePolicyResponse 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;
}
use of org.apache.cloudstack.api.response.AutoScalePolicyResponse in project cloudstack by apache.
the class UpdateAutoScalePolicyCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("AutoScale Policy Id: " + getId());
AutoScalePolicy result = _autoScaleService.updateAutoScalePolicy(this);
if (result != null) {
AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update autoscale policy");
}
}
use of org.apache.cloudstack.api.response.AutoScalePolicyResponse in project cloudstack by apache.
the class ApiResponseHelper method createAutoScaleVmGroupResponse.
@Override
public AutoScaleVmGroupResponse createAutoScaleVmGroupResponse(AutoScaleVmGroup vmGroup) {
AutoScaleVmGroupResponse response = new AutoScaleVmGroupResponse();
response.setId(vmGroup.getUuid());
response.setMinMembers(vmGroup.getMinMembers());
response.setMaxMembers(vmGroup.getMaxMembers());
response.setState(vmGroup.getState());
response.setInterval(vmGroup.getInterval());
response.setForDisplay(vmGroup.isDisplay());
AutoScaleVmProfileVO profile = ApiDBUtils.findAutoScaleVmProfileById(vmGroup.getProfileId());
if (profile != null) {
response.setProfileId(profile.getUuid());
}
FirewallRuleVO fw = ApiDBUtils.findFirewallRuleById(vmGroup.getLoadBalancerId());
if (fw != null) {
response.setLoadBalancerId(fw.getUuid());
}
List<AutoScalePolicyResponse> scaleUpPoliciesResponse = new ArrayList<AutoScalePolicyResponse>();
List<AutoScalePolicyResponse> scaleDownPoliciesResponse = new ArrayList<AutoScalePolicyResponse>();
response.setScaleUpPolicies(scaleUpPoliciesResponse);
response.setScaleDownPolicies(scaleDownPoliciesResponse);
response.setObjectName("autoscalevmgroup");
// Fetch policies for vmgroup
List<AutoScalePolicy> scaleUpPolicies = new ArrayList<AutoScalePolicy>();
List<AutoScalePolicy> scaleDownPolicies = new ArrayList<AutoScalePolicy>();
ApiDBUtils.getAutoScaleVmGroupPolicies(vmGroup.getId(), scaleUpPolicies, scaleDownPolicies);
// populate policies
for (AutoScalePolicy autoScalePolicy : scaleUpPolicies) {
scaleUpPoliciesResponse.add(createAutoScalePolicyResponse(autoScalePolicy));
}
for (AutoScalePolicy autoScalePolicy : scaleDownPolicies) {
scaleDownPoliciesResponse.add(createAutoScalePolicyResponse(autoScalePolicy));
}
return response;
}
Aggregations