use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class IsoDomainListSynchronizer method refreshIsoDomain.
/**
* The procedure Try to refresh the repository files of the storage domain id, By iterate over the storage pools of
* this domain, and try to choose a valid storage pool, to fetch the repository files from the VDSM, and refresh the
* cached table. <BR/>
* If succeeded, will return True. Otherwise return false with updated list of problematic repository files with the
* storage pool, storage domain, and file type, that could not complete the cache update transaction.
*
* @param storageDomainId
* - The Repository domain Id, we want to refresh.
* @param problematicRepoFileList
* - List of business entities, each one indicating the problematic entity.
* @param imageType
* - The imageType we want to fetch the files from the cache.
* @return Boolean value indicating if the refresh succeeded or not.
*/
private boolean refreshIsoDomain(Guid storageDomainId, List<RepoImage> problematicRepoFileList, ImageFileType imageType) {
List<StoragePoolIsoMap> isoMapList = fetchAllStoragePoolsForIsoDomain(storageDomainId, imageType);
for (StoragePoolIsoMap storagePoolIsoMap : isoMapList) {
Guid storagePoolId = storagePoolIsoMap.getStoragePoolId();
StorageDomainStatus status = storagePoolIsoMap.getStatus();
if (StorageDomainStatus.Active != status) {
handleInactiveStorageDomain(storageDomainId, imageType, status);
} else {
// Try to refresh the domain of the storage pool id because its status is active.
boolean refreshOk = refreshIsoDomainFileForStoragePool(storageDomainId, storagePoolId, imageType);
if (!refreshOk) {
log.debug("Failed refreshing Storage domain id '{}', for '{}' file type in storage pool id '{}'.", storageDomainId, imageType, storagePoolId);
// Add the repository file to the list of problematic Iso domains.
RepoImage repoImage = createMockRepositoryFileMetaData(storageDomainId, imageType, storagePoolId);
problematicRepoFileList.add(repoImage);
return false;
}
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class IsoDomainListSynchronizer method createMockRepositoryFileMetaData.
// set a mock repository file meta data with storage domain id and storage pool id.
private static RepoImage createMockRepositoryFileMetaData(Guid storageDomainId, ImageFileType imageType, Guid storagePoolId) {
RepoImage repoImage = new RepoImage();
repoImage.setStoragePoolId(storagePoolId);
repoImage.setRepoDomainId(storageDomainId);
repoImage.setFileType(imageType);
return repoImage;
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class IsoDomainListSynchronizer method refreshIsoFileListMetaData.
private boolean refreshIsoFileListMetaData(final Guid repoStorageDomainId, final Map<String, Map<String, Object>> fileStats, final ImageFileType imageType) {
Lock syncObject = getSyncObject(repoStorageDomainId, imageType);
try {
syncObject.lock();
return (Boolean) TransactionSupport.executeInScope(TransactionScopeOption.RequiresNew, new TransactionMethod<Object>() {
@Override
public Object runInTransaction() {
long currentTime = System.currentTimeMillis();
repoFileMetaDataDao.removeRepoDomainFileList(repoStorageDomainId, imageType);
for (Map.Entry<String, Map<String, Object>> entry : fileStats.entrySet()) {
repoFileMetaDataDao.addRepoFileMap(newRepoImage(currentTime, entry));
}
return true;
}
public RepoImage newRepoImage(long currentTime, Map.Entry<String, Map<String, Object>> entry) {
RepoImage repo_md = new RepoImage();
repo_md.setLastRefreshed(currentTime);
repo_md.setSize(retrieveIsoFileSize(entry));
repo_md.setRepoDomainId(repoStorageDomainId);
repo_md.setDateCreated(null);
repo_md.setRepoImageId(entry.getKey());
repo_md.setRepoImageName(null);
repo_md.setFileType(imageType);
return repo_md;
}
});
} catch (Exception e) {
log.warn("Updating repository content to DB failed for repoStorageDomainId={}, imageType={}: {}", repoStorageDomainId, imageType, e.getMessage());
log.debug("Exception", e);
return false;
} finally {
syncObject.unlock();
}
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class BackendFilesResourceTest method setUpFiles.
private List<RepoImage> setUpFiles() {
List<RepoImage> isos = new ArrayList<>();
for (int i = 0; i < NAMES.length; i++) {
RepoImage file = new RepoImage();
file.setRepoImageId(NAMES[i]);
isos.add(file);
}
return isos;
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class ImportRepoImageModel method executeCommand.
@Override
public void executeCommand(UICommand command) {
if (!validate()) {
return;
}
super.executeCommand(command);
startProgress();
ArrayList<ActionParametersBase> actionParameters = new ArrayList<>();
final StringBuilder imageNames = new StringBuilder();
for (EntityModel entity : getEntities()) {
RepoImage repoImage = (RepoImage) entity.getEntity();
// $NON-NLS-1$
imageNames.append("\n -");
imageNames.append(repoImage.getRepoImageName());
ImportRepoImageParameters importParameters = new ImportRepoImageParameters();
// source
importParameters.setSourceRepoImageId(repoImage.getRepoImageId());
importParameters.setSourceStorageDomainId(sourceStorageDomain.getId());
// destination
importParameters.setDiskAlias(((RepoImageModel) entity).getDiskImageAlias());
importParameters.setStoragePoolId(getDataCenter().getSelectedItem().getId());
importParameters.setStorageDomainId(getStorageDomain().getSelectedItem().getId());
importParameters.setClusterId(getStorageDomain().getSelectedItem().getId());
Quota selectedQuota = getQuota().getSelectedItem();
if (selectedQuota != null) {
importParameters.setQuotaId(selectedQuota.getId());
}
Boolean importAsTemplate = getImportAsTemplate().getEntity();
importParameters.setImportAsTemplate(importAsTemplate);
if (importAsTemplate) {
importParameters.setClusterId(getCluster().getSelectedItem().getId());
String templateName = getTemplateName().getEntity();
if (StringHelper.isNotNullOrEmpty(templateName)) {
importParameters.setTemplateName(templateName);
}
}
actionParameters.add(importParameters);
}
Frontend.getInstance().runMultipleAction(ActionType.ImportRepoImage, actionParameters, result -> {
ImportExportRepoImageBaseModel model = (ImportExportRepoImageBaseModel) result.getState();
model.stopProgress();
model.cancel();
ConfirmationModel confirmModel = new ConfirmationModel();
storageIsoListModel.setConfirmWindow(confirmModel);
confirmModel.setTitle(ConstantsManager.getInstance().getConstants().importImagesTitle());
confirmModel.setHelpTag(HelpTag.import_images);
// $NON-NLS-1$
confirmModel.setHashName("import_images");
confirmModel.setMessage(ConstantsManager.getInstance().getMessages().importProcessHasBegunForImages(imageNames.toString()));
confirmModel.getCommands().add(// $NON-NLS-1$
new UICommand("CancelConfirm", storageIsoListModel).setTitle(ConstantsManager.getInstance().getConstants().close()).setIsDefault(true).setIsCancel(true));
}, this);
}
Aggregations