use of com.cloud.api.response.LBStickinessResponse in project CloudStack-archive by CloudStack-extras.
the class ListLBStickinessPoliciesCmd method execute.
@Override
public void execute() {
List<LBStickinessResponse> spResponses = new ArrayList<LBStickinessResponse>();
LoadBalancer lb = _lbService.findById(getLbRuleId());
ListResponse<LBStickinessResponse> response = new ListResponse<LBStickinessResponse>();
if (lb != null) {
//check permissions
Account caller = UserContext.current().getCaller();
_accountService.checkAccess(caller, null, true, lb);
List<? extends StickinessPolicy> stickinessPolicies = _lbService.searchForLBStickinessPolicies(this);
LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(stickinessPolicies, lb);
spResponses.add(spResponse);
response.setResponses(spResponses);
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.LBStickinessResponse in project CloudStack-archive by CloudStack-extras.
the class CreateLBStickinessPolicyCmd method execute.
@Override
public void execute() throws ResourceAllocationException, ResourceUnavailableException {
StickinessPolicy policy = null;
boolean success = false;
try {
UserContext.current().setEventDetails("Rule Id: " + getEntityId());
success = _lbService.applyLBStickinessPolicy(this);
if (success) {
// State might be different after the rule is applied, so get new object here
policy = _entityMgr.findById(StickinessPolicy.class, getEntityId());
LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(policy, lb);
setResponseObject(spResponse);
spResponse.setResponseName(getCommandName());
}
} finally {
if (!success || (policy == null)) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create stickiness policy ");
}
}
}
Aggregations