Daniel Erez has uploaded a new change for review.

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

core: update console device on next run VM snapshot

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

Change-Id: I22a508327a678039eee666ea5f31748ee8c8f7b1
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/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java
4 files changed, 14 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/86/29386/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 34d40f0..bde27f3 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
@@ -512,11 +512,6 @@
             return 
failCanDoAction(VdcBllMessages.VM_HOSTCPU_MUST_BE_PINNED_TO_HOST);
         }
 
-        if (getParameters().isConsoleEnabled() != null && !getVm().isDown()
-                && VmDeviceUtils.vmDeviceChanged(getVmId(), 
VmDeviceGeneralType.CONSOLE, getParameters().isConsoleEnabled())) {
-            return 
failCanDoAction(VdcBllMessages.VM_CANNOT_UPDATE_DEVICE_VM_NOT_DOWN, "$device 
console");
-        }
-
         if (getParameters().isSoundDeviceEnabled() != null && !getVm().isDown()
                 && VmDeviceUtils.vmDeviceChanged(getVmId(), 
VmDeviceGeneralType.SOUND, getParameters().isSoundDeviceEnabled())) {
             return 
failCanDoAction(VdcBllMessages.VM_CANNOT_UPDATE_DEVICE_VM_NOT_DOWN, "$device 
sound");
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 a77afe9..7c6ea02 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
@@ -56,6 +56,7 @@
      * This parameter is used to decide if to create console device or not if 
it is null then: for add vm don't add
      * console device for update the current configuration will remain
      */
+    @EditableDeviceOnVmStatusField(generalType = VmDeviceGeneralType.CONSOLE, 
type = VmDeviceType.CONSOLE)
     private Boolean consoleEnabled;
 
     /*
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java
index eeb391f..d4a0ec0 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java
@@ -339,6 +339,7 @@
      */
     public static boolean isSpecialDevice(String device, VmDeviceGeneralType 
type) {
         return (VmDeviceGeneralType.SOUND == type || 
VmDeviceType.USB.getName().equals(device)
+                || (VmDeviceType.CONSOLE.getName().equals(device) && 
VmDeviceGeneralType.CONSOLE == type)
                 || (VmDeviceType.SMARTCARD.getName().equals(device) && 
VmDeviceGeneralType.SMARTCARD == type)
                 || (VmDeviceType.SPICEVMC.getName().equals(device) && 
VmDeviceGeneralType.REDIR == type)
                 || (VmDeviceType.MEMBALLOON.getName().equals(device) && 
VmDeviceGeneralType.BALLOON == type))
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 150b27b..da1d11f 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
@@ -272,6 +272,7 @@
                 deactivate();
                 getModel().getIsSoundcardEnabled().setEntity((Boolean) 
returnValue);
                 activate();
+
                 
Frontend.getInstance().runQuery(VdcQueryType.GetConsoleDevices, new 
IdQueryParameters(vmBase.getId()), new AsyncQuery(this, new INewAsyncCallback() 
{
                     @Override
                     public void onSuccess(Object model, Object returnValue) {
@@ -279,14 +280,23 @@
                         List<String> consoleDevices = ((VdcQueryReturnValue) 
returnValue).getReturnValue();
                         
getModel().getIsConsoleDeviceEnabled().setEntity(!consoleDevices.isEmpty());
                         activate();
-                        updateWatchdog(vmBase);
+                        postDoUpdateManagedFieldsFrom(vmBase);
                     }
                 }));
-
             }
         }), vmBase.getId());
     }
 
+    private void postDoUpdateManagedFieldsFrom(VmBase vmBase) {
+        if (isNextRunConfigurationExists()) {
+            deactivate();
+            
getModel().getIsConsoleDeviceEnabled().setEntity(isVmDeviceExists(vmBase.getManagedDeviceMap(),
 VmDeviceType.CONSOLE.getName()));
+            activate();
+        }
+
+        updateWatchdog(vmBase);
+    }
+
     private void updateWatchdog(final VmBase vmBase) {
         AsyncDataProvider.getWatchdogByVmId(new AsyncQuery(this.getModel(), 
new INewAsyncCallback() {
             @Override


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I22a508327a678039eee666ea5f31748ee8c8f7b1
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
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