use of com.cloud.network.as.AutoScalePolicy 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 com.cloud.network.as.AutoScalePolicy 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 com.cloud.network.as.AutoScalePolicy 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());
}
use of com.cloud.network.as.AutoScalePolicy in project cloudstack by apache.
the class CreateAutoScalePolicyCmd method create.
@Override
public void create() throws ResourceAllocationException {
AutoScalePolicy result = _autoScaleService.createAutoScalePolicy(this);
if (result != null) {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create AutoScale Policy");
}
}
use of com.cloud.network.as.AutoScalePolicy 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");
}
}
Aggregations