Search in sources :

Example 31 with RepoImage

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);
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList)

Example 32 with RepoImage

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;
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

Example 33 with 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());
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) Test(org.junit.Test)

Example 34 with RepoImage

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);
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 35 with RepoImage

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);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) GetImagesListParameters(org.ovirt.engine.core.common.queries.GetImagesListParameters) ArrayList(java.util.ArrayList)

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