use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class ImportRepoImageModel method setRepoImages.
public void setRepoImages(List<RepoImage> repoImages) {
ArrayList<EntityModel> entities = new ArrayList<>();
for (RepoImage i : repoImages) {
entities.add(new RepoImageModel(i));
}
setEntities(entities);
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class OpenStackImageProviderProxy method imageToRepoImage.
private static RepoImage imageToRepoImage(Image glanceImage) {
RepoImage repoImage = new RepoImage();
repoImage.setSize(glanceImage.getSize());
repoImage.setDateCreated(null);
repoImage.setRepoImageId(glanceImage.getId());
repoImage.setRepoImageName(glanceImage.getName());
if (glanceImage.getContainerFormat() == null || glanceImage.getDiskFormat() == null || !glanceImage.getContainerFormat().equals(GlanceImageContainer.BARE.getValue())) {
repoImage.setFileType(ImageFileType.Unknown);
} else {
if (glanceImage.getDiskFormat().equals(GlanceImageFormat.RAW.getValue()) || glanceImage.getDiskFormat().equals(GlanceImageFormat.COW.getValue())) {
repoImage.setFileType(ImageFileType.Disk);
} else if (glanceImage.getDiskFormat().equals(GlanceImageFormat.ISO.getValue())) {
repoImage.setFileType(ImageFileType.ISO);
} else {
repoImage.setFileType(ImageFileType.Unknown);
}
}
return repoImage;
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class RepoFileMetaDataDaoTest method testUpdateRepoFileByRemoveAndInsert.
/**
* Test update of Iso file. The test demonstrate the refresh procedure. It first deletes the Iso file from the
* repo_file_meta_data table, and then insert the new files fetched again from VDSM.
*/
@Test
public void testUpdateRepoFileByRemoveAndInsert() {
RepoImage newRepoFileMap = getNewIsoRepoFile();
repoFileMetaDataDao.addRepoFileMap(newRepoFileMap);
// Fetch the file from cache table
List<RepoImage> listOfRepoFiles = getActiveIsoDomain();
// Get first file and update its String
assertNotNull(listOfRepoFiles);
assertFalse(listOfRepoFiles.isEmpty());
RepoImage repoFile = listOfRepoFiles.get(0);
assertNotNull(repoFile);
String oldRepoImageId = repoFile.getRepoImageId();
newRepoFileMap.setRepoImageId("updatedFileName" + newRepoFileMap.getRepoImageId());
// Remove the file from cache table
repoFileMetaDataDao.removeRepoDomainFileList(FixturesTool.STORAGE_DOMAIN_NFS_ISO, ImageFileType.ISO);
// Add the new updated file into the cache table.
repoFileMetaDataDao.addRepoFileMap(newRepoFileMap);
// Fetch the updated File.
listOfRepoFiles = getActiveIsoDomain();
assertNotNull(listOfRepoFiles);
assertFalse(listOfRepoFiles.isEmpty());
RepoImage newRepoFile = listOfRepoFiles.get(0);
assertNotNull(repoFile);
// Check if not same file name as in the old file.
assertNotSame(oldRepoImageId, newRepoFile.getRepoImageId());
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class StorageIsoListModel method importImages.
private void importImages() {
List<RepoImage> repoImages = getSelectedItems();
if (repoImages == null || getWindow() != null) {
return;
}
ImportRepoImageModel model = new ImportRepoImageModel(this);
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().importImagesTitle());
model.setHelpTag(HelpTag.import_images);
// $NON-NLS-1$
model.setHashName("import_images");
model.setEntity(this);
model.init(getEntity(), repoImages);
// $NON-NLS-1$
UICommand cancelCommand = UICommand.createCancelUiCommand("Cancel", this);
model.setCancelCommand(cancelCommand);
model.getCommands().add(cancelCommand);
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class StorageIsoListModel method syncSearch.
@Override
protected void syncSearch() {
if (getEntity() == null) {
return;
}
super.syncSearch();
StorageDomain storageDomain = getEntity();
boolean isDomainActive = storageDomain.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Active || storageDomain.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Mixed;
if (storageDomain.getStorageDomainType() == StorageDomainType.ISO && !isDomainActive) {
setItems(Collections.emptyList());
return;
}
GetImagesListParameters imagesListParams = new GetImagesListParameters(storageDomain.getId(), ImageFileType.All);
imagesListParams.setForceRefresh(true);
imagesListParams.setRefresh(getIsQueryFirstTime());
startProgress();
AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
stopProgress();
ArrayList<RepoImage> repoImageList = new ArrayList<>();
if (returnValue != null && returnValue.getReturnValue() != null && returnValue.getSucceeded()) {
repoImageList = returnValue.getReturnValue();
repoImageList.sort(Comparator.comparing(RepoImage::getRepoImageId));
}
setItems(repoImageList);
setIsEmpty(repoImageList.isEmpty());
});
asyncQuery.setHandleFailure(true);
Frontend.getInstance().runQuery(QueryType.GetImagesList, imagesListParams, asyncQuery);
}
Aggregations