use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.
the class OvfManager method initIcons.
private void initIcons(VmBase vmBase) {
final int osId = vmBase.getOsId();
final int fallbackOsId = OsRepository.DEFAULT_X86_OS;
final Map<Integer, VmIconIdSizePair> vmIconDefaults = iconDefaultsProvider.getVmIconDefaults();
final VmIconIdSizePair iconPair = vmIconDefaults.containsKey(osId) ? vmIconDefaults.get(osId) : vmIconDefaults.get(fallbackOsId);
vmBase.setSmallIconId(iconPair.getSmall());
vmBase.setLargeIconId(iconPair.getLarge());
}
use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.
the class OvfVmIconDefaultsProvider method getVmIconDefaults.
public Map<Integer, VmIconIdSizePair> getVmIconDefaults() {
final Map<Integer, VmIconIdSizePair> result = new HashMap<>();
final List<VmIconDefault> iconDefaults = vmIconDefaultDao.getAll();
for (VmIconDefault iconDefault : iconDefaults) {
result.put(iconDefault.getOsId(), new VmIconIdSizePair(iconDefault.getSmallIconId(), iconDefault.getLargeIconId()));
}
if (!result.containsKey(OsRepository.DEFAULT_X86_OS)) {
throw new EngineException(EngineError.DefaultIconPairNotFound);
}
return result;
}
use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.
the class IconUtils method ensureIconPairInDatabase.
public VmIconIdSizePair ensureIconPairInDatabase(String largeIconDataUrl) {
final String smallIconDataUrl = IconUtils.computeSmallIcon(largeIconDataUrl);
Guid largeIconId = vmIconDao.ensureIconInDatabase(largeIconDataUrl);
Guid smallIconId = vmIconDao.ensureIconInDatabase(smallIconDataUrl);
return new VmIconIdSizePair(smallIconId, largeIconId);
}
use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.
the class IconLoader method ensureIconsInDatabase.
private VmIconIdSizePair ensureIconsInDatabase(String osName) {
final Guid smallIconId = ensureIconInDatabase(SMALL_ICON_DIR, osName);
final Guid largeIconId = ensureIconInDatabase(LARGE_ICON_DIR, osName);
if (smallIconId != null && largeIconId != null) {
return new VmIconIdSizePair(smallIconId, largeIconId);
}
return null;
}
use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.
the class OvfManagerTest method setUp.
@Before
public void setUp() throws Exception {
final HashMap<Integer, String> osIdsToNames = new HashMap<>();
osIdsToNames.put(DEFAULT_OS_ID, "os_name_a");
osIdsToNames.put(EXISTING_OS_ID, "os_name_b");
final List<Pair<GraphicsType, DisplayType>> gndDefaultOs = new ArrayList<>();
gndDefaultOs.add(new Pair<>(GraphicsType.SPICE, DisplayType.cirrus));
gndDefaultOs.add(new Pair<>(GraphicsType.VNC, DisplayType.cirrus));
final List<Pair<GraphicsType, DisplayType>> gndExistingOs = new ArrayList<>();
gndExistingOs.add(new Pair<>(GraphicsType.SPICE, DisplayType.cirrus));
when(osRepository.getArchitectureFromOS(anyInt())).thenReturn(ArchitectureType.x86_64);
when(osRepository.getUniqueOsNames()).thenReturn(osIdsToNames);
when(osRepository.getOsIdByUniqueName(any())).thenAnswer(invocation -> osIdsToNames.entrySet().stream().filter(k -> invocation.getArguments()[0].equals(k.getValue())).map(Map.Entry::getKey).findFirst().orElse(0));
when(osRepository.getGraphicsAndDisplays(eq(DEFAULT_OS_ID), any())).thenReturn(gndDefaultOs);
when(osRepository.getGraphicsAndDisplays(eq(EXISTING_OS_ID), any())).thenReturn(gndExistingOs);
doNothing().when(manager).updateBootOrderOnDevices(any(), anyBoolean());
Map<Integer, VmIconIdSizePair> iconDefaults = new HashMap<>();
iconDefaults.put(DEFAULT_OS_ID, new VmIconIdSizePair(SMALL_DEFAULT_ICON_ID, LARGE_DEFAULT_ICON_ID));
iconDefaults.put(EXISTING_OS_ID, new VmIconIdSizePair(SMALL_ICON_ID, LARGE_ICON_ID));
when(iconDefaultsProvider.getVmIconDefaults()).thenReturn(iconDefaults);
}
Aggregations