[node-patches] Change in ovirt-node[master]: valid: add to FQDNOrIPAddress, HostnameLength validation
dougsland at redhat.com
dougsland at redhat.com
Thu Mar 19 18:19:16 UTC 2015
Douglas Schilling Landgraf has uploaded a new change for review.
Change subject: valid: add to FQDNOrIPAddress, HostnameLength validation
......................................................................
valid: add to FQDNOrIPAddress, HostnameLength validation
This patch returns FQDNOrIPAddress validation to Hostname field
and adds to this validation function the HostnameLength check.
Change-Id: I02d907b69a15506ffc9337f642d97a301bf3c9f0
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1198990
Signed-off-by: Douglas Schilling Landgraf <dougsland at redhat.com>
---
M src/ovirt/node/config/defaults.py
M src/ovirt/node/setup/core/network_page.py
M src/ovirt/node/valid.py
3 files changed, 11 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/50/38950/1
diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index 839a9d5..e1a5bca 100755
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -709,7 +709,7 @@
@NodeConfigFileSection.map_and_update_defaults_decorator
def update(self, hostname):
- (valid.Empty() | valid.HostnameLength())(hostname)
+ (valid.Empty() | valid.FQDNOrIPAddress())(hostname)
def transaction(self):
cfg = self.retrieve()
diff --git a/src/ovirt/node/setup/core/network_page.py b/src/ovirt/node/setup/core/network_page.py
index de7d7fe..3baa3ac 100644
--- a/src/ovirt/node/setup/core/network_page.py
+++ b/src/ovirt/node/setup/core/network_page.py
@@ -169,7 +169,6 @@
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)$",
@@ -177,7 +176,7 @@
)
# No regex, but for users ^
- return {"hostname": hostname_64_chars_or_empty,
+ return {"hostname": fqdn_ip_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 c8e415a..7209958 100644
--- a/src/ovirt/node/valid.py
+++ b/src/ovirt/node/valid.py
@@ -450,6 +450,12 @@
True
>>> FQDNOrIPAddress().validate("")
False
+ >>> FQDNOrIPAddress().validate('localhost.localdomain.11111111111111111111\
+1111111111111111111111')
+ True
+ >>> FQDNOrIPAddress().validate('localhost.localdomain.11111111111111111111\
+11111111111111111111111')
+ False
"""
def __init__(self, allow_ipv6=True):
@@ -457,7 +463,9 @@
self.description = self._validator.description
def validate(self, value):
- return self._validator.validate(value)
+ if HostnameLength()(value) and self._validator.validate(value):
+ return True
+ return False
class Options(Validator):
--
To view, visit https://gerrit.ovirt.org/38950
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I02d907b69a15506ffc9337f642d97a301bf3c9f0
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