Moti Asayag has uploaded a new change for review. Change subject: core: Validate only supported nics are labeled ......................................................................
core: Validate only supported nics are labeled Only interfaces or bonds can be labeled. Labeling slaves and vlans is not supported and should be blocked. Change-Id: Id510dd0ae8f24533aaf7b6760e6188d2e036b312 Signed-off-by: Moti Asayag <masa...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/NetworkInterfaceValidator.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 5 files changed, 23 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/68/22868/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/NetworkInterfaceValidator.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/NetworkInterfaceValidator.java index 321e8b3..6bc8d1c 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/NetworkInterfaceValidator.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/NetworkInterfaceValidator.java @@ -42,6 +42,11 @@ return false; } + if (validateLabel(iface)) { + context.disableDefaultConstraintViolation(); + context.buildConstraintViolationWithTemplate("IMPROPER_INTERFACE_IS_LABELED").addConstraintViolation(); + } + return true; } @@ -70,4 +75,16 @@ private static boolean isEmpty(String value) { return value == null || value.isEmpty(); } + + /** + * Checks if a given nic is labeled properly: either an interface or a bond (not a slave nor vlan). + * + * @param iface + * the nic to check + * @return <code>true</code> iff the nic is properly labled or if no labels provided for it, else <code>false</code> + */ + private boolean validateLabel(VdsNetworkInterface iface) { + return iface.getLabels() == null || iface.getLabels().isEmpty() ? true : isEmpty(iface.getBondName()) + && iface.getVlanId() == null; + } } 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 97458ce..1dc4d92 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -698,6 +698,7 @@ VDS_GROUP_CANNOT_DISABLE_GLUSTER_WHEN_CLUSTER_CONTAINS_VOLUMES=Cannot disable gluster service on the cluster as it contains volumes. NETWORK_ATTACH_ILLEGAL_GATEWAY=The default gateway should be set only on the Management Network SLAVE_INTERFACE_IS_MISCONFIGURED=A slave interface is not properly configured. Please verify slaves do not contain any of the following properties: network name, boot protocol, IP address, netmask, gateway or vlan-ID notation (as part of interface's name or explicitly). +IMPROPER_INTERFACE_IS_LABELED=An improper network interface is labeled. Please verify labels are provided only to interfaces or to bonds (not to slaves nor vlans). MISSING_DIRECTORY_ELEMENT_ID=User/group ID cannot be empty. NETWORK_ILEGAL_NETWORK_NAME=Network name must be 1-15 long and can contain only 'A-Z', 'a-z', '0-9', '_' characters STORAGE_OPERATION_FAILED_SPM_NETWORK_PROBLEMS=Storage related operations can't be performed while the Storage Pool Manager is down.\nPlease make sure the Storage Pool Manager is up and running, and check network connectivity. 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 8705108..0c0afda 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 @@ -1892,6 +1892,9 @@ @DefaultStringValue("A slave interface is not properly configured. Please verify slaves do not contain any of the following properties: network name, boot protocol, IP address, netmask, gateway or vlan-ID notation (as part of interface's name or explicitly).") String SLAVE_INTERFACE_IS_MISCONFIGURED(); + @DefaultStringValue("An improper network interface is labeled. Please verify labels are provided only to interfaces or to bonds (not to slaves nor vlans).") + String IMPROPER_INTERFACE_IS_LABELED(); + @DefaultStringValue("User/group ID cannot be empty.") String MISSING_DIRECTORY_ELEMENT_ID(); 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 7d23771..86cf739 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 @@ -680,6 +680,7 @@ VDS_GROUP_CANNOT_DISABLE_GLUSTER_WHEN_CLUSTER_CONTAINS_VOLUMES=Cannot disable gluster service on the cluster as it contains volumes. NETWORK_ATTACH_ILLEGAL_GATEWAY=The default gateway should be set only on the Management Network SLAVE_INTERFACE_IS_MISCONFIGURED=A slave interface is not properly configured. Please verify slaves do not contain any of the following properties: network name, boot protocol, IP address, netmask, gateway or vlan-ID notation (as part of interface's name or explicitly). +IMPROPER_INTERFACE_IS_LABELED=An improper network interface is labeled. Please verify labels are provided only to interfaces or to bonds (not to slaves nor vlans). MISSING_DIRECTORY_ELEMENT_ID=User/group ID cannot be empty. NETWORK_ILEGAL_NETWORK_NAME=Network name must be 1-15 long and can contain only 'A-Z', 'a-z', '0-9', '_' characters STORAGE_OPERATION_FAILED_SPM_NETWORK_PROBLEMS=Storage related operations can't be performed while the Storage Pool Manager is down.\nPlease make sure the Storage Pool Manager is up and running, and check network connectivity. 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 06033b8..9f17e51 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 @@ -699,6 +699,7 @@ VDS_GROUP_CANNOT_DISABLE_GLUSTER_WHEN_CLUSTER_CONTAINS_VOLUMES=Cannot disable gluster service on the cluster as it contains volumes. NETWORK_ATTACH_ILLEGAL_GATEWAY=The default gateway should be set only on the Management Network SLAVE_INTERFACE_IS_MISCONFIGURED=A slave interface is not properly configured. Please verify slaves do not contain any of the following properties: network name, boot protocol, IP address, netmask, gateway or vlan-ID notation (as part of interface's name or explicitly). +IMPROPER_INTERFACE_IS_LABELED=An improper network interface is labeled. Please verify labels are provided only to interfaces or to bonds (not to slaves nor vlans). MISSING_DIRECTORY_ELEMENT_ID=User/group ID cannot be empty. NETWORK_ILEGAL_NETWORK_NAME=Network name must be 1-15 long and can contain only 'A-Z', 'a-z', '0-9', '_' characters STORAGE_OPERATION_FAILED_SPM_NETWORK_PROBLEMS=Storage related operations can't be performed while the Storage Pool Manager is down.\nPlease make sure the Storage Pool Manager is up and running, and check network connectivity. -- To view, visit http://gerrit.ovirt.org/22868 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id510dd0ae8f24533aaf7b6760e6188d2e036b312 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