Merge "Support glance client can get ipv6 image url correctly"
This commit is contained in:
commit
7a4a8a0979
@ -23,6 +23,7 @@ import re
|
||||
import sys
|
||||
|
||||
from keystoneclient.v2_0 import client as ksclient
|
||||
import netaddr
|
||||
|
||||
import glanceclient
|
||||
from glanceclient import exc
|
||||
@ -347,6 +348,9 @@ class OpenStackImagesShell(object):
|
||||
if args.os_image_url:
|
||||
return args.os_image_url
|
||||
elif args.host:
|
||||
# Check if it is legal ipv6 address, if so, need wrap it with '[]'
|
||||
if netaddr.valid_ipv6(args.host):
|
||||
args.host = '[%s]' % args.host
|
||||
scheme = 'https' if args.use_ssl else 'http'
|
||||
return '%s://%s:%s/' % (scheme, args.host, args.port)
|
||||
else:
|
||||
|
@ -80,3 +80,14 @@ class ShellTest(utils.TestCase):
|
||||
add_help=False,
|
||||
formatter_class=openstack_shell.HelpFormatter,)
|
||||
self.assertTrue(expected, actual_parser)
|
||||
|
||||
def test_get_image_url_by_ipv6Addr_host(self):
|
||||
fake_args = lambda: None
|
||||
setattr(fake_args, 'os_image_url', None)
|
||||
setattr(fake_args, 'host', '2011:2013:1:f101::1')
|
||||
setattr(fake_args, 'use_ssl', True)
|
||||
setattr(fake_args, 'port', '9292')
|
||||
expected_image_url = 'https://[2011:2013:1:f101::1]:9292/'
|
||||
test_shell = openstack_shell.OpenStackImagesShell()
|
||||
targeted_image_url = test_shell._get_image_url(fake_args)
|
||||
self.assertEqual(expected_image_url, targeted_image_url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user