[node-patches] Change in ovirt-node[master]: network_page: Add hostname validation length

dougsland at redhat.com dougsland at redhat.com
Fri Sep 5 01:10:16 UTC 2014


Douglas Schilling Landgraf has uploaded a new change for review.

Change subject: network_page: Add hostname validation length
......................................................................

network_page: Add hostname validation length

The commands hostname or hostnamectl accepts up to 64 chars.
This patch adds a validation for this entry in the TUI.

Change-Id: I6c542f7ec0b68fe8531c37791362daa7580cd06c
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1077996
Signed-off-by: Douglas Schilling Landgraf <dougsland at redhat.com>
---
M src/ovirt/node/setup/core/network_page.py
M src/ovirt/node/valid.py
2 files changed, 21 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/09/32509/1

diff --git a/src/ovirt/node/setup/core/network_page.py b/src/ovirt/node/setup/core/network_page.py
index 92d294a..55110a7 100644
--- a/src/ovirt/node/setup/core/network_page.py
+++ b/src/ovirt/node/setup/core/network_page.py
@@ -150,6 +150,7 @@
 
     def validators(self):
         ip_or_empty = valid.IPAddress() | valid.Empty()
+        hostname_64_chars_or_empty = valid.HostnameLength() | valid.Empty()
         fqdn_ip_or_empty = valid.FQDNOrIPAddress() | valid.Empty()
 
         valid_bond_name = valid.RegexValidator("^(bond[0-9]{1,2}|007)$",
@@ -157,7 +158,7 @@
                                                )
         # No regex, but for users ^
 
-        return {"hostname": fqdn_ip_or_empty,
+        return {"hostname": hostname_64_chars_or_empty,
                 "dns[0]": ip_or_empty,
                 "dns[1]": ip_or_empty,
                 "ntp[0]": fqdn_ip_or_empty,
diff --git a/src/ovirt/node/valid.py b/src/ovirt/node/valid.py
index 8367efa..d4db707 100644
--- a/src/ovirt/node/valid.py
+++ b/src/ovirt/node/valid.py
@@ -322,6 +322,25 @@
         return is_valid
 
 
+class HostnameLength(Validator):
+    """hostname or hostnamectl tools only accepts 64 chars or less
+
+    >>> HostnameLength().validate('localhost.localdomain.11111111111111111111\
+1111111111111111111111')
+    True
+    >>> HostnameLength().validate('localhost.localdomain.11111111111111111111\
+11111111111111111111111')
+    False
+    """
+
+    description = "a field less then 64 chars"
+
+    def validate(self, value):
+        if len(value) <= 64:
+            return True
+        return False
+
+
 class FQDNLength(Validator):
     """Matches a FQDN and ensures that fields are 63 characters or less
     per level and 255 characters or less total


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c542f7ec0b68fe8531c37791362daa7580cd06c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland at redhat.com>



More information about the node-patches mailing list