Search in sources :

Example 6 with ExtractResponse

use of com.cloud.api.response.ExtractResponse in project CloudStack-archive by CloudStack-extras.

the class ExtractTemplateCmd method execute.

@Override
public void execute() {
    try {
        UserContext.current().setEventDetails(getEventDescription());
        Long uploadId = _templateService.extract(this);
        if (uploadId != null) {
            ExtractResponse response = _responseGenerator.createExtractResponse(uploadId, id, zoneId, getEntityOwnerId(), mode);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to extract template");
        }
    } catch (InternalErrorException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : ExtractResponse(com.cloud.api.response.ExtractResponse) ServerApiException(com.cloud.api.ServerApiException) InternalErrorException(com.cloud.exception.InternalErrorException)

Example 7 with ExtractResponse

use of com.cloud.api.response.ExtractResponse in project cosmic by MissionCriticalCloud.

the class ExtractTemplateCmd method execute.

@Override
public void execute() {
    try {
        CallContext.current().setEventDetails(getEventDescription());
        final String uploadUrl = _templateService.extract(this);
        if (uploadUrl != null) {
            final ExtractResponse response = _responseGenerator.createExtractResponse(id, zoneId, getEntityOwnerId(), mode, uploadUrl);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to extract template");
        }
    } catch (final InternalErrorException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : ExtractResponse(com.cloud.api.response.ExtractResponse) ServerApiException(com.cloud.api.ServerApiException) InternalErrorException(com.cloud.exception.InternalErrorException)

Aggregations

ExtractResponse (com.cloud.api.response.ExtractResponse)7 ServerApiException (com.cloud.api.ServerApiException)6 InternalErrorException (com.cloud.exception.InternalErrorException)4 DataCenter (com.cloud.dc.DataCenter)2 Account (com.cloud.user.Account)2 Upload (com.cloud.storage.Upload)1 VMTemplateVO (com.cloud.storage.VMTemplateVO)1 Volume (com.cloud.storage.Volume)1 UserAccount (com.cloud.user.UserAccount)1 URISyntaxException (java.net.URISyntaxException)1