Change in vdsm[master]: net: IP address hostport split tool

nsoffer at redhat.com nsoffer at redhat.com
Fri Mar 4 09:14:10 UTC 2016


Nir Soffer has posted comments on this change.

Change subject: net: IP address hostport split tool
......................................................................


Patch Set 2:

(3 comments)

https://gerrit.ovirt.org/#/c/54312/2//COMMIT_MSG
Commit Message:

Line 3: AuthorDate: 2016-03-03 17:50:20 +0200
Line 4: Commit:     Edward Haas <edwardh at redhat.com>
Line 5: CommitDate: 2016-03-03 18:21:01 +0200
Line 6: 
Line 7: net: IP address hostport split tool
hostport is correct only for the networking case, but we need a more generic name, maybe hostspec?

This code should be in lib/vdsm/ or lib/vdsm/common, not in lib/vdsm/network.
Line 8: 
Line 9: vdsm.network.ip.address.hostport_split is provided to decode hostport
Line 10: and nfs mount path.
Line 11: Both use the following structure: host:rest, where 'rest' is either a


https://gerrit.ovirt.org/#/c/54312/2/lib/vdsm/network/ip/address.py
File lib/vdsm/network/ip/address.py:

Line 30:     For an IPv6 address host, it returns the address without the surrounding
Line 31:     brackets.
Line 32:     """
Line 33:     try:
Line 34:         host, rest = hostport.rsplit(':', 1)
Will fail for "host:/a:b:c"
Line 35:         if _is_ipv6_addr_soft_check(host):
Line 36:             host = _ipv6addr_strip_brackets(host)
Line 37:     except ValueError:
Line 38:         raise HostportError('%s is not a valid hostport address:' % hostport)


https://gerrit.ovirt.org/#/c/54312/2/tests/network/ip_test.py
File tests/network/ip_test.py:

Line 23: from vdsm.network.ip import address as ipaddress
Line 24: 
Line 25: 
Line 26: class TestIpAddressHostPort(VdsmTestCase):
Line 27: 
You should use permutations:

    @permutations([
        # address, host, spec
        ("1.2.3.4:4321", "1.2.3.4", "4321"),
        ("[200::1]:4321", "2000::1", "4321"),
        ("f.q.d.n:80", "f.q.d.n", "80"),
        ("1.2.3.4:/a:b:c", "1.2.3.4", "/a:b:c"),
        ("[200::1]:/a:b:c", "2000::1", "/a:b:c"),
        ("f.q.d.n:/a:b:c", "f.q.d.n", "/a:b:c"),
    )]
    def test_split(self, address, host, spec):
        self.assertEqual((host, spec), address.split(address))

Regular expression should be the easiest way to implement this.
Line 28:     def test_hostport_ipv4(self):
Line 29:         self._hostport_split_check('1.2.3.4', '4321')
Line 30: 
Line 31:     def test_hostport_ipv6(self):


-- 
To view, visit https://gerrit.ovirt.org/54312
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib246c78987f9707674a1966df91120d4189b41fc
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <edwardh at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Edward Haas <edwardh at redhat.com>
Gerrit-Reviewer: Freddy Rolland <frolland at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Ondřej Svoboda <osvoboda at redhat.com>
Gerrit-Reviewer: Petr Horáček <phoracek at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list