public LBHealthCheckPolicyResponse(HealthCheckPolicy healthcheckpolicy) { if (healthcheckpolicy.isRevoke()) { this.setState("Revoked"); } if (healthcheckpolicy.getUuid() != null) setId(healthcheckpolicy.getUuid()); this.pingpath = healthcheckpolicy.getpingpath(); this.healthcheckInterval = healthcheckpolicy.getHealthcheckInterval(); this.responseTime = healthcheckpolicy.getResponseTime(); this.healthcheckthresshold = healthcheckpolicy.getHealthcheckThresshold(); this.unhealthcheckthresshold = healthcheckpolicy.getUnhealthThresshold(); this.forDisplay = healthcheckpolicy.isDisplay(); this.description = healthcheckpolicy.getDescription(); setObjectName("healthcheckpolicy"); }
@Override public void create() { try { HealthCheckPolicy result = _lbService.createLBHealthCheckPolicy(this); this.setEntityId(result.getId()); this.setEntityUuid(result.getUuid()); } catch (InvalidParameterValueException e) { s_logger.warn("Exception: ", e); throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, e.getMessage()); } }
@Override public Long getSyncObjId() { HealthCheckPolicy policy = _entityMgr.findById(HealthCheckPolicy.class, getId()); if (policy == null) { throw new InvalidParameterValueException("Unable to find load balancer health check rule: " + id); } LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId()); if (lb == null) { throw new InvalidParameterValueException("Unable to find load balancer rule for health check rule: " + id); } return lb.getNetworkId(); } }
@Override public void execute() { HealthCheckPolicy policy = _lbService.updateLBHealthCheckPolicy(this.getId(), this.getCustomId(), this.getDisplay()); LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId()); LBHealthCheckResponse hcResponse = _responseGenerator.createLBHealthCheckPolicyResponse(policy, lb); setResponseObject(hcResponse); hcResponse.setResponseName(getCommandName()); }
public LBHealthCheckPolicyResponse(final HealthCheckPolicy healthcheckpolicy) { if (healthcheckpolicy.isRevoke()) { this.setState("Revoked"); } if (healthcheckpolicy.getUuid() != null) { setId(healthcheckpolicy.getUuid()); } this.pingpath = healthcheckpolicy.getpingpath(); this.healthcheckInterval = healthcheckpolicy.getHealthcheckInterval(); this.responseTime = healthcheckpolicy.getResponseTime(); this.healthcheckthresshold = healthcheckpolicy.getHealthcheckThresshold(); this.unhealthcheckthresshold = healthcheckpolicy.getUnhealthThresshold(); this.forDisplay = healthcheckpolicy.isDisplay(); this.description = healthcheckpolicy.getDescription(); setObjectName("healthcheckpolicy"); }
@Override public void create() { try { final HealthCheckPolicy result = _lbService.createLBHealthCheckPolicy(this); this.setEntityId(result.getId()); this.setEntityUuid(result.getUuid()); } catch (final InvalidParameterValueException e) { s_logger.warn("Exception: ", e); throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, e.getMessage()); } }
@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()); LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId()); 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"); } } }
@Override public Long getSyncObjId() { final HealthCheckPolicy policy = _entityMgr.findById(HealthCheckPolicy.class, getId()); if (policy == null) { throw new InvalidParameterValueException("Unable to find load balancer health check rule: " + id); } final LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId()); if (lb == null) { throw new InvalidParameterValueException("Unable to find load balancer rule for health check rule: " + id); } return lb.getNetworkId(); }
@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()); }
@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"); } } }