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());
}
}
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());
}
}
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());
}
}
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");
}
}
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());
}
}
Aggregations