Search in sources :

Example 1 with HostResponse

use of com.cloud.api.response.HostResponse in project CloudStack-archive by CloudStack-extras.

the class UpdateHostCmd method execute.

@Override
public void execute() {
    Host result;
    try {
        result = _resourceService.updateHost(this);
        HostResponse hostResponse = _responseGenerator.createHostResponse(result);
        hostResponse.setResponseName(getCommandName());
        this.setResponseObject(hostResponse);
    } catch (Exception e) {
        s_logger.debug("Failed to update host:" + getId(), e);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update host:" + getId() + "," + e.getMessage());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) HostResponse(com.cloud.api.response.HostResponse) Host(com.cloud.host.Host) ServerApiException(com.cloud.api.ServerApiException) NoTransitionException(com.cloud.utils.fsm.NoTransitionException)

Example 2 with HostResponse

use of com.cloud.api.response.HostResponse in project CloudStack-archive by CloudStack-extras.

the class ReconnectHostCmd method execute.

@Override
public void execute() {
    try {
        Host result = _resourceService.reconnectHost(this);
        if (result != null) {
            HostResponse response = _responseGenerator.createHostResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reconnect host");
        }
    } catch (Exception ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) HostResponse(com.cloud.api.response.HostResponse) Host(com.cloud.host.Host) ServerApiException(com.cloud.api.ServerApiException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException)

Example 3 with HostResponse

use of com.cloud.api.response.HostResponse in project CloudStack-archive by CloudStack-extras.

the class AddSecondaryStorageCmd method execute.

@Override
public void execute() {
    try {
        List<? extends Host> result = _resourceService.discoverHosts(this);
        HostResponse hostResponse = null;
        if (result != null && result.size() > 0) {
            for (Host host : result) {
                // There should only be one secondary storage host per add
                hostResponse = _responseGenerator.createHostResponse(host);
                hostResponse.setResponseName(getCommandName());
                hostResponse.setObjectName("secondarystorage");
                this.setResponseObject(hostResponse);
            }
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add secondary storage");
        }
    } catch (DiscoveryException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) HostResponse(com.cloud.api.response.HostResponse) Host(com.cloud.host.Host) DiscoveryException(com.cloud.exception.DiscoveryException)

Example 4 with HostResponse

use of com.cloud.api.response.HostResponse in project CloudStack-archive by CloudStack-extras.

the class CancelMaintenanceCmd method execute.

@Override
public void execute() {
    Host result = _resourceService.cancelMaintenance(this);
    if (result != null) {
        HostResponse response = _responseGenerator.createHostResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel host maintenance");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) HostResponse(com.cloud.api.response.HostResponse) Host(com.cloud.host.Host)

Example 5 with HostResponse

use of com.cloud.api.response.HostResponse in project CloudStack-archive by CloudStack-extras.

the class AddHostCmd method execute.

@Override
public void execute() {
    try {
        List<? extends Host> result = _resourceService.discoverHosts(this);
        ListResponse<HostResponse> response = new ListResponse<HostResponse>();
        List<HostResponse> hostResponses = new ArrayList<HostResponse>();
        if (result != null && result.size() > 0) {
            for (Host host : result) {
                HostResponse hostResponse = _responseGenerator.createHostResponse(host);
                hostResponses.add(hostResponse);
            }
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
        }
        response.setResponses(hostResponses);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } catch (DiscoveryException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) HostResponse(com.cloud.api.response.HostResponse) ArrayList(java.util.ArrayList) Host(com.cloud.host.Host) DiscoveryException(com.cloud.exception.DiscoveryException)

Aggregations

HostResponse (com.cloud.api.response.HostResponse)7 Host (com.cloud.host.Host)7 ServerApiException (com.cloud.api.ServerApiException)6 ListResponse (com.cloud.api.response.ListResponse)2 DiscoveryException (com.cloud.exception.DiscoveryException)2 ArrayList (java.util.ArrayList)2 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)1 List (java.util.List)1