use of org.apache.cloudstack.api.response.RollingMaintenanceResponse in project cloudstack by apache.
the class StartRollingMaintenanceCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
Ternary<Boolean, String, Pair<List<RollingMaintenanceManager.HostUpdated>, List<RollingMaintenanceManager.HostSkipped>>> result = manager.startRollingMaintenance(this);
Boolean success = result.first();
String details = result.second();
Pair<List<RollingMaintenanceManager.HostUpdated>, List<RollingMaintenanceManager.HostSkipped>> pair = result.third();
List<RollingMaintenanceManager.HostUpdated> hostsUpdated = pair.first();
List<RollingMaintenanceManager.HostSkipped> hostsSkipped = pair.second();
RollingMaintenanceResponse response = _responseGenerator.createRollingMaintenanceResponse(success, details, hostsUpdated, hostsSkipped);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.RollingMaintenanceResponse in project cloudstack by apache.
the class ApiResponseHelper method createRollingMaintenanceResponse.
@Override
public RollingMaintenanceResponse createRollingMaintenanceResponse(Boolean success, String details, List<RollingMaintenanceManager.HostUpdated> hostsUpdated, List<RollingMaintenanceManager.HostSkipped> hostsSkipped) {
RollingMaintenanceResponse response = new RollingMaintenanceResponse(success, details);
List<RollingMaintenanceHostUpdatedResponse> updated = new ArrayList<>();
for (RollingMaintenanceManager.HostUpdated h : hostsUpdated) {
RollingMaintenanceHostUpdatedResponse r = new RollingMaintenanceHostUpdatedResponse();
r.setHostId(h.getHost().getUuid());
r.setHostName(h.getHost().getName());
r.setStartDate(getDateStringInternal(h.getStart()));
r.setEndDate(getDateStringInternal(h.getEnd()));
r.setOutput(h.getOutputMsg());
updated.add(r);
}
List<RollingMaintenanceHostSkippedResponse> skipped = new ArrayList<>();
for (RollingMaintenanceManager.HostSkipped h : hostsSkipped) {
RollingMaintenanceHostSkippedResponse r = new RollingMaintenanceHostSkippedResponse();
r.setHostId(h.getHost().getUuid());
r.setHostName(h.getHost().getName());
r.setReason(h.getReason());
skipped.add(r);
}
response.setUpdatedHosts(updated);
response.setSkippedHosts(skipped);
response.setObjectName("rollingmaintenance");
return response;
}
Aggregations