Search in sources :

Example 1 with RetrieveImageDataParameters

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");
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) RetrieveImageDataParameters(org.ovirt.engine.core.bll.RetrieveImageDataParameters)

Example 2 with RetrieveImageDataParameters

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<>();
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) OvfEntityData(org.ovirt.engine.core.common.businessentities.OvfEntityData) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) RetrieveImageDataParameters(org.ovirt.engine.core.bll.RetrieveImageDataParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

RetrieveImageDataParameters (org.ovirt.engine.core.bll.RetrieveImageDataParameters)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 ArrayList (java.util.ArrayList)1 OvfEntityData (org.ovirt.engine.core.common.businessentities.OvfEntityData)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)1 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)1