Add SSL support to utils.generate_glance_url().
Since glance now supports SSL, we need to take this into consideration when generating the URL. Also updates and adds a test. A new config option 'glance_protocol' was added that defaults to 'http' since that's what the glance options, '*_client_protocol', default to. Set to 'https' for SSL. Change-Id: Id231a1fd4c4d8e221ae0cf6541181e5572dff02b
This commit is contained in:
parent
a6d8554fa3
commit
eae906f8a8
3
.mailmap
3
.mailmap
|
@ -37,7 +37,8 @@
|
||||||
<jmckenty@gmail.com> <jmckenty@yyj-dhcp171.corp.flock.com>
|
<jmckenty@gmail.com> <jmckenty@yyj-dhcp171.corp.flock.com>
|
||||||
<jmckenty@gmail.com> <joshua.mckenty@nasa.gov>
|
<jmckenty@gmail.com> <joshua.mckenty@nasa.gov>
|
||||||
<johannes.erdfelt@rackspace.com> <johannes@compute3.221.st>
|
<johannes.erdfelt@rackspace.com> <johannes@compute3.221.st>
|
||||||
<josh@jk0.org> <josh.kearney@rackspace.com>
|
<josh.kearney@pistoncloud.com> <josh.kearney@rackspace.com>
|
||||||
|
<josh.kearney@pistoncloud.com> <josh@jk0.org>
|
||||||
<justin@fathomdb.com> <justinsb@justinsb-desktop>
|
<justin@fathomdb.com> <justinsb@justinsb-desktop>
|
||||||
<kshileev@gmail.com> <kshileev@griddynamics.com>
|
<kshileev@gmail.com> <kshileev@griddynamics.com>
|
||||||
<lorin@nimbisservices.com> <lorin@isi.edu>
|
<lorin@nimbisservices.com> <lorin@isi.edu>
|
||||||
|
|
|
@ -86,6 +86,10 @@ global_opts = [
|
||||||
cfg.IntOpt('glance_port',
|
cfg.IntOpt('glance_port',
|
||||||
default=9292,
|
default=9292,
|
||||||
help='default glance port'),
|
help='default glance port'),
|
||||||
|
cfg.StrOpt('glance_protocol',
|
||||||
|
default='http',
|
||||||
|
help='Default protocol to use when connecting to glance. '
|
||||||
|
'Set to https for SSL.'),
|
||||||
cfg.ListOpt('glance_api_servers',
|
cfg.ListOpt('glance_api_servers',
|
||||||
default=['$glance_host:$glance_port'],
|
default=['$glance_host:$glance_port'],
|
||||||
help='A list of the glance api servers available to nova. '
|
help='A list of the glance api servers available to nova. '
|
||||||
|
|
|
@ -34,7 +34,9 @@ from nova import test
|
||||||
from nova import utils
|
from nova import utils
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
CONF.import_opt('glance_host', 'nova.config')
|
||||||
CONF.import_opt('glance_port', 'nova.config')
|
CONF.import_opt('glance_port', 'nova.config')
|
||||||
|
CONF.import_opt('glance_protocol', 'nova.config')
|
||||||
|
|
||||||
|
|
||||||
class ByteConversionTest(test.TestCase):
|
class ByteConversionTest(test.TestCase):
|
||||||
|
@ -379,10 +381,16 @@ class GenericUtilsTestCase(test.TestCase):
|
||||||
self.assertFalse(utils.bool_from_str(None))
|
self.assertFalse(utils.bool_from_str(None))
|
||||||
self.assertFalse(utils.bool_from_str('junk'))
|
self.assertFalse(utils.bool_from_str('junk'))
|
||||||
|
|
||||||
def test_generate_glance_url(self):
|
def test_generate_glance_http_url(self):
|
||||||
generated_url = utils.generate_glance_url()
|
generated_url = utils.generate_glance_url()
|
||||||
actual_url = "http://%s:%d" % (CONF.glance_host, CONF.glance_port)
|
http_url = "http://%s:%d" % (CONF.glance_host, CONF.glance_port)
|
||||||
self.assertEqual(generated_url, actual_url)
|
self.assertEqual(generated_url, http_url)
|
||||||
|
|
||||||
|
def test_generate_glance_https_url(self):
|
||||||
|
self.flags(glance_protocol="https")
|
||||||
|
generated_url = utils.generate_glance_url()
|
||||||
|
https_url = "https://%s:%d" % (CONF.glance_host, CONF.glance_port)
|
||||||
|
self.assertEqual(generated_url, https_url)
|
||||||
|
|
||||||
def test_read_cached_file(self):
|
def test_read_cached_file(self):
|
||||||
self.mox.StubOutWithMock(os.path, "getmtime")
|
self.mox.StubOutWithMock(os.path, "getmtime")
|
||||||
|
|
|
@ -59,7 +59,9 @@ CONF = cfg.CONF
|
||||||
CONF.register_opt(
|
CONF.register_opt(
|
||||||
cfg.BoolOpt('disable_process_locking', default=False,
|
cfg.BoolOpt('disable_process_locking', default=False,
|
||||||
help='Whether to disable inter-process locks'))
|
help='Whether to disable inter-process locks'))
|
||||||
|
CONF.import_opt('glance_host', 'nova.config')
|
||||||
CONF.import_opt('glance_port', 'nova.config')
|
CONF.import_opt('glance_port', 'nova.config')
|
||||||
|
CONF.import_opt('glance_protocol', 'nova.config')
|
||||||
CONF.import_opt('instance_usage_audit_period', 'nova.config')
|
CONF.import_opt('instance_usage_audit_period', 'nova.config')
|
||||||
CONF.import_opt('monkey_patch', 'nova.config')
|
CONF.import_opt('monkey_patch', 'nova.config')
|
||||||
CONF.import_opt('rootwrap_config', 'nova.config')
|
CONF.import_opt('rootwrap_config', 'nova.config')
|
||||||
|
@ -905,9 +907,8 @@ def timefunc(func):
|
||||||
|
|
||||||
def generate_glance_url():
|
def generate_glance_url():
|
||||||
"""Generate the URL to glance."""
|
"""Generate the URL to glance."""
|
||||||
# TODO(jk0): This will eventually need to take SSL into consideration
|
return "%s://%s:%d" % (CONF.glance_protocol, CONF.glance_host,
|
||||||
# when supported in glance.
|
CONF.glance_port)
|
||||||
return "http://%s:%d" % (CONF.glance_host, CONF.glance_port)
|
|
||||||
|
|
||||||
|
|
||||||
def generate_image_url(image_ref):
|
def generate_image_url(image_ref):
|
||||||
|
|
Loading…
Reference in New Issue