use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListLBStickinessPoliciesCmd method execute.
@Override
public void execute() {
LoadBalancer lb = null;
if (lbRuleId == null && id == null) {
throw new InvalidParameterValueException("load balancer rule ID and stickiness policy ID can't be null");
}
if (id != null) {
lb = _lbService.findLbByStickinessId(id);
if (lb == null) {
throw new InvalidParameterValueException("stickiness policy ID doesn't exist");
}
if ((lbRuleId != null) && (lbRuleId != lb.getId())) {
throw new InvalidParameterValueException("stickiness policy ID doesn't belong to lbId" + lbRuleId);
}
}
if (lbRuleId != null && lb == null) {
lb = _lbService.findById(getLbRuleId());
}
List<LBStickinessResponse> spResponses = new ArrayList<LBStickinessResponse>();
ListResponse<LBStickinessResponse> response = new ListResponse<LBStickinessResponse>();
if (lb != null) {
//check permissions
Account caller = CallContext.current().getCallingAccount();
_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 org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class RegisterIsoCmd method execute.
@Override
public void execute() throws ResourceAllocationException {
VirtualMachineTemplate template = _templateService.registerIso(this);
if (template != null) {
ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
List<TemplateResponse> templateResponses = _responseGenerator.createIsoResponses(ResponseView.Restricted, template, zoneId, false);
response.setResponses(templateResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register ISO");
}
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListGuestOsCategoriesCmd method execute.
@Override
public void execute() {
Pair<List<? extends GuestOsCategory>, Integer> result = _mgr.listGuestOSCategoriesByCriteria(this);
ListResponse<GuestOSCategoryResponse> response = new ListResponse<GuestOSCategoryResponse>();
List<GuestOSCategoryResponse> osCatResponses = new ArrayList<GuestOSCategoryResponse>();
for (GuestOsCategory osCategory : result.first()) {
GuestOSCategoryResponse categoryResponse = new GuestOSCategoryResponse();
categoryResponse.setId(osCategory.getUuid());
categoryResponse.setName(osCategory.getName());
categoryResponse.setObjectName("oscategory");
osCatResponses.add(categoryResponse);
}
response.setResponses(osCatResponses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListGuestOsCmd method execute.
@Override
public void execute() {
Pair<List<? extends GuestOS>, Integer> result = _mgr.listGuestOSByCriteria(this);
ListResponse<GuestOSResponse> response = new ListResponse<GuestOSResponse>();
List<GuestOSResponse> osResponses = new ArrayList<GuestOSResponse>();
for (GuestOS guestOS : result.first()) {
GuestOSResponse guestOSResponse = _responseGenerator.createGuestOSResponse(guestOS);
osResponses.add(guestOSResponse);
}
response.setResponses(osResponses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListIpForwardingRulesCmd method execute.
@Override
public void execute() {
Pair<List<? extends FirewallRule>, Integer> result = _rulesService.searchStaticNatRules(publicIpAddressId, id, vmId, this.getStartIndex(), this.getPageSizeVal(), this.getAccountName(), this.getDomainId(), this.getProjectId(), this.isRecursive(), this.listAll());
ListResponse<IpForwardingRuleResponse> response = new ListResponse<IpForwardingRuleResponse>();
List<IpForwardingRuleResponse> ipForwardingResponses = new ArrayList<IpForwardingRuleResponse>();
for (FirewallRule rule : result.first()) {
StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false);
IpForwardingRuleResponse resp = _responseGenerator.createIpForwardingRuleResponse(staticNatRule);
if (resp != null) {
ipForwardingResponses.add(resp);
}
}
response.setResponses(ipForwardingResponses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations