urlsplit issues with IPv6 addresses in python26

Bug #1298137 reported by Davanum Srinivas (DIMS)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance Client
Fix Released
Medium
Unassigned
oslo-incubator
Fix Released
Undecided
Davanum Srinivas (DIMS)
python-novaclient
Fix Released
Undecided
Unassigned

Bug Description

we need to handle the broken urlparse impl on py26 better somehow

[root@localhost ~]# python
Python 2.6.6 (r266:84292, May 1 2012, 13:52:17)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from nova.openstack.common import network_utils
>>> ipv6_url = 'https://dims:abc@[2001:db8:85a3::8a2e:370:7334]/v2.0/xy?ab#12'
>>> tuple = network_utils.urlsplit(ipv6_url)
>>> print tuple
SplitResult(scheme='https', netloc='dims:abc@[2001:db8:85a3::8a2e:370:7334]', path='/v2.0/xy', query='ab', fragment='12')
>>> print tuple.port
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/urlparse.py", line 102, in port
    return int(port, 10)
ValueError: invalid literal for int() with base 10: 'db8:85a3::8a2e:370:7334]'

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo-incubator (master)

Fix proposed to branch: master
Review: https://review.openstack.org/83268

Changed in oslo:
assignee: nobody → Davanum Srinivas (DIMS) (dims-v)
status: New → In Progress
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

vagrant@precise64:~/openstack/python-novaclient$ nova --debug --os-auth-url http://[::1]:5003/v2.0/ --bypass-url http://[::1]:8774/v2/78a98c24eec945e28d74beb82178607b list
2.6.6 (r266:84292, Mar 27 2014, 13:56:54)
[GCC 4.6.3]
DEBUG (shell:791) invalid literal for int() with base 10: ':1]:5003'
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/site-packages/novaclient/shell.py", line 788, in main
    OpenStackComputeShell().main(map(strutils.safe_decode, sys.argv[1:]))
  File "/usr/local/lib/python2.6/site-packages/novaclient/shell.py", line 693, in main
    self.cs.authenticate()
  File "/usr/local/lib/python2.6/site-packages/novaclient/v1_1/client.py", line 173, in authenticate
    self.client.authenticate()
  File "/usr/local/lib/python2.6/site-packages/novaclient/client.py", line 360, in authenticate
    port = magic_tuple.port
  File "/usr/local/lib/python2.6/urlparse.py", line 102, in port
    return int(port, 10)
ValueError: invalid literal for int() with base 10: ':1]:5003'
ERROR (ValueError): invalid literal for int() with base 10: ':1]:5003'

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

Glance runs into the same problem too

vagrant@precise64:~/openstack/python-glanceclient$ glance --debug --os-auth-url 'http://[::1]:5003/v2.0/' --os-image-url 'http://[::1]:9292/v1' image-list
invalid literal for int() with base 10: ':1]:9292'

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo-incubator (master)

Reviewed: https://review.openstack.org/83268
Committed: https://git.openstack.org/cgit/openstack/oslo-incubator/commit/?id=897aa7c42e1970e9a40799dac87a654cb1b10981
Submitter: Jenkins
Branch: master

commit 897aa7c42e1970e9a40799dac87a654cb1b10981
Author: Davanum Srinivas <email address hidden>
Date: Wed Mar 26 21:48:05 2014 -0400

    urlsplit issues with IPv6 addresses in python26

    urlsplit can't handle RFC 2732 URLs. reuse the
    parse_host_port to rectify the hostname and
    port implementation of SplitResult. Added test
    cases to make sure we get the right ip and port
    when the urls have ipv6 in them. Added an additional
    test for both ipv4 and ipv6 to ensure we are indeed
    handling username password in urls as well

    Change-Id: I054f5e46cc8c201aaa48ee2d8b9d0a09b30a48ce
    Closes-Bug: #1298137

Changed in oslo:
status: In Progress → Fix Committed
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

heat works fine

vagrant@precise64:~/openstack/python-heatclient$ heat --os-auth-url 'http://[::1]:5003/v2.0/' --heat-url 'http://[::1]:8004/v1/78a98c24eec945e28d74beb82178607b' stack-list

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/83576
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=9344f02649df65af26ca13b4d3443be73beb5d4e
Submitter: Jenkins
Branch: master

commit 9344f02649df65af26ca13b4d3443be73beb5d4e
Author: Davanum Srinivas <email address hidden>
Date: Thu Mar 27 20:14:48 2014 +0000

    Fix for invalid literal ValueError parsing ipv6 url(s)

    Switch to using network_utils for splitting the URL. The code
    in oslo-incubator supports ipv6 urls

    HEAD of oslo-incubator is bb52a3fc49f033b9f36238231ca56e754a78cf4b

    Updated openstack-common.conf to pick up the new dependency from
    oslo-incubator

    Change-Id: Ifa3dec384e85942a191260d17e8141030d31ff84
    Closes-Bug: #1298137

Changed in python-novaclient:
status: New → Fix Committed
Alex Meade (alex-meade)
Changed in python-glanceclient:
importance: Undecided → Medium
Thierry Carrez (ttx)
Changed in oslo:
milestone: none → icehouse-rc1
status: Fix Committed → Fix Released
Revision history for this message
Dazhao Yu (dzyu) wrote :

Hi Davanum,
I have faced this problem, in order to work well with IPv6, I make one workabound in Python 2.6 urlparse file. It seems like your method cna be fix such issue, thanks for it.

I guess many components need make some code change about it, such as nova, cinder, and cinder client. Do you have some plan about these code change? If you need help, please let me know, thanks!

Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to python-glanceclient (master)

Reviewed: https://review.openstack.org/83586
Committed: https://git.openstack.org/cgit/openstack/python-glanceclient/commit/?id=078819cf9ea121bbffc71ad0af6b3bea1d897b0b
Submitter: Jenkins
Branch: master

commit 078819cf9ea121bbffc71ad0af6b3bea1d897b0b
Author: Davanum Srinivas <email address hidden>
Date: Thu Mar 27 20:57:09 2014 +0000

    Fix for invalid literal ValueError parsing ipv6 url(s)

    Switch to using network_utils for splitting the URL. The code
    in oslo-incubator supports ipv6 urls

    Change-Id: I76be6173b97eb000319d30b4e9232a5a7c4a5aba
    Closes-Bug: #1298137

Changed in python-glanceclient:
status: New → Fix Committed
Thierry Carrez (ttx)
Changed in oslo:
milestone: icehouse-rc1 → 2014.1
Michael Still (mikal)
Changed in python-novaclient:
milestone: none → 2.18.0
Michael Still (mikal)
Changed in python-novaclient:
status: Fix Committed → Fix Released
Louis Taylor (kragniz)
Changed in python-glanceclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.