Search in sources :

Example 1 with UsbPolicy

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

the class UnitVmModel method initUsbPolicy.

private void initUsbPolicy() {
    GraphicsTypes graphicsTypes = getGraphicsType().getSelectedItem();
    if (graphicsTypes == null) {
        return;
    }
    getUsbPolicy().setIsChangeable(true);
    UsbPolicy prevSelectedUsbPolicy = getUsbPolicy().getSelectedItem();
    getUsbPolicy().setItems(Arrays.asList(UsbPolicy.DISABLED, UsbPolicy.ENABLED_NATIVE));
    if (!graphicsTypes.getBackingGraphicsTypes().contains(GraphicsType.SPICE)) {
        getUsbPolicy().setIsChangeable(false);
    }
    if (getBehavior().basedOnCustomInstanceType()) {
        Collection<UsbPolicy> policies = getUsbPolicy().getItems();
        if (policies.contains(prevSelectedUsbPolicy)) {
            getUsbPolicy().setSelectedItem(prevSelectedUsbPolicy);
        } else if (policies.size() > 0) {
            getUsbPolicy().setSelectedItem(getVmType().getSelectedItem() == VmType.HighPerformance ? UsbPolicy.DISABLED : policies.iterator().next());
        }
    }
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy)

Example 2 with UsbPolicy

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

the class VmMapperTest method getUsbPolicyOnUpdateCurrentlyDisabledGotNullUsb.

@Test
public void getUsbPolicyOnUpdateCurrentlyDisabledGotNullUsb() {
    Usb usb = null;
    UsbPolicy currentPolicy = UsbPolicy.DISABLED;
    assertEquals(VmMapper.getUsbPolicyOnUpdate(usb, currentPolicy), currentPolicy);
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) Usb(org.ovirt.engine.api.model.Usb) Test(org.junit.Test)

Example 3 with UsbPolicy

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

the class VmMapperTest method getUsbPolicyOnUpdateCurrentlyNativeGotEnabledNotSetPolicyNotSetUsb.

@Test
public void getUsbPolicyOnUpdateCurrentlyNativeGotEnabledNotSetPolicyNotSetUsb() {
    Usb usb = new Usb();
    UsbPolicy currentPolicy = UsbPolicy.ENABLED_NATIVE;
    assertEquals(VmMapper.getUsbPolicyOnUpdate(usb, currentPolicy), currentPolicy);
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) Usb(org.ovirt.engine.api.model.Usb) Test(org.junit.Test)

Example 4 with UsbPolicy

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

the class UsbMapperUtilsTest method getUsbTypeEnabledNative.

@Test
public void getUsbTypeEnabledNative() {
    UsbPolicy usbPolicy = UsbPolicy.ENABLED_NATIVE;
    assertEquals(UsbType.NATIVE, UsbMapperUtils.getUsbType(usbPolicy));
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) Test(org.junit.Test)

Example 5 with UsbPolicy

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

the class UsbMapperUtilsTest method getIsUsbEnabledEnabledNative.

@Test
public void getIsUsbEnabledEnabledNative() {
    UsbPolicy usbPolicy = UsbPolicy.ENABLED_NATIVE;
    assertTrue(UsbMapperUtils.getIsUsbEnabled(usbPolicy));
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) Test(org.junit.Test)

Aggregations

UsbPolicy (org.ovirt.engine.core.common.businessentities.UsbPolicy)10 Test (org.junit.Test)8 Usb (org.ovirt.engine.api.model.Usb)4 ChipsetType (org.ovirt.engine.core.common.businessentities.ChipsetType)1