code: def __init_keystone_session_v2(self, check=False):
          
          from keystoneauth1 import loading as keystone_v2
          loader = keystone_v2.get_plugin_loader('password')
          auth = loader.load_from_options(
              auth_url=self._os_auth_url,
              username=self._os_username,
              password=self._os_password,
              project_name=self._os_tenant_name,
          )
          sess = keystoneauth1.session.Session(auth=auth, verify=self._os_cacert)
          if check:
              log.debug("Checking that Keystone API v2 session works...")
              try:
                  # if session is invalid, the following will raise some exception
                  nova = nova_client.Client(self._compute_api_version, session=sess, cacert=self._os_cacert)
                  nova.flavors.list()
              except keystoneauth1.exceptions.NotFound as err:
                  log.warning("Creating Keystone v2 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, v2 session is valid
          log.info("Using Keystone API v2 session to authenticate to OpenStack")
          return sess
docs: Create and return a session object using Keystone API v2.