use of com.cloud.api.response.LBHealthCheckResponse in project cosmic by MissionCriticalCloud.
the class UpdateLBHealthCheckPolicyCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final HealthCheckPolicy policy = _lbService.updateLBHealthCheckPolicy(this.getId(), this.getCustomId(), this.getDisplay());
final LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
final LBHealthCheckResponse hcResponse = _responseGenerator.createLBHealthCheckPolicyResponse(policy, lb);
setResponseObject(hcResponse);
hcResponse.setResponseName(getCommandName());
}
use of com.cloud.api.response.LBHealthCheckResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createLBHealthCheckPolicyResponse.
@Override
public LBHealthCheckResponse createLBHealthCheckPolicyResponse(final HealthCheckPolicy healthcheckPolicy, final LoadBalancer lb) {
final LBHealthCheckResponse hcResponse = new LBHealthCheckResponse();
hcResponse.setlbRuleId(lb.getUuid());
final Account accountTemp = ApiDBUtils.findAccountById(lb.getAccountId());
if (accountTemp != null) {
hcResponse.setAccountName(accountTemp.getAccountName());
final Domain domain = ApiDBUtils.findDomainById(accountTemp.getDomainId());
if (domain != null) {
hcResponse.setDomainId(domain.getUuid());
hcResponse.setDomainName(domain.getName());
}
}
final List<LBHealthCheckPolicyResponse> responses = new ArrayList<>();
final LBHealthCheckPolicyResponse ruleResponse = new LBHealthCheckPolicyResponse(healthcheckPolicy);
responses.add(ruleResponse);
hcResponse.setRules(responses);
hcResponse.setObjectName("healthcheckpolicies");
return hcResponse;
}
use of com.cloud.api.response.LBHealthCheckResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createLBHealthCheckPolicyResponse.
@Override
public LBHealthCheckResponse createLBHealthCheckPolicyResponse(final List<? extends HealthCheckPolicy> healthcheckPolicies, final LoadBalancer lb) {
final LBHealthCheckResponse hcResponse = new LBHealthCheckResponse();
if (lb == null) {
return hcResponse;
}
hcResponse.setlbRuleId(lb.getUuid());
final Account account = ApiDBUtils.findAccountById(lb.getAccountId());
if (account != null) {
hcResponse.setAccountName(account.getAccountName());
final Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
if (domain != null) {
hcResponse.setDomainId(domain.getUuid());
hcResponse.setDomainName(domain.getName());
}
}
final List<LBHealthCheckPolicyResponse> responses = new ArrayList<>();
for (final HealthCheckPolicy healthcheckPolicy : healthcheckPolicies) {
final LBHealthCheckPolicyResponse ruleResponse = new LBHealthCheckPolicyResponse(healthcheckPolicy);
responses.add(ruleResponse);
}
hcResponse.setRules(responses);
hcResponse.setObjectName("healthcheckpolicies");
return hcResponse;
}
use of com.cloud.api.response.LBHealthCheckResponse in project cosmic by MissionCriticalCloud.
the class CreateLBHealthCheckPolicyCmd method execute.
@Override
public void execute() throws ResourceAllocationException, ResourceUnavailableException {
HealthCheckPolicy policy = null;
boolean success = false;
try {
CallContext.current().setEventDetails("Load balancer health check policy ID : " + getEntityId());
success = _lbService.applyLBHealthCheckPolicy(this);
if (success) {
// State might be different after the rule is applied, so get new object here
policy = _entityMgr.findById(HealthCheckPolicy.class, getEntityId());
final LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
final LBHealthCheckResponse hcResponse = _responseGenerator.createLBHealthCheckPolicyResponse(policy, lb);
setResponseObject(hcResponse);
hcResponse.setResponseName(getCommandName());
}
} finally {
if (!success || (policy == null)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create health check policy");
}
}
}
use of com.cloud.api.response.LBHealthCheckResponse in project cosmic by MissionCriticalCloud.
the class ListLBHealthCheckPoliciesCmd method execute.
@Override
public void execute() {
final List<LBHealthCheckResponse> hcpResponses = new ArrayList<>();
final ListResponse<LBHealthCheckResponse> response = new ListResponse<>();
Long lbRuleId = getLbRuleId();
final Long hId = getId();
if (lbRuleId == null) {
if (hId != null) {
lbRuleId = _lbService.findLBIdByHealtCheckPolicyId(hId);
} else {
throw new InvalidParameterValueException("Either load balancer rule ID or health check policy ID should be specified");
}
}
final LoadBalancer lb = _lbService.findById(lbRuleId);
if (lb != null) {
final List<? extends HealthCheckPolicy> healthCheckPolicies = _lbService.searchForLBHealthCheckPolicies(this);
final LBHealthCheckResponse spResponse = _responseGenerator.createLBHealthCheckPolicyResponse(healthCheckPolicies, lb);
hcpResponses.add(spResponse);
response.setResponses(hcpResponses);
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations