use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class RegisterIsoCmdByAdmin 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.Full, 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 ListLoadBalancerRuleInstancesCmdByAdmin method execute.
@Override
public void execute() {
Pair<List<? extends UserVm>, List<String>> vmServiceMap = _lbService.listLoadBalancerInstances(this);
List<? extends UserVm> result = vmServiceMap.first();
List<String> serviceStates = vmServiceMap.second();
if (!isListLbVmip()) {
// list lb instances
ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
if (result != null) {
vmResponses = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "loadbalancerruleinstance", result.toArray(new UserVm[result.size()]));
for (int i = 0; i < result.size(); i++) {
vmResponses.get(i).setServiceState(serviceStates.get(i));
}
}
response.setResponses(vmResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
ListResponse<LoadBalancerRuleVmMapResponse> lbRes = new ListResponse<LoadBalancerRuleVmMapResponse>();
List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
List<LoadBalancerRuleVmMapResponse> listlbVmRes = new ArrayList<LoadBalancerRuleVmMapResponse>();
if (result != null) {
vmResponses = _responseGenerator.createUserVmResponse(ResponseView.Full, "loadbalancerruleinstance", result.toArray(new UserVm[result.size()]));
List<String> ipaddr = null;
for (int i = 0; i < result.size(); i++) {
LoadBalancerRuleVmMapResponse lbRuleVmIpResponse = new LoadBalancerRuleVmMapResponse();
vmResponses.get(i).setServiceState(serviceStates.get(i));
lbRuleVmIpResponse.setUserVmResponse(vmResponses.get(i));
//get vm id from the uuid
VirtualMachine lbvm = _entityMgr.findByUuid(VirtualMachine.class, vmResponses.get(i).getId());
lbRuleVmIpResponse.setIpAddr(_lbService.listLbVmIpAddress(getId(), lbvm.getId()));
lbRuleVmIpResponse.setObjectName("lbrulevmidip");
listlbVmRes.add(lbRuleVmIpResponse);
}
}
lbRes.setResponseName(getCommandName());
lbRes.setResponses(listlbVmRes);
setResponseObject(lbRes);
}
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListNetworksCmdByAdmin method execute.
@Override
public void execute() {
Pair<List<? extends Network>, Integer> networks = _networkService.searchForNetworks(this);
ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>();
List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
for (Network network : networks.first()) {
NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(ResponseView.Full, network);
networkResponses.add(networkResponse);
}
response.setResponses(networkResponses, networks.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class GetUsageRecordsCmd method execute.
@Override
public void execute() {
Pair<List<? extends Usage>, Integer> usageRecords = _usageService.getUsageRecords(this);
ListResponse<UsageRecordResponse> response = new ListResponse<UsageRecordResponse>();
List<UsageRecordResponse> usageResponses = new ArrayList<UsageRecordResponse>();
if (usageRecords != null) {
for (Usage usageRecord : usageRecords.first()) {
UsageRecordResponse usageResponse = _responseGenerator.createUsageResponse(usageRecord);
usageResponse.setObjectName("usagerecord");
usageResponses.add(usageResponse);
}
response.setResponses(usageResponses, usageRecords.second());
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListRecurringSnapshotScheduleCmd method execute.
@Override
public void execute() {
List<? extends SnapshotSchedule> snapshotSchedules = _snapshotService.findRecurringSnapshotSchedule(this);
ListResponse<SnapshotScheduleResponse> response = new ListResponse<SnapshotScheduleResponse>();
List<SnapshotScheduleResponse> snapshotScheduleResponses = new ArrayList<SnapshotScheduleResponse>();
for (SnapshotSchedule snapshotSchedule : snapshotSchedules) {
SnapshotScheduleResponse snapSchedResponse = _responseGenerator.createSnapshotScheduleResponse(snapshotSchedule);
snapshotScheduleResponses.add(snapSchedResponse);
}
response.setResponses(snapshotScheduleResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations