use of com.cloud.api.response.TemplateResponse in project cosmic by MissionCriticalCloud.
the class UpdateTemplateCmdByAdmin method execute.
@Override
public void execute() {
final VirtualMachineTemplate result = _templateService.updateTemplate(this);
if (result != null) {
final TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(ResponseView.Full, result);
response.setObjectName("template");
// Template can be either USER or ROUTING type
response.setTemplateType(result.getTemplateType().toString());
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update template");
}
}
use of com.cloud.api.response.TemplateResponse in project cosmic by MissionCriticalCloud.
the class CreateTemplateCmdByAdmin method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Template Id: " + getEntityId() + ((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId()));
VirtualMachineTemplate template = null;
template = _templateService.createPrivateTemplate(this);
if (template != null) {
final List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, template.getId(), snapshotId, volumeId, false);
TemplateResponse response = new TemplateResponse();
if (templateResponses != null && !templateResponses.isEmpty()) {
response = templateResponses.get(0);
}
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private template");
}
}
use of com.cloud.api.response.TemplateResponse in project cosmic by MissionCriticalCloud.
the class RegisterIsoCmdByAdmin method execute.
@Override
public void execute() throws ResourceAllocationException {
final VirtualMachineTemplate template = _templateService.registerIso(this);
if (template != null) {
final ListResponse<TemplateResponse> response = new ListResponse<>();
final List<TemplateResponse> templateResponses = _responseGenerator.createIsoResponses(ResponseView.Full, template, zoneId, false);
response.setResponses(templateResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register iso");
}
}
Aggregations