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();
}
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);
}
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;
}
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();
}
}
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;
}
Aggregations