Example #1
0
    def _get_auth_plugin(self):
        # NOTE(jamielennox): Ideally this would use get_from_conf_options
        # however that is not possible because we have to support the override
        # pattern we use in _conf_get. There is a somewhat replacement for this
        # in keystoneclient in load_from_options_getter which should be used
        # when available. Until then this is essentially a copy and paste of
        # the ksc load_from_conf_options code because we need to get a fix out
        # for this quickly.

        # FIXME(jamielennox): update to use load_from_options_getter when
        # https://review.openstack.org/162529 merges.

        # !!! - UNDER NO CIRCUMSTANCES COPY ANY OF THIS CODE - !!!

        group = self._conf_get('auth_section') or _base.AUTHTOKEN_GROUP

        # NOTE(jamielennox): auth_plugin was deprecated to auth_type. _conf_get
        # doesn't handle that deprecation in the case of conf dict options so
        # we have to manually check the value
        plugin_name = (self._conf_get('auth_type', group=group)
                       or self._conf.get('auth_plugin'))

        if not plugin_name:
            return _auth.AuthTokenPlugin(
                log=self.log,
                auth_admin_prefix=self._conf_get('auth_admin_prefix',
                                                 group=group),
                auth_host=self._conf_get('auth_host', group=group),
                auth_port=self._conf_get('auth_port', group=group),
                auth_protocol=self._conf_get('auth_protocol', group=group),
                identity_uri=self._conf_get('identity_uri', group=group),
                admin_token=self._conf_get('admin_token', group=group),
                admin_user=self._conf_get('admin_user', group=group),
                admin_password=self._conf_get('admin_password', group=group),
                admin_tenant_name=self._conf_get('admin_tenant_name',
                                                 group=group)
            )

        plugin_loader = loading.get_plugin_loader(plugin_name)
        plugin_opts = [o._to_oslo_opt() for o in plugin_loader.get_options()]
        plugin_kwargs = dict()

        (self._local_oslo_config or CONF).register_opts(plugin_opts,
                                                        group=group)

        for opt in plugin_opts:
            val = self._conf_get(opt.dest, group=group)
            if val is not None:
                val = opt.type(val)
            plugin_kwargs[opt.dest] = val

        return plugin_loader.load_from_options(**plugin_kwargs)
Example #2
0
    def new_plugin(self, auth_host=None, auth_port=None, auth_protocol=None,
                   auth_admin_prefix=None, admin_user=None,
                   admin_password=None, admin_tenant_name=None,
                   admin_token=None, identity_uri=None, log=None):
        if not log:
            log = self.logger

        return _auth.AuthTokenPlugin(
            auth_host=auth_host,
            auth_port=auth_port,
            auth_protocol=auth_protocol,
            auth_admin_prefix=auth_admin_prefix,
            admin_user=admin_user,
            admin_password=admin_password,
            admin_tenant_name=admin_tenant_name,
            admin_token=admin_token,
            identity_uri=identity_uri,
            log=log)
Example #3
0
    def _get_auth_plugin(self):
        # NOTE(jamielennox): Ideally this would use load_from_conf_options
        # however that is not possible because we have to support the override
        # pattern we use in _conf_get. This function therefore does a manual
        # version of load_from_conf_options with the fallback plugin inline.

        group = self._conf_get('auth_section') or _base.AUTHTOKEN_GROUP

        # NOTE(jamielennox): auth_plugin was deprecated to auth_type. _conf_get
        # doesn't handle that deprecation in the case of conf dict options so
        # we have to manually check the value
        plugin_name = (self._conf_get('auth_type', group=group)
                       or self._conf.get('auth_plugin'))

        if not plugin_name:
            return _auth.AuthTokenPlugin(
                log=self.log,
                auth_admin_prefix=self._conf_get('auth_admin_prefix',
                                                 group=group),
                auth_host=self._conf_get('auth_host', group=group),
                auth_port=self._conf_get('auth_port', group=group),
                auth_protocol=self._conf_get('auth_protocol', group=group),
                identity_uri=self._conf_get('identity_uri', group=group),
                admin_token=self._conf_get('admin_token', group=group),
                admin_user=self._conf_get('admin_user', group=group),
                admin_password=self._conf_get('admin_password', group=group),
                admin_tenant_name=self._conf_get('admin_tenant_name',
                                                 group=group))

        # Plugin option registration is normally done as part of the load_from
        # function rather than the register function so copy here.
        plugin_loader = loading.get_plugin_loader(plugin_name)
        plugin_opts = loading.get_auth_plugin_conf_options(plugin_loader)

        (self._local_oslo_config or CONF).register_opts(plugin_opts,
                                                        group=group)

        getter = lambda opt: self._conf_get(opt.dest, group=group)
        return plugin_loader.load_from_options_getter(getter)