Search in sources :

Example 6 with OsRepository

use of org.ovirt.engine.core.common.osinfo.OsRepository in project ovirt-engine by oVirt.

the class BackendSnapshotsResourceTest method mockOsRepository.

private void mockOsRepository() {
    OsRepository mockOsRepository = mock(OsRepository.class);
    SimpleDependencyInjector.getInstance().bind(OsRepository.class, mockOsRepository);
}
Also used : OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository)

Example 7 with OsRepository

use of org.ovirt.engine.core.common.osinfo.OsRepository in project ovirt-engine by oVirt.

the class UpdateWatchdogCommandTest method setUpOsRepository.

@Before
public void setUpOsRepository() {
    OsRepository osRepository = mock(OsRepository.class);
    injectorRule.bind(OsRepository.class, osRepository);
    when(osRepository.getVmWatchdogTypes(anyInt(), any())).thenReturn(WATCHDOG_MODELS);
}
Also used : OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository) Before(org.junit.Before)

Example 8 with OsRepository

use of org.ovirt.engine.core.common.osinfo.OsRepository in project ovirt-engine by oVirt.

the class Backend method initOsRepository.

private void initOsRepository() {
    OsInfoPreferencesLoader.INSTANCE.init(FileSystems.getDefault().getPath(EngineLocalConfig.getInstance().getEtcDir().getAbsolutePath(), Config.<String>getValue(ConfigValues.OsRepositoryConfDir)));
    OsRepositoryImpl.INSTANCE.init(OsInfoPreferencesLoader.INSTANCE.getPreferences());
    OsRepository osRepository = OsRepositoryImpl.INSTANCE;
    SimpleDependencyInjector.getInstance().bind(OsRepository.class, osRepository);
    osInfoDao.populateDwhOsInfo(osRepository.getOsNames());
}
Also used : OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository)

Example 9 with OsRepository

use of org.ovirt.engine.core.common.osinfo.OsRepository in project ovirt-engine by oVirt.

the class BackendOperatingSystemsResource method list.

@Override
public OperatingSystemInfos list() {
    OsRepository repository = SimpleDependencyInjector.getInstance().get(OsRepository.class);
    final Map<Integer, VmIconIdSizePair> iconDefaults = getIconDefaults();
    List<Integer> ids = repository.getOsIds();
    Map<Integer, String> uniqueNames = repository.getUniqueOsNames();
    Map<Integer, String> names = repository.getOsNames();
    OperatingSystemInfos collection = new OperatingSystemInfos();
    for (Integer id : ids) {
        OperatingSystemInfo model = new OperatingSystemInfo();
        model.setId(id.toString());
        if (iconDefaults.containsKey(id)) {
            final VmIconIdSizePair iconDefault = iconDefaults.get(id);
            model.setSmallIcon(IconHelper.createIcon(iconDefault.getSmall()));
            model.setLargeIcon(IconHelper.createIcon(iconDefault.getLarge()));
        }
        String uniqueName = uniqueNames.get(id);
        if (uniqueName != null) {
            model.setName(uniqueName);
        }
        String name = names.get(id);
        if (name != null) {
            model.setDescription(name);
        }
        collection.getOperatingSystemInfos().add(addLinks(model));
    }
    return collection;
}
Also used : VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair) OperatingSystemInfo(org.ovirt.engine.api.model.OperatingSystemInfo) OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository) OperatingSystemInfos(org.ovirt.engine.api.model.OperatingSystemInfos)

Example 10 with OsRepository

use of org.ovirt.engine.core.common.osinfo.OsRepository in project ovirt-engine by oVirt.

the class OsTypeMockUtils method mockOsTypes.

public static void mockOsTypes() {
    OsRepository osRepositoryMock = mock(OsRepository.class);
    HashMap<Integer, String> osNames = new HashMap<>(1);
    osNames.put(0, "Unassigned");
    when(osRepositoryMock.getUniqueOsNames()).thenReturn(osNames);
    HashMap<ArchitectureType, Integer> defaultOSes = new HashMap<>();
    defaultOSes.put(ArchitectureType.x86_64, 0);
    when(osRepositoryMock.getDefaultOSes()).thenReturn(defaultOSes);
    SimpleDependencyInjector.getInstance().bind(OsRepository.class, osRepositoryMock);
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) HashMap(java.util.HashMap) OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository)

Aggregations

OsRepository (org.ovirt.engine.core.common.osinfo.OsRepository)10 OperatingSystemInfo (org.ovirt.engine.api.model.OperatingSystemInfo)2 ArchitectureType (org.ovirt.engine.core.common.businessentities.ArchitectureType)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Before (org.junit.Before)1 OperatingSystemInfos (org.ovirt.engine.api.model.OperatingSystemInfos)1 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)1 VmCommand (org.ovirt.engine.core.bll.VmCommand)1 HostDeviceManager (org.ovirt.engine.core.bll.hostdev.HostDeviceManager)1 DisksFilter (org.ovirt.engine.core.bll.storage.disk.image.DisksFilter)1 ONLY_ACTIVE (org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_ACTIVE)1 ONLY_NOT_SHAREABLE (org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_NOT_SHAREABLE)1