diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2013-01-07 22:06:49 +0000 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2013-01-08 10:23:40 +0000 |
| commit | 2bcca3959209707e5604948ceb70d039671ae002 (patch) | |
| tree | f1d3df4e8a24333251808c1fdd11f4865ba4273a /nova/image | |
| parent | 942b3ed874f045c892ad497ffadfdd80cb63bf9e (diff) | |
| download | nova-2bcca3959209707e5604948ceb70d039671ae002.tar.gz nova-2bcca3959209707e5604948ceb70d039671ae002.tar.xz nova-2bcca3959209707e5604948ceb70d039671ae002.zip | |
Move global glance opts into nova.image.glance
Move the glance_host, glance_port and glance_protocol options into the
nova.image.glance module.
Also move the generate_glance_url() and generate_image_url() utility
methods there since they're the only uses of the options outside of the
module.
blueprint: scope-config-opts
Change-Id: I3beca1a65cdd902a94ddc1c512d79a4de635ef38
Diffstat (limited to 'nova/image')
| -rw-r--r-- | nova/image/glance.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/nova/image/glance.py b/nova/image/glance.py index 9a93df2ab..6a5406d9e 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -36,6 +36,16 @@ from nova.openstack.common import log as logging from nova.openstack.common import timeutils glance_opts = [ + cfg.StrOpt('glance_host', + default='$my_ip', + help='default glance hostname or ip'), + cfg.IntOpt('glance_port', + default=9292, + 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', default=['$glance_host:$glance_port'], help='A list of the glance api servers available to nova. ' @@ -54,6 +64,18 @@ LOG = logging.getLogger(__name__) CONF = cfg.CONF CONF.register_opts(glance_opts) CONF.import_opt('auth_strategy', 'nova.api.auth') +CONF.import_opt('my_ip', 'nova.config') + + +def generate_glance_url(): + """Generate the URL to glance.""" + return "%s://%s:%d" % (CONF.glance_protocol, CONF.glance_host, + CONF.glance_port) + + +def generate_image_url(image_ref): + """Generate an image URL from an image_ref.""" + return "%s/images/%s" % (generate_glance_url(), image_ref) def _parse_image_ref(image_href): |
