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