use of com.cloud.api.response.TemplateResponse in project cosmic by MissionCriticalCloud.
the class UpdateIsoCmdByAdmin method execute.
@Override
public void execute() {
final VirtualMachineTemplate result = _templateService.updateTemplate(this);
if (result != null) {
final TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update iso");
}
}
use of com.cloud.api.response.TemplateResponse in project cosmic by MissionCriticalCloud.
the class CopyTemplateCmdByAdmin method execute.
@Override
public void execute() throws ResourceAllocationException {
try {
CallContext.current().setEventDetails(getEventDescription());
final VirtualMachineTemplate template = _templateService.copyTemplate(this);
if (template != null) {
final List<TemplateResponse> listResponse = _responseGenerator.createTemplateResponses(ResponseView.Full, template, getDestinationZoneId(), false);
TemplateResponse response = new TemplateResponse();
if (listResponse != null && !listResponse.isEmpty()) {
response = listResponse.get(0);
}
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to copy template");
}
} catch (final StorageUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
}
}
use of com.cloud.api.response.TemplateResponse in project cosmic by MissionCriticalCloud.
the class PrepareTemplateCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final ListResponse<TemplateResponse> response = new ListResponse<>();
final VirtualMachineTemplate vmTemplate = _templateService.prepareTemplate(templateId, zoneId, storageId);
final List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, vmTemplate, zoneId, true);
response.setResponses(templateResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of com.cloud.api.response.TemplateResponse in project cosmic by MissionCriticalCloud.
the class RegisterTemplateCmdByAdmin method execute.
@Override
public void execute() throws ResourceAllocationException {
try {
final VirtualMachineTemplate template = _templateService.registerTemplate(this);
if (template != null) {
final ListResponse<TemplateResponse> response = new ListResponse<>();
final List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, template, zoneId, false);
response.setResponses(templateResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register template");
}
} catch (final URISyntaxException ex1) {
s_logger.info(ex1.toString());
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex1.getMessage());
}
}
use of com.cloud.api.response.TemplateResponse in project cosmic by MissionCriticalCloud.
the class CopyTemplateCmd method execute.
@Override
public void execute() throws ResourceAllocationException {
try {
CallContext.current().setEventDetails(getEventDescription());
final VirtualMachineTemplate template = _templateService.copyTemplate(this);
if (template != null) {
final List<TemplateResponse> listResponse = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template, getDestinationZoneId(), false);
TemplateResponse response = new TemplateResponse();
if (listResponse != null && !listResponse.isEmpty()) {
response = listResponse.get(0);
}
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to copy template");
}
} catch (final StorageUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
}
}
Aggregations