Daniel Erez has uploaded a new change for review.

Change subject: core: update sound device on next run VM snapshot
......................................................................

core: update sound device on next run VM snapshot

* Added an 'EditableDeviceOnVmStatusField' annotation for
  'soundDeviceEnabled' (in VmManagementParametersBase).
* Consequently, removed canDo validation in UpdateVmCommand.

Change-Id: Icb794bcb6a054bbb0424c35f024c4a1a85ea5069
Bug-Url: https://bugzilla.redhat.com/1035289
Signed-off-by: Daniel Erez <de...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmCommandTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java
4 files changed, 2 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/50/30550/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
index ad9a426..b244906 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
@@ -522,11 +522,6 @@
             return 
failCanDoAction(VdcBllMessages.VM_HOSTCPU_MUST_BE_PINNED_TO_HOST);
         }
 
-        if (getParameters().isSoundDeviceEnabled() != null && !getVm().isDown()
-                && vmDeviceChanged(getVmId(), VmDeviceGeneralType.SOUND, 
getParameters().isSoundDeviceEnabled())) {
-            return 
failCanDoAction(VdcBllMessages.VM_CANNOT_UPDATE_DEVICE_VM_NOT_DOWN, "$device 
sound");
-        }
-
         if (!isCpuSharesValid(vmFromParams)) {
             return failCanDoAction(VdcBllMessages.QOS_CPU_SHARES_OUT_OF_RANGE);
         }
@@ -747,11 +742,4 @@
         return getParameters().getWatchdog() != null;
     }
 
-    protected boolean vmDeviceChanged(Guid vmId, VmDeviceGeneralType 
deviceType, boolean deviceEnabled) {
-        return VmDeviceUtils.vmDeviceChanged(vmId, deviceType, deviceEnabled);
-    }
-
-    protected boolean vmDeviceChanged(Guid vmId, VmDeviceGeneralType 
deviceType, String device, boolean deviceEnabled) {
-        return VmDeviceUtils.vmDeviceChanged(vmId, deviceType, device, 
deviceEnabled);
-    }
 }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmCommandTest.java
index d4f0dcc..c4bd8f2 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmCommandTest.java
@@ -35,7 +35,6 @@
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
-import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType;
 import org.ovirt.engine.core.common.businessentities.VmStatic;
 import org.ovirt.engine.core.common.config.ConfigValues;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
@@ -296,11 +295,6 @@
 
         doReturn(vmDeviceDAO).when(command).getVmDeviceDao();
         doReturn(true).when(command).areUpdatedFieldsLegal();
-
-        doReturn(false).when(command).vmDeviceChanged(
-                any(Guid.class), any(VmDeviceGeneralType.class), 
any(Boolean.class));
-        doReturn(false).when(command).vmDeviceChanged(
-                any(Guid.class), any(VmDeviceGeneralType.class), 
any(String.class), any(Boolean.class));
 
         CanDoActionTestUtils.runAndAssertCanDoActionSuccess(command);
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java
index 7c6ea02..f5f14e85 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java
@@ -51,6 +51,7 @@
      * for add vm legacy logic will be used: create device for desktop type
      * for update the current configuration will remain
      */
+    @EditableDeviceOnVmStatusField(generalType = VmDeviceGeneralType.SOUND, 
type = VmDeviceType.SOUND, isReadOnly = true)
     private Boolean soundDeviceEnabled;
     /*
      * This parameter is used to decide if to create console device or not if 
it is null then: for add vm don't add
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java
index c089be5..342f0e3 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java
@@ -292,6 +292,7 @@
     private void postDoUpdateManagedFieldsFrom(VmBase vmBase) {
         if (isNextRunConfigurationExists()) {
             deactivate();
+            
getModel().getIsSoundcardEnabled().setEntity(isVmDeviceExists(vmBase.getManagedDeviceMap(),
 VmDeviceType.SOUND.getName()));
             
getModel().getIsConsoleDeviceEnabled().setEntity(isVmDeviceExists(vmBase.getManagedDeviceMap(),
 VmDeviceType.CONSOLE.getName()));
             activate();
         }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb794bcb6a054bbb0424c35f024c4a1a85ea5069
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Daniel Erez <de...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to