Oved Ourfali has uploaded a new change for review.

Change subject: core+ui: USB policy template issues (#850719)
......................................................................

core+ui: USB policy template issues (#850719)

https://bugzilla.redhat.com/850719

This patch containsL
1. The UI didn't set the proper USB policy on make template from VM.
This patch fixes that behaviour.
2. When copying VM devices, the specParams should be copied in case of
USB devices.
3. Updating USB devices logic.

Change-Id: I90d40c5c13ca997b2981b8e63a3c9c1cf3551869
Signed-off-by: Oved Ourfali <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
2 files changed, 6 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/44/7544/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java
index b246778..cf9b62c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java
@@ -372,9 +372,11 @@
     private static void updateUSBSlots(VmBase oldVm, VmBase newVm) {
         UsbPolicy oldUsbPolicy = UsbPolicy.DISABLED;
         UsbPolicy newUsbPolicy = newVm.getusb_policy();
+        int currentNumberOfSlots = 0;
 
         if (oldVm != null) {
             oldUsbPolicy = oldVm.getusb_policy();
+            currentNumberOfSlots = getUsbRedirectDevices(oldVm).size();
         }
 
         final int usbSlots = Config.<Integer> 
GetValue(ConfigValues.NumberOfUSBSlots);
@@ -387,13 +389,12 @@
                 addUsbSlots(newVm, usbSlots);
             }
         }
-        // Remove USB slots and controllers
-        else if (oldUsbPolicy.equals(UsbPolicy.ENABLED_NATIVE) && 
!newUsbPolicy.equals(UsbPolicy.ENABLED_NATIVE)) {
+        // Remove USB slots and controllers in case we are either in disabled 
policy or legacy one
+        else if (newUsbPolicy.equals(UsbPolicy.DISABLED) || 
newUsbPolicy.equals(UsbPolicy.ENABLED_LEGACY)) {
             removeUsbControllers(newVm);
             removeUsbSlots(newVm);
+        // if the USB policy is enabled (and was enabled before), we need to 
update the number of slots
         } else if (newUsbPolicy.equals(UsbPolicy.ENABLED_NATIVE)) {
-            final int currentNumberOfSlots = 
getUsbRedirectDevices(oldVm).size();
-
             if (currentNumberOfSlots < usbSlots) {
                 // Add slots
                 if (currentNumberOfSlots == 0) {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
index efcdc9d..d00af9e 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
@@ -1625,12 +1625,12 @@
         tempVar.setnum_of_sockets((Integer) 
model.getNumOfSockets().getSelectedItem());
         
tempVar.setcpu_per_socket(Integer.parseInt(model.getTotalCPUCores().getEntity().toString())
                 / (Integer) model.getNumOfSockets().getSelectedItem());
-        tempVar.setusb_policy((UsbPolicy) 
model.getUsbPolicy().getSelectedItem());
         tempVar.setis_auto_suspend(false);
         tempVar.setis_stateless((Boolean) model.getIsStateless().getEntity());
         tempVar.setdefault_boot_sequence(model.getBootSequence());
         tempVar.setauto_startup((Boolean) 
model.getIsHighlyAvailable().getEntity());
         tempVar.setiso_path(model.getCdImage().getIsChangable() ? (String) 
model.getCdImage().getSelectedItem() : ""); //$NON-NLS-1$
+        tempVar.setusb_policy(vm.getusb_policy());
         tempVar.setinitrd_url(vm.getinitrd_url());
         tempVar.setkernel_url(vm.getkernel_url());
         tempVar.setkernel_params(vm.getkernel_params());


--
To view, visit http://gerrit.ovirt.org/7544
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I90d40c5c13ca997b2981b8e63a3c9c1cf3551869
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Oved Ourfali <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to