[node-patches] Change in ovirt-node[master]: Add validation for SSH Location

fabiand at fedoraproject.org fabiand at fedoraproject.org
Mon Jul 15 11:39:19 UTC 2013


Fabian Deutsch has posted comments on this change.

Change subject: Add validation for SSH Location
......................................................................


Patch Set 2: I would prefer that you didn't submit this

(2 inline comments)

....................................................
File src/ovirt/node/valid.py
Line 258:     description = "a string without spaces"
Line 259:     pattern = "^\S+$"
Line 260: 
Line 261: 
Line 262: class SSH(RegexValidator):
Please rename the class to something more descriptiove. E.g.: SSHUrl or SshAddress or whatsoever .. maybe there is even an official name for it.


Further more I'd recommend using the FQDNorIPAddress validator to validate the host part and to use the text validator to validate the user part.
That way we can also cover IPv6 addresses.

Something along the lines:

  parts = value.split("@")
  if len parts != 2:
     raise ...
  user, host = parts
  return Text().validate(user) and FQDNOrIpAddress().validate(host)
Line 263:     """Matches a ssh server
Line 264: 
Line 265:     >>> SSH()("root at example.com")
Line 266:     True


Line 275:     description = "a valid SSH"
Line 276:     pattern = ("^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*" +
Line 277:                "?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$", re.I)
Line 278: 
Line 279:     def validate(self, value):
In general you don't need to define the validate() method if you are dervigin from the RegexValidator - specifying a pattern and description is enough.
Line 280:         is_valid = super(SSH, self).validate(value)
Line 281:         return is_valid
Line 282: 
Line 283: 


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I7d9153cdd7cddecf238a82d7e1639f74386795fe
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: hadong <hadong0720 at gmail.com>
Gerrit-Reviewer: Fabian Deutsch <fabiand at fedoraproject.org>
Gerrit-Reviewer: oVirt Jenkins CI Server



More information about the node-patches mailing list