Search in sources :

Example 1 with SimulatorHAProvider

use of org.apache.cloudstack.ha.SimulatorHAProvider in project cloudstack by apache.

the class ConfigureSimulatorHAProviderState method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    final Host host = _resourceService.getHost(getHostId());
    if (host == null) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find host by ID: " + getHostId());
    }
    final SimulatorHAState haState = new SimulatorHAState(healthy, activity, recovery, fenceable);
    final SimulatorHAProvider simulatorHAProvider = (SimulatorHAProvider) haManager.getHAProvider(SimulatorHAProvider.class.getSimpleName().toLowerCase());
    if (simulatorHAProvider != null) {
        simulatorHAProvider.setHAStateForHost(host.getId(), haState);
    }
    final SuccessResponse response = new SuccessResponse();
    response.setSuccess(simulatorHAProvider != null);
    response.setResponseName(getCommandName());
    response.setObjectName("simulatorhaprovider");
    setResponseObject(response);
}
Also used : SimulatorHAProvider(org.apache.cloudstack.ha.SimulatorHAProvider) SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) SimulatorHAState(org.apache.cloudstack.ha.SimulatorHAState) Host(com.cloud.host.Host)

Example 2 with SimulatorHAProvider

use of org.apache.cloudstack.ha.SimulatorHAProvider in project cloudstack by apache.

the class ListSimulatorHAStateTransitions method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    final Host host = _resourceService.getHost(getHostId());
    if (host == null) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find host by ID: " + getHostId());
    }
    final SimulatorHAProvider simulatorHAProvider = (SimulatorHAProvider) haManager.getHAProvider(SimulatorHAProvider.class.getSimpleName().toLowerCase());
    List<SimulatorHAStateResponse> recentStates = new ArrayList<>();
    if (simulatorHAProvider != null) {
        recentStates = simulatorHAProvider.listHAStateTransitions(host.getId());
    }
    final ListResponse<SimulatorHAStateResponse> response = new ListResponse<>();
    response.setResponses(recentStates);
    response.setResponseName(getCommandName());
    response.setObjectName("simulatorhastatetransition");
    setResponseObject(response);
}
Also used : SimulatorHAProvider(org.apache.cloudstack.ha.SimulatorHAProvider) ServerApiException(org.apache.cloudstack.api.ServerApiException) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) Host(com.cloud.host.Host) SimulatorHAStateResponse(com.cloud.api.response.SimulatorHAStateResponse)

Aggregations

Host (com.cloud.host.Host)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 SimulatorHAProvider (org.apache.cloudstack.ha.SimulatorHAProvider)2 SimulatorHAStateResponse (com.cloud.api.response.SimulatorHAStateResponse)1 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)1 SimulatorHAState (org.apache.cloudstack.ha.SimulatorHAState)1