Search in sources :

Example 1 with OpenStackImageProviderProxy

use of org.ovirt.engine.core.bll.provider.storage.OpenStackImageProviderProxy in project ovirt-engine by oVirt.

the class ExportRepoImageCommand method executeCommand.

@Override
protected void executeCommand() {
    DiskImage diskImage = getDiskImage();
    OpenStackImageProviderProxy proxy = getProviderProxy();
    acquireImageDbLock();
    String newImageId = proxy.createImageFromDiskImage(diskImage);
    getParameters().setParentCommand(ActionType.ExportRepoImage);
    Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupID()));
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.UploadImage, new UploadImageVDSCommandParameters(getStorageDomain().getStoragePoolId(), getStorageDomain().getId(), diskImage.getId(), diskImage.getImageId(), new HttpLocationInfo(getProviderProxy().getImageUrl(newImageId), getProviderProxy().getUploadHeaders())));
    if (vdsReturnValue.getSucceeded()) {
        getReturnValue().getVdsmTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Disk, getParameters().getImageGroupID(), getParameters().getDestinationDomainId()));
    }
    getReturnValue().setActionReturnValue(newImageId);
    setSucceeded(true);
}
Also used : UploadImageVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.UploadImageVDSCommandParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) HttpLocationInfo(org.ovirt.engine.core.common.businessentities.HttpLocationInfo) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) OpenStackImageProviderProxy(org.ovirt.engine.core.bll.provider.storage.OpenStackImageProviderProxy) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 2 with OpenStackImageProviderProxy

use of org.ovirt.engine.core.bll.provider.storage.OpenStackImageProviderProxy in project ovirt-engine by oVirt.

the class IsoDomainListSynchronizer method refreshImageDomain.

private boolean refreshImageDomain(final StorageDomain storageDomain, final ImageFileType imageType) {
    Provider provider = providerDao.get(new Guid(storageDomain.getStorage()));
    final OpenStackImageProviderProxy client = providerProxyFactory.create(provider);
    Lock syncObject = getSyncObject(storageDomain.getId(), imageType);
    try {
        syncObject.lock();
        return TransactionSupport.executeInScope(TransactionScopeOption.RequiresNew, () -> {
            repoFileMetaDataDao.removeRepoDomainFileList(storageDomain.getId(), imageType);
            Integer totalListSize = Config.<Integer>getValue(ConfigValues.GlanceImageTotalListSize);
            List<RepoImage> repoImages = client.getAllImagesAsRepoImages(Config.<Integer>getValue(ConfigValues.GlanceImageListSize), totalListSize);
            if (repoImages.size() >= totalListSize) {
                AuditLogable logable = new AuditLogableImpl();
                logable.addCustomValue("imageDomain", storageDomain.getName()).addCustomValue("imageListSize", String.valueOf(repoImages.size()));
                logable.setStorageDomainId(storageDomain.getId());
                logable.setStorageDomainName(storageDomain.getName());
                auditLogDirector.log(logable, AuditLogType.REFRESH_REPOSITORY_IMAGE_LIST_INCOMPLETE);
            }
            for (RepoImage repoImage : repoImages) {
                repoImage.setRepoDomainId(storageDomain.getId());
                repoFileMetaDataDao.addRepoFileMap(repoImage);
            }
            return true;
        });
    } finally {
        syncObject.unlock();
    }
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) Guid(org.ovirt.engine.core.compat.Guid) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) OpenStackImageProviderProxy(org.ovirt.engine.core.bll.provider.storage.OpenStackImageProviderProxy) Provider(org.ovirt.engine.core.common.businessentities.Provider) ReentrantLock(java.util.concurrent.locks.ReentrantLock) Lock(java.util.concurrent.locks.Lock)

Aggregations

OpenStackImageProviderProxy (org.ovirt.engine.core.bll.provider.storage.OpenStackImageProviderProxy)2 Guid (org.ovirt.engine.core.compat.Guid)2 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)1 HttpLocationInfo (org.ovirt.engine.core.common.businessentities.HttpLocationInfo)1 Provider (org.ovirt.engine.core.common.businessentities.Provider)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1 RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)1 UploadImageVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.UploadImageVDSCommandParameters)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)1 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)1