Martin Peřina has uploaded a new change for review.

Change subject: core: Allow CPU family change for cluster with hosts
......................................................................

core: Allow CPU family change for cluster with hosts

Allows changing CPU family for cluster which has all hosts in
Maintenance. Currently this was allowed only for empty cluster.

Change-Id: I7d5e53f15e917e84ed0bb99fa646a6d5bb866f8c
Bug-Url: https://bugzilla.redhat.com/1057232
Signed-off-by: Martin Perina <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
4 files changed, 18 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/74/25274/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java
index 6fe0134..587245a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java
@@ -152,6 +152,7 @@
         boolean hasVms = false;
         boolean hasVmOrHost = false;
         boolean sameCpuNames = false;
+        boolean allVdssInMaintenance = false;
 
         List<VM> vmList = null;
 
@@ -188,6 +189,7 @@
         // If both original Cpu and new Cpu are null, don't check Cpu validity
         if (result) {
             allForVdsGroup = getVdsDAO().getAllForVdsGroup(oldGroup.getId());
+            allVdssInMaintenance = areAllVdssInMaintenance(allForVdsGroup);
         }
         // Validate the cpu only if the cluster supports Virt
         if (result && getVdsGroup().supportsVirtService()
@@ -201,7 +203,8 @@
                 // if cpu changed from intel to amd (or backwards) and there 
are
                 // vds in this cluster, cannot update
                 if (!StringUtils.isEmpty(oldGroup.getcpu_name())
-                        && !checkIfCpusSameManufacture(oldGroup) && 
!allForVdsGroup.isEmpty()) {
+                        && !checkIfCpusSameManufacture(oldGroup)
+                        && !allVdssInMaintenance) {
                     
addCanDoActionMessage(VdcBllMessages.VDS_GROUP_CANNOT_UPDATE_CPU_ILLEGAL);
                     result = false;
                 }
@@ -391,6 +394,17 @@
         return CpuFlagsManagerHandler.isCpuUpdatable(cluster.getcpu_name(), 
cluster.getcompatibility_version());
     }
 
+    private boolean areAllVdssInMaintenance(List<VDS> vdss) {
+        boolean allInMaintenance = true;
+        for (VDS vds : vdss) {
+            if (vds.getStatus() != VDSStatus.Maintenance) {
+                allInMaintenance = false;
+                break;
+            }
+        }
+        return allInMaintenance;
+    }
+
     protected int compareCpuLevels(VDSGroup otherGroup) {
         return 
CpuFlagsManagerHandler.compareCpuLevels(getVdsGroup().getcpu_name(),
                 otherGroup.getcpu_name(),
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 1677f56..6349ffd 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -404,7 +404,7 @@
        -Host must be in "Pending Approval" or "Install Failed" status in order 
to be approved.
 VDS_NEW_CLUSTER_ILLEGAL=Cannot update Host properties. Mismatch between 
Cluster CPU and Host CPU.
 VDS_CLUSTER_IS_NOT_VALID=Cannot ${action} ${type}. Cluster ID is not valid.
-VDS_GROUP_CANNOT_UPDATE_CPU_ILLEGAL=Cannot change Cluster CPU type when there 
are Hosts attached to this Cluster.
+VDS_GROUP_CANNOT_UPDATE_CPU_ILLEGAL=Cannot change Cluster CPU type when all 
Hosts attached to this Cluster are not in Maintenance.
 VDS_GROUP_CANNOT_UPDATE_CPU_ARCHITECTURE_ILLEGAL=Cannot change Cluster CPU 
architecture when there are Hosts or VMs attached to this Cluster.
 VDS_GROUP_CANNOT_UPDATE_CPU_WITH_LOWER_HOSTS=Cannot change Cluster CPU to 
higher CPU type when there are active Hosts with lower CPU type.\n\
        -Please move Hosts with lower CPU to maintenance first.
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index f2c13d0..32144c6 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -383,7 +383,7 @@
        -Host must be in "Pending Approval" or "Install Failed" status in order 
to be approved.
 VDS_NEW_CLUSTER_ILLEGAL=Cannot update Host properties. Mismatch between 
Cluster CPU and Host CPU.
 VDS_CLUSTER_IS_NOT_VALID=Cannot ${action} ${type}. Cluster ID is not valid.
-VDS_GROUP_CANNOT_UPDATE_CPU_ILLEGAL=Cannot change Cluster CPU type when there 
are Hosts attached to this Cluster.
+VDS_GROUP_CANNOT_UPDATE_CPU_ILLEGAL=Cannot change Cluster CPU type when all 
Hosts attached to this Cluster are not in Maintenance.
 VDS_GROUP_CANNOT_UPDATE_CPU_ARCHITECTURE_ILLEGAL=Cannot change Cluster CPU 
architecture when there are Hosts or VMs attached to this Cluster.
 VDS_GROUP_CANNOT_UPDATE_CPU_WITH_LOWER_HOSTS=Cannot change Cluster CPU to 
higher CPU type when there are active Hosts with lower CPU type.\n\
        -Please move Hosts with lower CPU to maintenance first.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index ae979d3..cfde6e6 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -408,7 +408,7 @@
        -Host must be in "Pending Approval" or "Install Failed" status in order 
to be approved.
 VDS_NEW_CLUSTER_ILLEGAL=Cannot update Host properties. Mismatch between 
Cluster CPU and Host CPU.
 VDS_CLUSTER_IS_NOT_VALID=Cannot ${action} ${type}. Cluster ID is not valid.
-VDS_GROUP_CANNOT_UPDATE_CPU_ILLEGAL=Cannot change Cluster CPU type when there 
are Hosts attached to this Cluster.
+VDS_GROUP_CANNOT_UPDATE_CPU_ILLEGAL=Cannot change Cluster CPU type when all 
Hosts attached to this Cluster are not in Maintenance.
 VDS_GROUP_CANNOT_UPDATE_CPU_ARCHITECTURE_ILLEGAL=Cannot change Cluster CPU 
architecture when there are Hosts or VMs attached to this Cluster.
 VDS_GROUP_CANNOT_UPDATE_CPU_WITH_LOWER_HOSTS=Cannot change Cluster CPU to 
higher CPU type when there are active Hosts with lower CPU type.\n\
        -Please move Hosts with lower CPU to maintenance first.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d5e53f15e917e84ed0bb99fa646a6d5bb866f8c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Martin Peřina <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to