use of com.cloud.api.response.TemplateResponse in project CloudStack-archive by CloudStack-extras.
the class CreateTemplateCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Template Id: " + getEntityId() + ((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId()));
VirtualMachineTemplate template = null;
if (isBareMetal()) {
template = _bareMetalVmService.createPrivateTemplate(this);
} else {
template = _userVmService.createPrivateTemplate(this);
}
if (template != null) {
List<TemplateResponse> templateResponses;
if (isBareMetal()) {
templateResponses = _responseGenerator.createTemplateResponses(template.getId(), vmId);
} else {
templateResponses = _responseGenerator.createTemplateResponses(template.getId(), snapshotId, volumeId, false);
}
TemplateResponse response = new TemplateResponse();
if (templateResponses != null && !templateResponses.isEmpty()) {
response = templateResponses.get(0);
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create private template");
}
}
use of com.cloud.api.response.TemplateResponse in project CloudStack-archive by CloudStack-extras.
the class UpdateIsoCmd method execute.
@Override
public void execute() {
VirtualMachineTemplate result = _mgr.updateTemplate(this);
if (result != null) {
TemplateResponse response = _responseGenerator.createIsoResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update iso");
}
}
use of com.cloud.api.response.TemplateResponse in project CloudStack-archive by CloudStack-extras.
the class PrepareTemplateCmd method execute.
@Override
public void execute() {
ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
VirtualMachineTemplate vmTemplate = _templateService.prepareTemplate(templateId, zoneId);
List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(vmTemplate.getId(), zoneId, true);
response.setResponses(templateResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.TemplateResponse in project CloudStack-archive by CloudStack-extras.
the class UpdateTemplateCmd method execute.
@Override
public void execute() {
VirtualMachineTemplate result = _mgr.updateTemplate(this);
if (result != null) {
TemplateResponse response = _responseGenerator.createIsoResponse(result);
response.setObjectName("template");
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update template");
}
}
use of com.cloud.api.response.TemplateResponse in project CloudStack-archive by CloudStack-extras.
the class RegisterTemplateCmd method execute.
@Override
public void execute() throws ResourceAllocationException {
try {
VirtualMachineTemplate template = _templateService.registerTemplate(this);
if (template != null) {
ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(template.getId(), zoneId, false);
response.setResponses(templateResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register template");
}
} catch (URISyntaxException ex1) {
s_logger.info(ex1);
throw new ServerApiException(BaseCmd.PARAM_ERROR, ex1.getMessage());
}
}
Aggregations