Search in sources :

Example 1 with UploadStreamParameters

use of org.ovirt.engine.core.bll.UploadStreamParameters in project ovirt-engine by oVirt.

the class ProcessOvfUpdateForStorageDomainCommand method performOvfUpdateForDomain.

private boolean performOvfUpdateForDomain(byte[] ovfData, StorageDomainOvfInfo storageDomainOvfInfo, DiskImage ovfDisk, List<Guid> vmAndTemplatesIds) {
    Guid storagePoolId = ovfDisk.getStoragePoolId();
    Guid storageDomainId = ovfDisk.getStorageIds().get(0);
    Guid diskId = ovfDisk.getId();
    Guid volumeId = ovfDisk.getImageId();
    storageDomainOvfInfo.setStoredOvfIds(null);
    try {
        setOvfVolumeDescription(storagePoolId, storageDomainId, diskId, volumeId, generateOvfStoreDescription(storageDomainOvfInfo.getLastUpdated(), false, null));
        storageDomainOvfInfoDao.update(storageDomainOvfInfo);
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(ovfData);
        Long size = Long.valueOf(ovfData.length);
        UploadStreamParameters uploadStreamParameters = new UploadStreamParameters(storagePoolId, storageDomainId, diskId, volumeId, byteArrayInputStream, size);
        uploadStreamParameters.setParentCommand(getActionType());
        uploadStreamParameters.setParentParameters(getParameters());
        uploadStreamParameters.setEndProcedure(EndProcedure.COMMAND_MANAGED);
        ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.UploadStream, uploadStreamParameters);
        if (actionReturnValue.getSucceeded()) {
            storageDomainOvfInfo.setStatus(StorageDomainOvfInfoStatus.UPDATED);
            storageDomainOvfInfo.setStoredOvfIds(vmAndTemplatesIds);
            storageDomainOvfInfo.setLastUpdated(updateDate);
            setOvfVolumeDescription(storagePoolId, storageDomainId, diskId, volumeId, getPostUpdateOvfStoreDescription(size));
            storageDomainOvfInfoDao.update(storageDomainOvfInfo);
            return true;
        }
    } catch (EngineException e) {
        log.warn("failed to update domain '{}' ovf store disk '{}'", storageDomainId, diskId);
    }
    failedOvfDisks.add(diskId);
    return false;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid) UploadStreamParameters(org.ovirt.engine.core.bll.UploadStreamParameters)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 UploadStreamParameters (org.ovirt.engine.core.bll.UploadStreamParameters)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 Guid (org.ovirt.engine.core.compat.Guid)1