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
This commit is contained in:
@@ -22,6 +22,7 @@ the system.
|
|||||||
import nova.context
|
import nova.context
|
||||||
from nova import db
|
from nova import db
|
||||||
from nova import exception
|
from nova import exception
|
||||||
|
from nova.image import glance
|
||||||
from nova import network
|
from nova import network
|
||||||
from nova.network import model as network_model
|
from nova.network import model as network_model
|
||||||
from nova.openstack.common import cfg
|
from nova.openstack.common import cfg
|
||||||
@@ -277,7 +278,7 @@ def info_from_instance(context, instance_ref, network_info,
|
|||||||
def null_safe_str(s):
|
def null_safe_str(s):
|
||||||
return str(s) if s else ''
|
return str(s) if s else ''
|
||||||
|
|
||||||
image_ref_url = utils.generate_image_url(instance_ref['image_ref'])
|
image_ref_url = glance.generate_image_url(instance_ref['image_ref'])
|
||||||
|
|
||||||
instance_type_name = instance_ref.get('instance_type', {}).get('name', '')
|
instance_type_name = instance_ref.get('instance_type', {}).get('name', '')
|
||||||
|
|
||||||
|
|||||||
@@ -80,9 +80,6 @@ utils_opts = [
|
|||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
CONF.register_opts(monkey_patch_opts)
|
CONF.register_opts(monkey_patch_opts)
|
||||||
CONF.register_opts(utils_opts)
|
CONF.register_opts(utils_opts)
|
||||||
CONF.import_opt('glance_host', 'nova.config')
|
|
||||||
CONF.import_opt('glance_port', 'nova.config')
|
|
||||||
CONF.import_opt('glance_protocol', 'nova.config')
|
|
||||||
CONF.import_opt('service_down_time', 'nova.config')
|
CONF.import_opt('service_down_time', 'nova.config')
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@@ -975,17 +972,6 @@ def timefunc(func):
|
|||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def remove_path_on_error(path):
|
def remove_path_on_error(path):
|
||||||
"""Protect code that wants to operate on PATH atomically.
|
"""Protect code that wants to operate on PATH atomically.
|
||||||
|
|||||||
Reference in New Issue
Block a user