use of org.ovirt.engine.core.common.businessentities.UsbPolicy in project ovirt-engine by oVirt.
the class VmDeviceUtils method updateUsbSlots.
/*
* USB slot
*/
/**
* Update USB slots and controllers in the new VM, if USB policy of the new VM differs from one of the old VM.
* @param oldVm old configuration, may not be null, won't be modified
* @param newVm new configuration, may not be null, only devices if this entity will be modified
*/
public void updateUsbSlots(VmBase oldVm, VmBase newVm, Supplier<Cluster> clusterSupplier) {
final UsbPolicy oldUsbPolicy = oldVm.getUsbPolicy();
final UsbPolicy newUsbPolicy = newVm.getUsbPolicy();
final int oldNumberOfSlots = getUsbSlots(oldVm.getId()).size();
final int newNumberOfUsbSlots = Config.<Integer>getValue(ConfigValues.NumberOfUSBSlots);
if (UsbPolicy.DISABLED == newUsbPolicy && newVm.getVmType() == VmType.HighPerformance) {
disableAnyUsb(oldVm, newVm);
return;
}
if (UsbPolicy.DISABLED == oldUsbPolicy && UsbPolicy.ENABLED_NATIVE == newUsbPolicy) {
disableNormalUsb(newVm.getId());
enableSpiceUsb(newVm.getId(), newNumberOfUsbSlots);
return;
}
if (UsbPolicy.ENABLED_NATIVE == oldUsbPolicy && UsbPolicy.ENABLED_NATIVE == newUsbPolicy) {
updateSpiceUsb(newVm.getId(), oldNumberOfSlots, newNumberOfUsbSlots);
return;
}
ChipsetType chipset = EmulatedMachineUtils.getEffectiveChipset(newVm, clusterSupplier);
if (UsbPolicy.ENABLED_NATIVE == oldUsbPolicy && UsbPolicy.DISABLED == newUsbPolicy) {
disableSpiceUsb(newVm.getId());
enableNormalUsb(newVm, chipset);
return;
}
if (UsbPolicy.DISABLED == oldUsbPolicy && UsbPolicy.DISABLED == newUsbPolicy) {
updateNormalUsb(newVm, chipset);
return;
}
throw new RuntimeException(format("Unexpected state: oldUsbPolicy=%s, newUsbPolicy=%s", oldUsbPolicy, newUsbPolicy));
}
use of org.ovirt.engine.core.common.businessentities.UsbPolicy in project ovirt-engine by oVirt.
the class VmMapperTest method getUsbPolicyOnUpdateCurrentlyNativeGotNullUsb.
@Test
public void getUsbPolicyOnUpdateCurrentlyNativeGotNullUsb() {
Usb usb = null;
UsbPolicy currentPolicy = UsbPolicy.ENABLED_NATIVE;
assertEquals(VmMapper.getUsbPolicyOnUpdate(usb, currentPolicy), currentPolicy);
}
use of org.ovirt.engine.core.common.businessentities.UsbPolicy in project ovirt-engine by oVirt.
the class VmMapperTest method getUsbPolicyOnUpdateCurrentlyDisabledGotEnabledNotSetPolicyNotSetUsb.
@Test
public void getUsbPolicyOnUpdateCurrentlyDisabledGotEnabledNotSetPolicyNotSetUsb() {
Usb usb = new Usb();
UsbPolicy currentPolicy = UsbPolicy.DISABLED;
assertEquals(VmMapper.getUsbPolicyOnUpdate(usb, currentPolicy), currentPolicy);
}
use of org.ovirt.engine.core.common.businessentities.UsbPolicy in project ovirt-engine by oVirt.
the class UsbMapperUtilsTest method getIsUsbEnabledDisabled.
@Test
public void getIsUsbEnabledDisabled() {
UsbPolicy usbPolicy = UsbPolicy.DISABLED;
assertFalse(UsbMapperUtils.getIsUsbEnabled(usbPolicy));
}
use of org.ovirt.engine.core.common.businessentities.UsbPolicy in project ovirt-engine by oVirt.
the class UsbMapperUtilsTest method getUsbTypeDisabled.
@Test
public void getUsbTypeDisabled() {
UsbPolicy usbPolicy = UsbPolicy.DISABLED;
assertNull(UsbMapperUtils.getUsbType(usbPolicy));
}
Aggregations