Maor Lipchuk has uploaded a new change for review.

Change subject: core:Print clusters when upgrading DC version(#844425)
......................................................................

core:Print clusters when upgrading DC version(#844425)

https://bugzilla.redhat.com/show_bug.cgi?id=844425

When we upgrade Data-Center we check if all cluster also has a validate
level (which is the same as the DC or upper), if not, user gets a
message that it should upgrade the clusters, but there are no mentions
which clusters it should be upgraded.

Signed-off-by: Maor Lipchuk <[email protected]>
Change-Id: Ia9c92d1c477354f7f5fa66895ecf2ab38c10bdf6
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommand.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommandTest.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M backend/manager/modules/utils/src/test/resources/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
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
7 files changed, 57 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/32/7132/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommand.java
index 62bd917..d6cea7a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommand.java
@@ -1,7 +1,9 @@
 package org.ovirt.engine.core.bll.storage;
 
+import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.Backend;
 import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
 import org.ovirt.engine.core.bll.utils.VersionSupport;
@@ -181,19 +183,8 @@
                 returnValue = false;
                 
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION);
             } else {
-                // check all clusters has at least the same compatibility
-                // version
-                List<VDSGroup> clusters = 
getVdsGroupDAO().getAllForStoragePool(getStoragePool().getId());
-                for (VDSGroup cluster : clusters) {
-                    if 
(getStoragePool().getcompatibility_version().compareTo(cluster.getcompatibility_version())
 > 0) {
-                        returnValue = false;
-                        getReturnValue()
-                                .getCanDoActionMessages()
-                                
.add(VdcBllMessages.ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS
-                                        .toString());
-                        break;
-                    }
-                }
+                // Check all clusters has at least the same compatibility 
version.
+                returnValue = checkAllClustersLevel();
             }
         }
 
@@ -208,6 +199,27 @@
         return returnValue;
     }
 
+    protected boolean checkAllClustersLevel() {
+        boolean returnValue = true;
+        List<VDSGroup> clusters = 
getVdsGroupDAO().getAllForStoragePool(getStoragePool().getId());
+        List<String> lowLevelClusters = new ArrayList<String>();
+        for (VDSGroup cluster : clusters) {
+            if 
(getStoragePool().getcompatibility_version().compareTo(cluster.getcompatibility_version())
 > 0) {
+                lowLevelClusters.add(cluster.getname());
+            }
+        }
+        if (!lowLevelClusters.isEmpty()) {
+            returnValue = false;
+            
getReturnValue().getCanDoActionMessages().add(String.format("$ClustersList 
%1$s",
+                    StringUtils.join(lowLevelClusters, ",")));
+            getReturnValue()
+                    .getCanDoActionMessages()
+                    
.add(VdcBllMessages.ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS
+                            .toString());
+        }
+        return returnValue;
+    }
+
     protected StoragePoolValidator createStoragePoolValidator() {
         return new StoragePoolValidator(getStoragePool(), 
getReturnValue().getCanDoActionMessages());
     }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommandTest.java
index ff6a35f..7151100 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommandTest.java
@@ -113,6 +113,32 @@
     }
 
     @Test
+    public void testValidateAllClustersLevel() {
+        storagePoolWithVersionHigherThanCluster();
+        List<VDSGroup> clusterList = createClusterList();
+        // Create new supported cluster.
+        VDSGroup secondCluster = new VDSGroup();
+        secondCluster.setcompatibility_version(VERSION_1_2);
+        secondCluster.setname("secondCluster");
+        clusterList.add(secondCluster);
+
+        // Create new unsupported cluster.
+        VDSGroup thirdCluster = new VDSGroup();
+        thirdCluster.setcompatibility_version(VERSION_1_1);
+        thirdCluster.setname("thirdCluster");
+        clusterList.add(thirdCluster);
+
+        // Test upgrade
+        
when(vdsDao.getAllForStoragePool(any(Guid.class))).thenReturn(clusterList);
+        assertFalse(cmd.checkAllClustersLevel());
+        List<String> messages = cmd.getReturnValue().getCanDoActionMessages();
+        
assertTrue(messages.contains(VdcBllMessages.ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS.toString()));
+        assertTrue(messages.get(0).contains("firstCluster"));
+        assertTrue(!messages.get(0).contains("secondCluster"));
+        assertTrue(messages.get(0).contains("thirdCluster"));
+    }
+
+    @Test
     public void poolHasDefaultCluster() {
         addDefaultClusterToPool();
         storagePoolWithLocalFS();
@@ -199,6 +225,7 @@
         List<VDSGroup> clusters = new ArrayList<VDSGroup>();
         VDSGroup cluster = new VDSGroup();
         cluster.setcompatibility_version(VERSION_1_0);
+        cluster.setname("firstCluster");
         clusters.add(cluster);
         return clusters;
     }
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 3e31491..54cecc1 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -390,7 +390,7 @@
 ERROR_CANNOT_EXTEND_NON_DATA_DOMAIN=Cannot extend Storage Domain. Extend 
operation is supported only on Data Storage Domain.
 ERROR_CANNOT_EXTEND_CONNECTION_FAILED=Cannot extend Storage Domain. Storage 
device ${lun} is unreachable on ${hostName}.
 ERROR_CANNOT_CHANGE_STORAGE_DOMAIN_FIELDS=Cannot ${action} ${type}. Only 
Storage Domain name is updateable.
-ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS=Cannot
 update Data Center compatibility version to a value that is greater than its 
Cluster's version.
+ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS=Cannot
 update Data Center compatibility version to a value that is greater than its 
Cluster's version. The following clusters should be upgraded ${ClustersList}.
 ERROR_CANNOT_ADD_EXISTING_STORAGE_DOMAIN_CONNECTION_DATA_ILLEGAL=Cannot import 
Storage Domain. Internal Error: The connection data is illegal.
 ERROR_CANNOT_ADD_EXISTING_STORAGE_DOMAIN_LUNS_PROBLEM=Cannot import Storage 
Domain. Not all LUNs connected to Storage Domain.
 NETWORK_MAC_ADDRESS_IN_USE=MAC Address is already in use.
diff --git 
a/backend/manager/modules/utils/src/test/resources/AppErrors.properties 
b/backend/manager/modules/utils/src/test/resources/AppErrors.properties
index 53d6b35..f30d842 100644
--- a/backend/manager/modules/utils/src/test/resources/AppErrors.properties
+++ b/backend/manager/modules/utils/src/test/resources/AppErrors.properties
@@ -253,6 +253,7 @@
 ERROR_CANNOT_ATTACH_MORE_THAN_ONE_EXPORT_DOMAIN=Cannot attach more than one 
Import/Export Storage Domain to the same Data Center. If you want to use a 
newly created Domain, detach the existing attached Domain and attach the new 
one.
 ERROR_CANNOT_ATTACH_STORAGE_DOMAIN_STORAGE_TYPE_NOT_MATCH=Cannot attach 
storage to Repository. Storage type doesn't match the Repository type
 ERROR_CANNOT_CHANGE_STORAGE_POOL_TYPE_WITH_DOMAINS=Cannot change Repository 
type with Storage Domains attached to it
+ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS=Cannot
 update Data Center compatibility version to a value that is greater than its 
Cluster's version. The following clusters should be upgraded ${ClustersList}.
 NETWORK_INTERFACE_ALREADY_HAVE_NETWORK=The Interface is already attached to a 
Network
 NETWROK_ALREAY_ATTACH_TO_INTERFACE=Network is already attached to an interface
 NETWORK_INTERFACE_NOT_HAVE_DISPLAY_FLAG=The specified interface is not a 
display interface
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 54bea2c..738adef 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -1030,7 +1030,7 @@
     @DefaultStringValue("Cannot ${action} ${type}. Only Storage Domain name is 
updateable.")
     String ERROR_CANNOT_CHANGE_STORAGE_DOMAIN_FIELDS();
 
-    @DefaultStringValue("Cannot update Data Center compatibility version to a 
value that is greater than its Cluster's version.")
+    @DefaultStringValue("Cannot update Data Center compatibility version to a 
value that is greater than its Cluster's version. The following clusters should 
be upgraded ${ClustersList}.")
     String 
ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS();
 
     @DefaultStringValue("Cannot import Storage Domain. Internal Error: The 
connection data is illegal.")
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 2e96cdd..0f0ccc9 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
@@ -389,7 +389,7 @@
 ERROR_CANNOT_EXTEND_NON_DATA_DOMAIN=Cannot extend Storage Domain. Extend 
operation is supported only on Data Storage Domain.
 ERROR_CANNOT_EXTEND_CONNECTION_FAILED=Cannot extend Storage Domain. Storage 
device ${lun} is unreachable from ${hostName}.
 ERROR_CANNOT_CHANGE_STORAGE_DOMAIN_FIELDS=Cannot ${action} ${type}. Only 
Storage Domain name is updateable.
-ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS=Cannot
 update Data Center compatibility version to a value that is greater than its 
Cluster's version.
+ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS=Cannot
 update Data Center compatibility version to a value that is greater than its 
Cluster's version. The following clusters should be upgraded ${ClustersList}.
 ERROR_CANNOT_ADD_EXISTING_STORAGE_DOMAIN_CONNECTION_DATA_ILLEGAL=Cannot import 
Storage Domain. Internal Error: The connection data is illegal.
 ERROR_CANNOT_ADD_EXISTING_STORAGE_DOMAIN_LUNS_PROBLEM=Cannot import Storage 
Domain. Not all LUNs connected to Storage Domain.
 NETWORK_MAC_ADDRESS_IN_USE=MAC Address is already in use.
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 7188f9a..ebafb0a 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
@@ -387,7 +387,7 @@
 ERROR_CANNOT_EXTEND_NON_DATA_DOMAIN=Cannot extend Storage Domain. Extend 
operation is supported only on Data Storage Domain.
 ERROR_CANNOT_EXTEND_CONNECTION_FAILED=Cannot extend Storage Domain. Storage 
device ${lun} is unreachable from ${hostName}.
 ERROR_CANNOT_CHANGE_STORAGE_DOMAIN_FIELDS=Cannot ${action} ${type}. Only 
Storage Domain name is updateable.
-ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS=Cannot
 update Data Center compatibility version to a value that is greater than its 
Cluster's version.
+ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS=Cannot
 update Data Center compatibility version to a value that is greater than its 
Cluster's version. The following clusters should be upgraded ${ClustersList}.
 ERROR_CANNOT_ADD_EXISTING_STORAGE_DOMAIN_CONNECTION_DATA_ILLEGAL=Cannot import 
Storage Domain. Internal Error: The connection data is illegal.
 ERROR_CANNOT_ADD_EXISTING_STORAGE_DOMAIN_LUNS_PROBLEM=Cannot import Storage 
Domain. Not all LUNs connected to Storage Domain.
 NETWORK_MAC_ADDRESS_IN_USE=MAC Address is already in use.


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

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

Reply via email to