Moti Asayag has uploaded a new change for review.

Change subject: engine: Block cluster change if network labels not supported
......................................................................

engine: Block cluster change if network labels not supported

Network labels are supported only if setup networks is
supported by the cluster level. Therefore a host which
has network labels shouldn't be moved to a cluster which
doesn't support it, without removing the labels from the
nics.

Change-Id: I918905e2e5ca01726a0a647109b11e1bbeb5596a
Bug-Url: https://bugzilla.redhat.com/1063285
Signed-off-by: Moti Asayag <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
5 files changed, 36 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/24/24524/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java
index a5dcb98..3e688b3 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java
@@ -57,6 +57,8 @@
 
     private AuditLogType errorType = AuditLogType.USER_FAILED_UPDATE_VDS;
 
+    private List<VdsNetworkInterface> hostNics;
+
     /**
      * Constructor for command creation when compensation is applied on startup
      * @param commandId
@@ -123,7 +125,7 @@
 
         if 
(FeatureSupported.hostNetworkQos(getSourceCluster().getcompatibility_version())
                 && 
!FeatureSupported.hostNetworkQos(getTargetCluster().getcompatibility_version()))
 {
-            for (VdsNetworkInterface iface : 
getDbFacade().getInterfaceDao().getAllInterfacesForVds(vds.getId())) {
+            for (VdsNetworkInterface iface : getHostNics()) {
                 if (iface.getQos() != null) {
                     return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED,
                             
String.format("$ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED_LIST %s",
@@ -132,7 +134,29 @@
             }
         }
 
+        if (!targetClusterSupportsSetupNetworks() && hostHasLabeledNics()) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_HOST_NETWORK_LABELS_NOT_SUPPORTED);
+        }
+
         return true;
+    }
+
+    private boolean hostHasLabeledNics() {
+        for (VdsNetworkInterface nic : getHostNics()) {
+            if (NetworkUtils.isLabeled(nic)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private List<VdsNetworkInterface> getHostNics() {
+        if (hostNics == null) {
+            hostNics = 
getDbFacade().getInterfaceDao().getAllInterfacesForVds(getVdsId());
+        }
+
+        return hostNics;
     }
 
     private boolean hasUpServer(VDSGroup cluster) {
@@ -219,13 +243,17 @@
             getVdsSpmIdMapDAO().removeByVdsAndStoragePool(getVds().getId(), 
getSourceCluster().getStoragePoolId());
         }
 
-        if 
(NetworkHelper.setupNetworkSupported(getTargetCluster().getcompatibility_version()))
 {
+        if (targetClusterSupportsSetupNetworks()) {
             configureNetworks();
         }
 
         setSucceeded(true);
     }
 
+    private boolean targetClusterSupportsSetupNetworks() {
+        return 
NetworkHelper.setupNetworkSupported(getTargetCluster().getcompatibility_version());
+    }
+
     private void configureNetworks() {
         ChangeClusterParametersBuilder builder = new 
ChangeClusterParametersBuilder();
         final PersistentSetupNetworksParameters params;
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index 5721f1c..bb30c0a 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -714,6 +714,7 @@
     NULL_NETWORK_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     ACTION_TYPE_FAILED_NETWORK_QOS_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
+    
ACTION_TYPE_FAILED_HOST_NETWORK_LABELS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     
ACTION_TYPE_FAILED_VM_INTERFACE_TYPE_IS_NOT_SUPPORTED_BY_OS(ErrorType.INCOMPATIBLE_VERSION),
     CANNOT_PERFORM_HOT_UPDATE(ErrorType.CONFLICT),
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 f05adf7..5776129 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -902,6 +902,7 @@
 NULL_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. There is no network on 
the virtual machine's interface, this is not supported for clusters of version 
${clusterVersion}.
 ACTION_TYPE_FAILED_NETWORK_QOS_IS_NOT_SUPPORTED=Cannot ${action} ${type}. 
There is Network QoS on the profile, this is not supported for clusters of 
version ${clusterVersion}.
 ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED=Cannot ${action} ${type}. 
Host Network QoS is not supported in the cluster's compatibility version, but 
QoS was configured on the following network(s): 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED_LIST}.
+ACTION_TYPE_FAILED_HOST_NETWORK_LABELS_NOT_SUPPORTED=Cannot ${action} ${type}. 
Host nics network labels are not supported in the cluster's compatibility 
version, but network labels are configured on the host's nics.
 HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Updating 
the virtual machine interface while the virtual machine is running is not 
supported for clusters of version ${clusterVersion}.
 ACTION_TYPE_FAILED_VM_INTERFACE_TYPE_IS_NOT_SUPPORTED_BY_OS=Cannot ${action} 
${type}. The network interface type is not compatible with the selected 
operating system.
 CANNOT_PERFORM_HOT_UPDATE=Cannot ${action} ${type}. Updating some of the 
properties is not supported while the interface is plugged into a running 
virtual machine. Please un-plug the interface, update the properties, and then 
plug it back.
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 05efaa5..46dcf57 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
@@ -2446,6 +2446,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. Host Network QoS is not 
supported in the cluster's compatibility version, but QoS was configured on the 
following network(s): 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED_LIST}.")
     String ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Host nics network labels 
are not supported in the cluster's compatibility version, but network labels 
are configured on the host's nics.")
+    String ACTION_TYPE_FAILED_HOST_NETWORK_LABELS_NOT_SUPPORTED();
+
     @DefaultStringValue("Cannot ${action} ${type}. Updating the virtual 
machine interface while the virtual machine is running is not supported for 
clusters of version ${clusterVersion}.")
     String HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED();
 
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 c231902..b29b51f 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
@@ -901,6 +901,7 @@
 NULL_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. There is no network on 
the virtual machine's interface, this is not supported for clusters of version 
${clusterVersion}.
 ACTION_TYPE_FAILED_NETWORK_QOS_IS_NOT_SUPPORTED=Cannot ${action} ${type}. 
There is Network QoS on the profile, this is not supported for clusters of 
version ${clusterVersion}.
 ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED=Cannot ${action} ${type}. 
Host Network QoS is not supported in the cluster's compatibility version, but 
QoS was configured on the following network(s): 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED_LIST}.
+ACTION_TYPE_FAILED_HOST_NETWORK_LABELS_NOT_SUPPORTED=Cannot ${action} ${type}. 
Host nics network labels are not supported in the cluster's compatibility 
version, but network labels are configured on the host's nics.
 HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Updating 
the virtual machine interface while the virtual machine is running is not 
supported for clusters of version ${clusterVersion}.
 ACTION_TYPE_FAILED_VM_INTERFACE_TYPE_IS_NOT_SUPPORTED_BY_OS=Cannot ${action} 
${type}. The network interface type is not compatible with the selected 
operating system.
 CANNOT_PERFORM_HOT_UPDATE=Cannot ${action} ${type}. Updating some of the 
properties is not supported while the interface is plugged into a running 
virtual machine. Please un-plug the interface, update the properties, and then 
plug it back.


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

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

Reply via email to