Search in sources :

Example 1 with RollingMaintenanceResponse

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);
}
Also used : RollingMaintenanceResponse(org.apache.cloudstack.api.response.RollingMaintenanceResponse) RollingMaintenanceManager(com.cloud.resource.RollingMaintenanceManager) List(java.util.List) Pair(com.cloud.utils.Pair)

Example 2 with RollingMaintenanceResponse

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;
}
Also used : RollingMaintenanceResponse(org.apache.cloudstack.api.response.RollingMaintenanceResponse) ArrayList(java.util.ArrayList) RollingMaintenanceHostSkippedResponse(org.apache.cloudstack.api.response.RollingMaintenanceHostSkippedResponse) RollingMaintenanceManager(com.cloud.resource.RollingMaintenanceManager) RollingMaintenanceHostUpdatedResponse(org.apache.cloudstack.api.response.RollingMaintenanceHostUpdatedResponse)

Aggregations

RollingMaintenanceManager (com.cloud.resource.RollingMaintenanceManager)2 RollingMaintenanceResponse (org.apache.cloudstack.api.response.RollingMaintenanceResponse)2 Pair (com.cloud.utils.Pair)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 RollingMaintenanceHostSkippedResponse (org.apache.cloudstack.api.response.RollingMaintenanceHostSkippedResponse)1 RollingMaintenanceHostUpdatedResponse (org.apache.cloudstack.api.response.RollingMaintenanceHostUpdatedResponse)1