ApplicationLoadBalancerRule rule = null;
try {
CallContext.current().setEventDetails("Load Balancer Id: " + getEntityId());
// State might be different after the rule is applied, so get new object here
rule = _entityMgr.findById(ApplicationLoadBalancerRule.class, getEntityId());
ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getEntityId()));
setResponseObject(lbResponse);
lbResponse.setResponseName(getCommandName());
} catch (Exception ex) {
s_logger.warn("Failed to create Load Balancer due to exception ", ex);
} finally {
if (rule == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Load Balancer");