Search in sources :

Example 21 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class GetImagesListByStoragePoolIdQueryTest method initQuery.

@Override
protected void initQuery(GetImagesListByStoragePoolIdQuery<? extends GetImagesListByStoragePoolIdParameters> query) {
    super.initQuery(query);
    RepoImage rfmd = new RepoImage();
    rfmd.setFileType(expectedType);
    doReturn(Collections.singletonList(rfmd)).when(query).getUserRequestForStorageDomainRepoFileList();
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

Example 22 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class IsoDomainListSynchronizer method handleErrorLog.

/**
 * Print information on the problematic storage domain. Mainly transfer the business entity to list, for handling
 * the error uniformly.
 * Create a mock RepoImage object in a list, to use the functionality of the handleErrorLog with list.
 *
 * @param storagePoolId
 *            - The storage pool Id.
 * @param storageDomainId
 *            - The storage domain Id.
 * @param imageType
 *            - The file type extension (ISO  or Floppy).
 * @see #handleErrorLog(List)
 */
private void handleErrorLog(Guid storagePoolId, Guid storageDomainId, ImageFileType imageType) {
    List<RepoImage> tempProblematicRepoFileList = new ArrayList<>();
    RepoImage repoImage = createMockRepositoryFileMetaData(storageDomainId, imageType, storagePoolId);
    // Add the repository file to the list, and use handleError.
    tempProblematicRepoFileList.add(repoImage);
    handleErrorLog(tempProblematicRepoFileList);
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) ArrayList(java.util.ArrayList)

Example 23 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class IsoDomainListSynchronizer method refreshRepos.

private boolean refreshRepos(Guid storageDomainId, ImageFileType imageType) {
    boolean refreshResult;
    List<RepoImage> tempProblematicRepoFileList = new ArrayList<>();
    StorageDomain storageDomain = storageDomainDao.get(storageDomainId);
    if (storageDomain.getStorageDomainType() == StorageDomainType.ISO) {
        refreshResult = refreshIsoDomain(storageDomainId, tempProblematicRepoFileList, imageType);
    } else if (storageDomain.getStorageDomainType() == StorageDomainType.Image && storageDomain.getStorageType() == StorageType.GLANCE) {
        refreshResult = refreshImageDomain(storageDomain, imageType);
    } else {
        log.error("Unable to refresh the storage domain '{}', Storage Domain Type '{}' not supported", storageDomainId, storageDomain.getStorageDomainType());
        return false;
    }
    handleErrorLog(tempProblematicRepoFileList);
    // If refresh succeeded update the audit log
    if (refreshResult) {
        addToAuditLogSuccessMessage(storageDomain, imageType.name());
    }
    return refreshResult;
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) ArrayList(java.util.ArrayList)

Example 24 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage 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)

Example 25 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class IsoDomainListSynchronizer method handleErrorLog.

/**
 * Print information on the problematic storage domains and print an audit log.<BR/>
 * If the problematicFileListForHandleError list retrieved empty or null,<BR/>
 * then don't do nothing and return false flag.
 *
 * @param problematicFileListForHandleError
 *            - List of repository file meta data, each one indicating a problematic repository domain.
 * @return true, if has problematic storage domains, false otherwise (List is empty).
 */
private boolean handleErrorLog(List<RepoImage> problematicFileListForHandleError) {
    boolean hasProblematic = false;
    if (problematicFileListForHandleError != null && !problematicFileListForHandleError.isEmpty()) {
        StringBuilder problematicStorages = new StringBuilder();
        StringBuilder problematicIsoDomainsForAuditLog = new StringBuilder();
        Set<String> storageDomainNames = new HashSet<>();
        for (RepoImage repoMap : problematicFileListForHandleError) {
            problematicStorages.append(buildDetailedProblematicMapMsg(repoMap));
            storageDomainNames.add(buildDetailedAuditLogMessage(repoMap));
        }
        // Build Audit log message with problematic domains.
        for (String domainName : storageDomainNames) {
            problematicIsoDomainsForAuditLog.append("  ").append(domainName);
        }
        hasProblematic = true;
        log.error("The following storage domains had a problem retrieving data from VDSM: {}", problematicStorages);
        addToAuditLogErrorMessage(problematicIsoDomainsForAuditLog.toString());
    }
    return hasProblematic;
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) HashSet(java.util.HashSet)

Aggregations

RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)41 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)5 Guid (org.ovirt.engine.core.compat.Guid)5 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)4 InstanceType (org.ovirt.engine.core.common.businessentities.InstanceType)3 Quota (org.ovirt.engine.core.common.businessentities.Quota)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 NullSafeRenderer (org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Lock (java.util.concurrent.locks.Lock)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)2 ListModelTypeAheadChangeableListBoxEditor (org.ovirt.engine.ui.common.widget.editor.ListModelTypeAheadChangeableListBoxEditor)2 VncKeyMapRenderer (org.ovirt.engine.ui.common.widget.editor.VncKeyMapRenderer)2 EntityModelCheckBoxEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)2