def __init__(self, client=None): self._client = client or GlanceClientWrapper() # NOTE(jbresnah) build the table of download handlers at the beginning # so that operators can catch errors at load time rather than whenever # a user attempts to use a module. Note this cannot be done in glance # space when this python module is loaded because the download module # may require configuration options to be parsed. self._download_handlers = {} download_modules = image_xfers.load_transfer_modules() for scheme, mod in download_modules.iteritems(): if scheme not in CONF.allowed_direct_url_schemes: continue try: self._download_handlers[scheme] = mod.get_download_handler() except Exception as ex: fmt = _("When loading the module %(module_str)s the " "following error occurred: %(ex)s") LOG.error(fmt % {"module_str": str(mod), "ex": ex})
def __init__(self, client=None): self._client = client or GlanceClientWrapper() #NOTE(jbresnah) build the table of download handlers at the beginning # so that operators can catch errors at load time rather than whenever # a user attempts to use a module. Note this cannot be done in glance # space when this python module is loaded because the download module # may require configuration options to be parsed. self._download_handlers = {} download_modules = image_xfers.load_transfer_modules() for scheme, mod in download_modules.iteritems(): if scheme not in CONF.allowed_direct_url_schemes: continue try: self._download_handlers[scheme] = mod.get_download_handler() except Exception as ex: fmt = _('When loading the module %(module_str)s the ' 'following error occurred: %(ex)s') LOG.error(fmt % {'module_str': str(mod), 'ex': ex})
default=0, help='Number retries when downloading an image from glance'), cfg.ListOpt('allowed_direct_url_schemes', default=[], help='A list of url scheme that can be downloaded directly ' 'via the direct_url. Currently supported schemes: ' '[file].'), ] 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.netconf') _DOWNLOAD_MODULES = image_xfers.load_transfer_modules() 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): """Parse an image href into composite parts.
default=0, help='Number retries when downloading an image from glance'), cfg.ListOpt('allowed_direct_url_schemes', default=[], help='A list of url scheme that can be downloaded directly ' 'via the direct_url. Currently supported schemes: ' '[file].'), ] 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.netconf') _DOWNLOAD_MODULES = image_xfers.load_transfer_modules() 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): """Parse an image href into composite parts.