Search in sources :

Example 11 with RepoImage

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

the class BaseVmListModelTest method mockCdListModel.

protected ListModel<RepoImage> mockCdListModel() {
    final ListModel<RepoImage> model = mockListModel(new RepoImage(ISO_NAME));
    when(model.getIsChangable()).thenReturn(true);
    return model;
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

Example 12 with RepoImage

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

the class RunVmCommand method guestToolsVersionTreatment.

/**
 * If vds version greater then vm's and vm not running with cd and there is appropriate RhevAgentTools image -
 * add it to vm as cd.
 */
private String guestToolsVersionTreatment() {
    boolean attachCd = false;
    String selectedToolsVersion = "";
    String selectedToolsClusterVersion = "";
    Guid isoDomainId = getActiveIsoDomainId();
    if (osRepository.isWindows(getVm().getVmOsId()) && null != isoDomainId) {
        // get cluster version of the vm tools
        Version vmToolsClusterVersion = null;
        if (getVm().getHasAgent()) {
            Version clusterVer = getVm().getPartialVersion();
            if (new Version("4.4").equals(clusterVer)) {
                vmToolsClusterVersion = new Version("2.1");
            } else {
                vmToolsClusterVersion = clusterVer;
            }
        }
        // Fetch cached Iso files from active Iso domain.
        List<RepoImage> repoFilesMap = getIsoDomainListSynchronizer().getCachedIsoListByDomainId(isoDomainId, ImageFileType.ISO);
        Version bestClusterVer = null;
        int bestToolVer = 0;
        for (RepoImage map : repoFilesMap) {
            String fileName = StringUtils.defaultString(map.getRepoImageId(), "");
            Matcher matchToolPattern = Pattern.compile(IsoDomainListSynchronizer.REGEX_TOOL_PATTERN).matcher(fileName);
            if (matchToolPattern.find()) {
                // Get cluster version and tool version of Iso tool.
                Version clusterVer = new Version(matchToolPattern.group(IsoDomainListSynchronizer.TOOL_CLUSTER_LEVEL));
                int toolVersion = Integer.parseInt(matchToolPattern.group(IsoDomainListSynchronizer.TOOL_VERSION));
                if (clusterVer.compareTo(getVm().getCompatibilityVersion()) <= 0) {
                    if ((bestClusterVer == null) || (clusterVer.compareTo(bestClusterVer) > 0)) {
                        bestToolVer = toolVersion;
                        bestClusterVer = clusterVer;
                    } else if (clusterVer.equals(bestClusterVer) && toolVersion > bestToolVer) {
                        bestToolVer = toolVersion;
                        bestClusterVer = clusterVer;
                    }
                }
            }
        }
        if (bestClusterVer != null && (vmToolsClusterVersion == null || vmToolsClusterVersion.compareTo(bestClusterVer) < 0 || (vmToolsClusterVersion.equals(bestClusterVer) && getVm().getHasAgent() && getVm().getGuestAgentVersion().getBuild() < bestToolVer))) {
            // Vm has no tools or there are new tools
            selectedToolsVersion = Integer.toString(bestToolVer);
            selectedToolsClusterVersion = bestClusterVer.toString();
            attachCd = true;
        }
    }
    if (attachCd) {
        String rhevToolsPath = String.format("%1$s%2$s_%3$s.iso", IsoDomainListSynchronizer.getGuestToolsSetupIsoPrefix(), selectedToolsClusterVersion, selectedToolsVersion);
        String isoDir = (String) runVdsCommand(VDSCommandType.IsoDirectory, new IrsBaseVDSCommandParameters(getVm().getStoragePoolId())).getReturnValue();
        rhevToolsPath = isoDir + File.separator + rhevToolsPath;
        return rhevToolsPath;
    }
    return null;
}
Also used : IrsBaseVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.IrsBaseVDSCommandParameters) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) Version(org.ovirt.engine.core.compat.Version) Matcher(java.util.regex.Matcher) Guid(org.ovirt.engine.core.compat.Guid)

Example 13 with RepoImage

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

the class BackendFilesResource method listFiles.

protected List<String> listFiles() {
    GetImagesListParameters queryParams = new GetImagesListParameters(asGuid(storageDomainId), ImageFileType.All);
    Boolean forceRefresh = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, FORCE_REFRESH, null, null);
    queryParams.setForceRefresh(forceRefresh);
    List<RepoImage> files = getBackendCollection(RepoImage.class, QueryType.GetImagesList, queryParams);
    return files.stream().map(RepoImage::getRepoImageId).collect(toList());
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) GetImagesListParameters(org.ovirt.engine.core.common.queries.GetImagesListParameters)

Example 14 with RepoImage

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

the class RepoFileMetaDataDaoTest method testSave.

/**
 * Ensures that saving a domain works as expected.
 */
@Test
public void testSave() {
    // Fetch the file from cache table
    List<RepoImage> listOfRepoFiles = repoFileMetaDataDao.getRepoListForStorageDomain(FixturesTool.STORAGE_DOMAIN_NFS_ISO, ImageFileType.ISO);
    assertNotNull(listOfRepoFiles);
    assertTrue(listOfRepoFiles.isEmpty());
    RepoImage newRepoFileMap = getNewIsoRepoFile();
    repoFileMetaDataDao.addRepoFileMap(newRepoFileMap);
    listOfRepoFiles = repoFileMetaDataDao.getRepoListForStorageDomain(FixturesTool.STORAGE_DOMAIN_NFS_ISO, ImageFileType.ISO);
    assertFalse(listOfRepoFiles.isEmpty());
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) Test(org.junit.Test)

Example 15 with RepoImage

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

the class RepoFileMetaDataDaoTest method getNewIsoRepoFile.

private static RepoImage getNewIsoRepoFile() {
    RepoImage newRepoFileMap = new RepoImage();
    newRepoFileMap.setFileType(ImageFileType.ISO);
    newRepoFileMap.setRepoImageId("isoDomain.iso");
    newRepoFileMap.setLastRefreshed(System.currentTimeMillis());
    newRepoFileMap.setSize(null);
    newRepoFileMap.setDateCreated(null);
    newRepoFileMap.setRepoDomainId(FixturesTool.STORAGE_DOMAIN_NFS_ISO);
    return newRepoFileMap;
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

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