use of org.ovirt.engine.core.bll.RetrieveImageDataParameters in project ovirt-engine by oVirt.
the class HostedEngineConfigFetcher method downloadDisk.
private byte[] downloadDisk(Guid spId, Guid sdId, DiskImage diskImage) {
long downloadSize = Config.<Integer>getValue(ConfigValues.HostedEngineConfigDiskSizeInBytes);
log.info("Found the HE configuration disk. Downloading the content in size of {} bytes", downloadSize);
ActionReturnValue returnValue = backend.runInternalAction(ActionType.RetrieveImageData, new RetrieveImageDataParameters(spId, sdId, diskImage.getId(), diskImage.getImageId(), downloadSize));
if (returnValue.getSucceeded()) {
return (byte[]) returnValue.getActionReturnValue();
} else {
throw new EngineException(EngineError.ENGINE, "Failed to download the HE configuration disk");
}
}
use of org.ovirt.engine.core.bll.RetrieveImageDataParameters in project ovirt-engine by oVirt.
the class StorageHandlingCommandBase method getEntitiesFromStorageOvfDisk.
protected List<OvfEntityData> getEntitiesFromStorageOvfDisk(Guid storageDomainId, Guid storagePoolId) {
// Initialize a new ArrayList with all the ovfDisks in the specified Storage Domain,
// so the entities can be removed from the list every time we register the latest OVF disk and we can keep the
// ovfDisks cache list updated.
List<DiskImage> ovfStoreDiskImages = new ArrayList<>(getAllOVFDisks(storageDomainId, storagePoolId));
if (!ovfStoreDiskImages.isEmpty()) {
while (!ovfStoreDiskImages.isEmpty()) {
Pair<DiskImage, Long> ovfDiskAndSize = getLatestOVFDisk(ovfStoreDiskImages);
DiskImage ovfDisk = ovfDiskAndSize.getFirst();
if (ovfDisk != null) {
try {
ActionReturnValue actionReturnValueReturnValue = runInternalAction(ActionType.RetrieveImageData, new RetrieveImageDataParameters(getParameters().getStoragePoolId(), storageDomainId, ovfDisk.getId(), ovfDisk.getImage().getId(), ovfDiskAndSize.getSecond()), cloneContextAndDetachFromParent());
getReturnValue().getVdsmTaskIdList().addAll(actionReturnValueReturnValue.getInternalVdsmTaskIdList());
if (actionReturnValueReturnValue.getSucceeded()) {
List<OvfEntityData> returnedMap = ovfUtils.getOvfEntities(actionReturnValueReturnValue.getActionReturnValue(), unregisteredDisks, storageDomainId);
return returnedMap;
} else {
log.error("Image data could not be retrieved for disk id '{}' in storage domain id '{}'", ovfDisk.getId(), storageDomainId);
}
} catch (RuntimeException e) {
// We are catching RuntimeException, since the call for OvfUtils.getOvfEntities will throw
// a RuntimeException if there is a problem to untar the file.
log.error("Image data could not be retrieved for disk id '{}' in storage domain id '{}': {}", ovfDisk.getId(), storageDomainId, e.getMessage());
log.debug("Exception", e);
}
ovfStoreDiskImages.remove(ovfDisk);
} else {
log.error("Couldn't find additional ovf store to retrieve the ovf data from in storage domain '{}'", storageDomainId);
break;
}
}
AuditLogable logable = new AuditLogableImpl();
logable.setStorageDomainId(storageDomainId);
logable.setStorageDomainName(storageDomainStaticDao.get(storageDomainId).getName());
auditLogDirector.log(logable, AuditLogType.RETRIEVE_OVF_STORE_FAILED);
} else {
log.warn("There are no OVF_STORE disks on storage domain id {}", storageDomainId);
}
return new ArrayList<>();
}
Aggregations