use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListPortForwardingRulesCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends PortForwardingRule>, Integer> result = _rulesService.listPortForwardingRules(this);
final ListResponse<FirewallRuleResponse> response = new ListResponse<>();
final List<FirewallRuleResponse> fwResponses = new ArrayList<>();
for (final PortForwardingRule fwRule : result.first()) {
final FirewallRuleResponse ruleData = _responseGenerator.createPortForwardingRuleResponse(fwRule);
ruleData.setObjectName("portforwardingrule");
fwResponses.add(ruleData);
}
response.setResponses(fwResponses, result.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListGuestOsCategoriesCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends GuestOsCategory>, Integer> result = _mgr.listGuestOSCategoriesByCriteria(this);
final ListResponse<GuestOSCategoryResponse> response = new ListResponse<>();
final List<GuestOSCategoryResponse> osCatResponses = new ArrayList<>();
for (final GuestOsCategory osCategory : result.first()) {
final 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 com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListNicsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
try {
final List<? extends Nic> results = _networkService.listNics(this);
final ListResponse<NicResponse> response = new ListResponse<>();
List<NicResponse> resList = null;
if (results != null) {
resList = new ArrayList<>(results.size());
for (final Nic r : results) {
final NicResponse resp = _responseGenerator.createNicResponse(r);
resp.setObjectName("nic");
resList.add(resp);
}
response.setResponses(resList);
}
response.setResponses(resList);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (final Exception e) {
s_logger.warn("Failed to list secondary ip address per nic ");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListIpForwardingRulesCmd method execute.
@Override
public void execute() {
final 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());
final ListResponse<IpForwardingRuleResponse> response = new ListResponse<>();
final List<IpForwardingRuleResponse> ipForwardingResponses = new ArrayList<>();
for (final FirewallRule rule : result.first()) {
final StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false);
final IpForwardingRuleResponse resp = _responseGenerator.createIpForwardingRuleResponse(staticNatRule);
if (resp != null) {
ipForwardingResponses.add(resp);
}
}
response.setResponses(ipForwardingResponses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListRegionsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final List<? extends Region> result = _regionService.listRegions(this);
final ListResponse<RegionResponse> response = new ListResponse<>();
final List<RegionResponse> regionResponses = new ArrayList<>();
for (final Region region : result) {
final RegionResponse regionResponse = _responseGenerator.createRegionResponse(region);
regionResponse.setObjectName("region");
regionResponses.add(regionResponse);
}
response.setResponses(regionResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations