ofri masad has uploaded a new change for review.

Change subject: webadmin: mutually exclude HA and non-migratable in UI
......................................................................

webadmin: mutually exclude HA and non-migratable in UI

In the VM popup dialog - user would not be able to select both
High-Availability and 'don't allow migration' or 'allow only manual
migration'. this was done because HA mode requires the ability to
automatically migrate the VM.

the action is also blocked by the beckend

Change-Id: I04a1e8641c41394d021bcb4bb323c987111609ea
Bug-Url: https://bugzilla.redhat.com/958318
Signed-off-by: Ofri Masad <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
3 files changed, 30 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/16191/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
index 362af91..4293a17 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
@@ -1063,6 +1063,7 @@
         getCdAttached().setEntity(false);
 
         setIsHighlyAvailable(new NotChangableForVmInPoolEntityModel());
+        getIsHighlyAvailable().getEntityChangedEvent().addListener(this);
         setIsTemplatePublic(new NotChangableForVmInPoolEntityModel());
         setKernel_parameters(new NotChangableForVmInPoolEntityModel());
         setKernel_path(new NotChangableForVmInPoolEntityModel());
@@ -1275,6 +1276,7 @@
             {
                 behavior.updateUseHostCpuAvailability();
                 behavior.updateCpuPinningVisibility();
+                behavior.updateHaAvailability();
             }
         }
         else if 
(ev.matchesDefinition(EntityModel.EntityChangedEventDefinition))
@@ -1291,6 +1293,7 @@
             {
                 behavior.updateUseHostCpuAvailability();
                 behavior.updateCpuPinningVisibility();
+                behavior.updateHaAvailability();
             }
             else if (sender == getProvisioning())
             {
@@ -1309,6 +1312,8 @@
                 }
             } else if (sender == getWatchdogModel()) {
                 WatchdogModel_EntityChanged(sender, args);
+            } else if (sender == getIsHighlyAvailable()) {
+                behavior.updateMigrationAvailability();
             }
         }
     }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
index 09d4240..04259a8 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
@@ -703,6 +703,26 @@
         }
     }
 
+    public void updateHaAvailability() {
+        boolean automaticMigrationAllowed = 
getModel().getMigrationMode().getSelectedItem()
+                == MigrationSupport.MIGRATABLE;
+        if (!automaticMigrationAllowed) {
+            
getModel().getIsHighlyAvailable().setChangeProhibitionReason(constants.hostNonMigratable());
+            getModel().getIsHighlyAvailable().setEntity(false);
+        }
+        
getModel().getIsHighlyAvailable().setIsChangable(automaticMigrationAllowed);
+    }
+
+    public void updateMigrationAvailability() {
+        Boolean haHost = (Boolean) 
getModel().getIsHighlyAvailable().getEntity();
+        if (haHost) {
+            
getModel().getMigrationMode().setChangeProhibitionReason(constants.hostIsHa());
+            
getModel().getMigrationMode().setSelectedItem(MigrationSupport.MIGRATABLE);
+        }
+        getModel().getMigrationMode().setIsChangable(!haHost);
+
+    }
+
     private boolean isVmMigratable() {
         return getModel().getMigrationMode().getSelectedItem() != 
MigrationSupport.PINNED_TO_HOST;
     }
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
index 625084a..60078e6 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
@@ -1911,4 +1911,9 @@
     @DefaultStringValue("Time Zone is not changeable for Linux VMs")
     String timeZoneNotChangeableForLinuxVms();
 
+    @DefaultStringValue("Host cannot be set highly available when 'Do not 
allow migration' or 'Allow manual migration' is selected")
+    String hostNonMigratable();
+
+    @DefaultStringValue("Host must be migratable when highly available is 
selected")
+    String hostIsHa();
 }


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

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

Reply via email to