code: def __init_keystone_session_v3(self, check=False):
          
          try:
              # may fail on Python 2.6?
              from keystoneauth1.identity import v3 as keystone_v3
          except ImportError:
              log.warning("Cannot load Keystone API v3 library.")
              return None
          auth = keystone_v3.Password(
              auth_url=self._os_auth_url,
              username=self._os_username,
              password=self._os_password,
              user_domain_name=self._os_user_domain_name,
              project_domain_name=self._os_project_domain_name,
              project_name=self._os_tenant_name,
          )
          sess = keystoneauth1.session.Session(auth=auth, verify=self._os_cacert)
          if check:
              log.debug("Checking that Keystone API v3 session works...")
              try:
                  # if session is invalid, the following will raise some exception
                  nova = nova_client.Client(self._compute_api_version, session=sess)
                  nova.flavors.list()
              except keystoneauth1.exceptions.NotFound as err:
                  log.warning("Creating Keystone v3 session failed: %s", err)
                  return None
              except keystoneauth1.exceptions.ClientException as err:
                  log.error("OpenStack server rejected request (likely configuration error?): %s", err)
                  return None  # FIXME: should we be raising an error instead?
          # if we got to this point, v3 session is valid
          log.info("Using Keystone API v3 session to authenticate to OpenStack")
          return sess
docs: Return a new session object, created using Keystone API v3.
  
          .. note::
  
            Note that the only supported authN method is password authentication;
            token or other plug-ins are not currently supported.