
from keystoneclient import auth as ksauth
from keystoneclient import session as kssession

from oslo_config import cfg


CONF = cfg.CONF
CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token')


class KeystoneSession(object):
    def __init__(self):
        self._session = None
        self.region_name = CONF.auth_region

    @property
    def session(self):
        if not self._session:
            # Construct a Keystone session for configured auth_plugin
            # and credentials
            auth_plugin = ksauth.load_from_conf_options(
                cfg.CONF, 'keystone_authtoken')
            self._session = kssession.Session(auth=auth_plugin)
        return self._session


from keystoneclient import auth as ksauth
from keystoneclient import session as kssession

from oslo_config import cfg


CONF = cfg.CONF


class KeystoneSession(object):
    def __init__(self):
        self._session = None
        self.region_name = CONF.auth_region
        ksauth.register_conf_options(CONF, 'keystone_authtoken')

    @property
    def session(self):
        if not self._session:
            # Construct a Keystone session for configured auth_plugin
            # and credentials
            auth_plugin = ksauth.load_from_conf_options(
                cfg.CONF, 'keystone_authtoken')
            self._session = kssession.Session(auth=auth_plugin)
        return self._session

Use KSC auth's register_conf_options instead of oslo.cfg import
Use KSC auth's register_conf_options instead of oslo.cfg import

A newer keystoneclient is not happy with simply using oslo_config to
import the config group.  Instead, use register_conf_options()
from keystoneclient.auth.

Change-Id: I798dad7ad5bd90362e1fa10c2eecb3e1d5bade71

  
  from keystoneclient import auth as ksauth
  from keystoneclient import session as kssession
  
  from oslo_config import cfg
  
  
  CONF = cfg.CONF
- CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token')
  
  
  class KeystoneSession(object):
      def __init__(self):
          self._session = None
          self.region_name = CONF.auth_region
+         ksauth.register_conf_options(CONF, 'keystone_authtoken')
  
      @property
      def session(self):
          if not self._session:
              # Construct a Keystone session for configured auth_plugin
              # and credentials
              auth_plugin = ksauth.load_from_conf_options(
                  cfg.CONF, 'keystone_authtoken')
              self._session = kssession.Session(auth=auth_plugin)
          return self._session
  
Use KSC auth's register_conf_options instead of oslo.cfg import
## Code Before:

from keystoneclient import auth as ksauth
from keystoneclient import session as kssession

from oslo_config import cfg


CONF = cfg.CONF
CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token')


class KeystoneSession(object):
    def __init__(self):
        self._session = None
        self.region_name = CONF.auth_region

    @property
    def session(self):
        if not self._session:
            # Construct a Keystone session for configured auth_plugin
            # and credentials
            auth_plugin = ksauth.load_from_conf_options(
                cfg.CONF, 'keystone_authtoken')
            self._session = kssession.Session(auth=auth_plugin)
        return self._session

## Instruction:
Use KSC auth's register_conf_options instead of oslo.cfg import
## Code After:

from keystoneclient import auth as ksauth
from keystoneclient import session as kssession

from oslo_config import cfg


CONF = cfg.CONF


class KeystoneSession(object):
    def __init__(self):
        self._session = None
        self.region_name = CONF.auth_region
        ksauth.register_conf_options(CONF, 'keystone_authtoken')

    @property
    def session(self):
        if not self._session:
            # Construct a Keystone session for configured auth_plugin
            # and credentials
            auth_plugin = ksauth.load_from_conf_options(
                cfg.CONF, 'keystone_authtoken')
            self._session = kssession.Session(auth=auth_plugin)
        return self._session
