use of com.cloud.api.response.ExtractResponse in project CloudStack-archive by CloudStack-extras.
the class ExtractIsoCmd 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());
response.setObjectName("iso");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to extract iso");
}
} catch (InternalErrorException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}
use of com.cloud.api.response.ExtractResponse in project CloudStack-archive by CloudStack-extras.
the class ExtractVolumeCmd method execute.
@Override
public void execute() {
try {
UserContext.current().setEventDetails("Volume Id: " + getId());
Long uploadId = _mgr.extractVolume(this);
if (uploadId != null) {
Upload uploadInfo = _entityMgr.findById(Upload.class, uploadId);
ExtractResponse response = new ExtractResponse();
response.setResponseName(getCommandName());
response.setObjectName("volume");
response.setIdentityTableName("volumes");
response.setId(id);
response.setName(_entityMgr.findById(Volume.class, id).getName());
response.setZoneId(zoneId);
response.setZoneName(_entityMgr.findById(DataCenter.class, zoneId).getName());
response.setMode(mode);
response.setUploadId(uploadId);
response.setState(uploadInfo.getUploadState().toString());
response.setAccountId(getEntityOwnerId());
response.setUrl(uploadInfo.getUploadUrl());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to extract volume");
}
} catch (URISyntaxException ex) {
s_logger.info(ex);
throw new ServerApiException(BaseCmd.PARAM_ERROR, ex.getMessage());
}
}
use of com.cloud.api.response.ExtractResponse in project cosmic by MissionCriticalCloud.
the class ExtractIsoCmd 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());
response.setObjectName("iso");
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to extract ISO");
}
} catch (final InternalErrorException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
use of com.cloud.api.response.ExtractResponse in project cosmic by MissionCriticalCloud.
the class ExtractVolumeCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Volume Id: " + getId());
final String uploadUrl = _volumeService.extractVolume(this);
if (uploadUrl != null) {
final ExtractResponse response = new ExtractResponse();
response.setResponseName(getCommandName());
response.setObjectName("volume");
final Volume vol = _entityMgr.findById(Volume.class, id);
response.setId(vol.getUuid());
response.setName(vol.getName());
final DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
response.setZoneId(zone.getUuid());
response.setZoneName(zone.getName());
response.setMode(mode);
response.setState(Upload.Status.DOWNLOAD_URL_CREATED.toString());
final Account account = _entityMgr.findById(Account.class, getEntityOwnerId());
response.setAccountId(account.getUuid());
response.setUrl(uploadUrl);
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to extract volume");
}
}
use of com.cloud.api.response.ExtractResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createExtractResponse.
// TODO: we need to deprecate uploadVO, since extract is done in a synchronous fashion
@Override
public ExtractResponse createExtractResponse(final Long id, final Long zoneId, final Long accountId, final String mode, final String url) {
final ExtractResponse response = new ExtractResponse();
response.setObjectName("template");
final VMTemplateVO template = ApiDBUtils.findTemplateById(id);
response.setId(template.getUuid());
response.setName(template.getName());
if (zoneId != null) {
final DataCenter zone = ApiDBUtils.findZoneById(zoneId);
response.setZoneId(zone.getUuid());
response.setZoneName(zone.getName());
}
response.setMode(mode);
response.setUrl(url);
response.setState(Upload.Status.DOWNLOAD_URL_CREATED.toString());
final Account account = ApiDBUtils.findAccountById(accountId);
response.setAccountId(account.getUuid());
return response;
}
Aggregations