[node-patches] Change in ovirt-node[master]: Add validation for SSH Location
hadong0720 at gmail.com
hadong0720 at gmail.com
Sun Jul 14 06:02:31 UTC 2013
hadong has uploaded a new change for review.
Change subject: Add validation for SSH Location
......................................................................
Add validation for SSH Location
Previously missed validation for SSH Location
when configuring kdump with ssh.
Now add it for ssh location.
Change-Id: I7d9153cdd7cddecf238a82d7e1639f74386795fe
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=981576
Signed-off-by: hadong <hadong0720 at gmail.com>
---
M src/ovirt/node/config/defaults.py
M src/ovirt/node/setup/core/kdump_page.py
M src/ovirt/node/valid.py
3 files changed, 24 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/96/16796/1
diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index 56ae68f..434ec52 100644
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -996,7 +996,7 @@
@NodeConfigFileSection.map_and_update_defaults_decorator
def update(self, nfs, ssh, local):
(valid.Empty(or_none=True) | valid.NFSAddress())(nfs)
- (valid.Empty(or_none=True) | valid.URL())(ssh)
+ (valid.Empty(or_none=True) | valid.SSH())(ssh)
(valid.Empty(or_none=True) | valid.Boolean())(local)
return {"OVIRT_KDUMP_LOCAL": "true" if local else None
}
diff --git a/src/ovirt/node/setup/core/kdump_page.py b/src/ovirt/node/setup/core/kdump_page.py
index 0e3888a..dbc114f 100644
--- a/src/ovirt/node/setup/core/kdump_page.py
+++ b/src/ovirt/node/setup/core/kdump_page.py
@@ -69,7 +69,7 @@
"""
# FIXME improve validation for ssh and nfs
return {"kdump.type": valid.Options(dict(self._types).keys()),
- "kdump.ssh_location": valid.Empty() | valid.URL(),
+ "kdump.ssh_location": valid.Empty() | valid.SSH(),
"kdump.nfs_location": valid.Empty() | valid.NFSAddress(),
}
diff --git a/src/ovirt/node/valid.py b/src/ovirt/node/valid.py
index 42ae4c4..e71712a 100644
--- a/src/ovirt/node/valid.py
+++ b/src/ovirt/node/valid.py
@@ -259,6 +259,28 @@
pattern = "^\S+$"
+class SSH(RegexValidator):
+ """Matches a ssh server
+
+ >>> SSH()("root at example.com")
+ True
+ >>> SSH()("root at 192.168.1.1")
+ True
+ >>> SSH()(".com")
+ False
+ >>> SSH()("")
+ False
+ """
+
+ description = "a valid SSH"
+ pattern = ("^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*" +
+ "?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$", re.I)
+
+ def validate(self, value):
+ is_valid = super(SSH, self).validate(value)
+ return is_valid
+
+
class FQDN(RegexValidator):
"""Matches a FQDN or a simple hostname
--
To view, visit http://gerrit.ovirt.org/16796
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d9153cdd7cddecf238a82d7e1639f74386795fe
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: hadong <hadong0720 at gmail.com>
More information about the node-patches
mailing list