Moti Asayag has uploaded a new change for review.

Change subject: engine: Block unsupported profiles from vNICs
......................................................................

engine: Block unsupported profiles from vNICs

The patch prevents from setting a vnic profile with
properties which aren't supported by the cluster to
the vnic of the vm which resides in that cluster.

Change-Id: I320d583437eac59fef62270aa7699afd8e6bbd6e
Bug-Url: https://bugzilla.redhat.com/1024209
Signed-off-by: Moti Asayag <masa...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VmNicValidatorTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.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/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
M packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
10 files changed, 45 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/71/20671/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java
index e085e46..4b1a360 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java
@@ -87,6 +87,19 @@
             if (!FeatureSupported.networkQoS(version) && 
vnicProfile.getNetworkQosId() != null)
                 return new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_NETWORK_QOS_IS_NOT_SUPPORTED,
                         clusterVersion());
+
+            // Check if the profile contains custom properties is supported in 
the current cluster's version
+            if (!FeatureSupported.deviceCustomProperties(version)
+                    && !(vnicProfile.getCustomProperties() == null || 
vnicProfile.getCustomProperties().isEmpty())) {
+                return new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_CUSTOM_PROPERTIES_NOT_SUPPORTED,
+                        clusterVersion());
+            }
+
+            // Check that if the profile marked for port mirroring is 
supported in the current cluster's version
+            if (!FeatureSupported.portMirroring(version) && 
vnicProfile.isPortMirroring()) {
+                return new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_PORT_MIRRORING_NOT_SUPPORTED,
+                        clusterVersion());
+            }
         }
         return ValidationResult.VALID;
     }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VmNicValidatorTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VmNicValidatorTest.java
index 7257b63..fa6d111 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VmNicValidatorTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VmNicValidatorTest.java
@@ -238,6 +238,9 @@
         
doReturn(networkExist).when(validator).isNetworkInCluster(any(Network.class), 
any(Guid.class));
 
         mockConfigRule.mockConfigValue(ConfigValues.NetworkQosSupported, 
version, qosSupported);
+        
mockConfigRule.mockConfigValue(ConfigValues.SupportCustomDeviceProperties, 
version, false);
+        mockConfigRule.mockConfigValue(ConfigValues.PortMirroringSupported, 
version, false);
+
         when(vnicProfile.getNetworkQosId()).thenReturn(qosNotNull ? 
DEFAULT_GUID : null);
         when(nic.getVnicProfileId()).thenReturn(VNIC_PROFILE_ID);
 
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
index cc0eea6..f7e69f0 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
@@ -186,4 +186,13 @@
     public static boolean hotPlugDiskSnapshot(Version version) {
         return supportedInConfig(ConfigValues.HotPlugDiskSnapshotSupported, 
version);
     }
+
+    /**
+     * @param version
+     *            Compatibility version to check for.
+     * @return <code>true</code> if port mirroring is supported for the 
version, <code>false</code> if it's not.
+     */
+    public static boolean portMirroring(Version version) {
+        return supportedInConfig(ConfigValues.PortMirroringSupported, version);
+    }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
index 2f5495a..fa0babb 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
@@ -1108,6 +1108,10 @@
     @DefaultValueAttribute("true")
     MTUOverrideSupported,
 
+    @TypeConverterAttribute(Boolean.class)
+    @DefaultValueAttribute("true")
+    PortMirroringSupported,
+
     @Reloadable
     @TypeConverterAttribute(Integer.class)
     @DefaultValueAttribute("1800")
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 7f9f8f2..6b520df 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
@@ -666,6 +666,8 @@
     HOT_PLUG_DISK_SNAPSHOT_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     NULL_NETWORK_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     ACTION_TYPE_FAILED_NETWORK_QOS_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
+    
ACTION_TYPE_FAILED_CUSTOM_PROPERTIES_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
+    ACTION_TYPE_FAILED_PORT_MIRRORING_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 5f12379..d93b774 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -859,6 +859,8 @@
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 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_CUSTOM_PROPERTIES_NOT_SUPPORTED=Cannot ${action} ${type}. 
There are custom properties on the profile, this is not supported for clusters 
of version ${clusterVersion}.
+ACTION_TYPE_FAILED_PORT_MIRRORING_NOT_SUPPORTED=Cannot ${action} ${type}. The 
port mirroring is enabled for the profile, this is not supported for clusters 
of version ${clusterVersion}.
 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 fd4fa6b..31ae13a 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
@@ -2308,6 +2308,12 @@
     @DefaultStringValue("Cannot ${action} ${type}. There is Network QoS on the 
profile, this is not supported for clusters of version ${clusterVersion}.")
     String ACTION_TYPE_FAILED_NETWORK_QOS_IS_NOT_SUPPORTED();
 
+    @DefaultStringValue("Cannot ${action} ${type}. There are custom properties 
on the profile, this is not supported for clusters of version 
${clusterVersion}.")
+    String ACTION_TYPE_FAILED_CUSTOM_PROPERTIES_NOT_SUPPORTED();
+
+    @DefaultStringValue("Cannot ${action} ${type}. The port mirroring is 
enabled for the profile, this is not supported for clusters of version 
${clusterVersion}.")
+    String ACTION_TYPE_FAILED_PORT_MIRRORING_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/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 ba5105d..166e5cc 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
@@ -834,6 +834,8 @@
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 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_CUSTOM_PROPERTIES_NOT_SUPPORTED=Cannot ${action} ${type}. 
There are custom properties on the profile, this is not supported for clusters 
of version ${clusterVersion}.
+ACTION_TYPE_FAILED_PORT_MIRRORING_NOT_SUPPORTED=Cannot ${action} ${type}. The 
port mirroring is enabled for the profile, this is not supported for clusters 
of version ${clusterVersion}.
 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/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 b35ce35..6d40837 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
@@ -859,6 +859,8 @@
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 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_CUSTOM_PROPERTIES_NOT_SUPPORTED=Cannot ${action} ${type}. 
There are custom properties on the profile, this is not supported for clusters 
of version ${clusterVersion}.
+ACTION_TYPE_FAILED_PORT_MIRRORING_NOT_SUPPORTED=Cannot ${action} ${type}. The 
port mirroring is enabled for the profile, this is not supported for clusters 
of version ${clusterVersion}.
 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/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql 
b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
index a4328e6..76ceebf 100644
--- a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
+++ b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
@@ -383,6 +383,8 @@
 select fn_db_add_config_value('MTUOverrideSupported','true','3.1');
 select fn_db_add_config_value('MTUOverrideSupported','true','3.2');
 select fn_db_add_config_value('MTUOverrideSupported','true','3.3');
+select fn_db_add_config_value('PortMirroringSupported','false','3.0');
+select fn_db_add_config_value('PortMirroringSupported','false','3.1');
 --Handling Organization Name
 select fn_db_add_config_value('OrganizationName','oVirt','general');
 select fn_db_add_config_value('OriginType','OVIRT','general');


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I320d583437eac59fef62270aa7699afd8e6bbd6e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Moti Asayag <masa...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to