Search in sources :

Example 26 with TemplateResponse

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");
    }
}
Also used : VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) ServerApiException(com.cloud.api.ServerApiException) TemplateResponse(com.cloud.api.response.TemplateResponse)

Example 27 with TemplateResponse

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");
    }
}
Also used : VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) ServerApiException(com.cloud.api.ServerApiException) TemplateResponse(com.cloud.api.response.TemplateResponse)

Example 28 with TemplateResponse

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");
    }
}
Also used : VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) TemplateResponse(com.cloud.api.response.TemplateResponse)

Aggregations

TemplateResponse (com.cloud.api.response.TemplateResponse)28 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)20 ServerApiException (com.cloud.api.ServerApiException)18 ListResponse (com.cloud.api.response.ListResponse)10 TemplateJoinVO (com.cloud.api.query.vo.TemplateJoinVO)5 ArrayList (java.util.ArrayList)5 ResourceTagJoinVO (com.cloud.api.query.vo.ResourceTagJoinVO)3 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)3 URISyntaxException (java.net.URISyntaxException)3 ResponseView (com.cloud.api.ResponseObject.ResponseView)2 Account (com.cloud.user.Account)2 HashMap (java.util.HashMap)2 Hashtable (java.util.Hashtable)2 List (java.util.List)2 ListIsosCmdByAdmin (com.cloud.api.command.admin.iso.ListIsosCmdByAdmin)1 ListTemplatesCmdByAdmin (com.cloud.api.command.admin.template.ListTemplatesCmdByAdmin)1 LinkedHashMap (java.util.LinkedHashMap)1