def __init__(self, config, section): kwargs = dict([(o, config.get(section, o)) for o in config.options(section)]) self.name = section self.keystone = KeystoneClient(**kwargs) glance_endpoint = self._get_endpoint('image') self.glance = GlanceV1Client(glance_endpoint['internalURL'], token=self.keystone.auth_token)
def __init__(self, id_service, os_username=None, os_tenant_name=None, os_password=None, os_auth_url=None, os_auth_token=None, interface=None, remote_user=None, id_service_auth_token=None, swift_auth_url=None, swift_tenant=None, swift_username=None, swift_password=None): ''' id_service is a full url of the id service to use. The remaining parameters are OpenStack Auth creds that are optional. VM IP Auth will be used if it applies''' self.id_service = id_service.strip("/") self.auth_token = os_auth_token self._username = os_username self._tenant_name = os_tenant_name self.interface = interface self.remote_user = remote_user self.os_auth_url = os_auth_url self._password = os_password self.swift_auth_url = swift_auth_url if swift_auth_url else os_auth_url self._swift_tenant = swift_tenant self._swift_username = swift_username self._swift_password = swift_password if os_username and os_tenant_name and os_password: if not os_auth_token: auth_client = KeystoneClient(username=os_username, tenant_name=os_tenant_name, password=os_password, auth_url=os_auth_url) self.auth_token = auth_client.auth_token self.headers = { "User-Agent": self.USER_AGENT, "content-type": "application/json" } if self.auth_token: self.headers["x-auth-token"] = self.auth_token self.headers["x-auth-user-name"] = self._username self.headers["x-auth-tenant-name"] = self.tenant_name if id_service_auth_token: self.headers["x-id-auth-token"] = id_service_auth_token
def __init_auth__(self, username, password, tenant_id, auth_url): """ Init the variables related to authorization, needed to execute tests. :param username (string): Keystone Username :param password (string): Password :param tenant_id (string): Tenant ID :param auth_url (string): Auth URL :return: The auth token retrieved """ __logger__.debug("Init auth") self.keystone_client = \ KeystoneClient(username=username, password=password, tenant_id=tenant_id, auth_url=auth_url) if self.keystone_client is None: __logger__.debug("Authentication error.") return None else: token = self.keystone_client.auth_ref['token']['id'] __logger__.debug("Auth token: '%s'", token) return token
def __init__(self): ks_args = SysUtil.get_credentials() self.ksclient = KeystoneClient(**ks_args)
def keystone(self): if not self._keystone_client: self._keystone_client = KeystoneClient(**self.credentials) self.credentials.update( {'token': self._keystone_client.auth_token}) return self._keystone_client
def get_keystone(config, section): kwargs = dict([(o, config.get(section, o)) for o in config.options(section)]) return KeystoneClient(**kwargs)
from flask import Flask from flask import request from middleman.config import load_middleman_config from middleman.log import get_logger, get_log_manager from middleman.util.request import http_request import uwsgi _CONFIG = load_middleman_config() _LOGGING_MANAGER = get_log_manager() _LOGGING_MANAGER.configure(_CONFIG) _LOG = get_logger(__name__) _KEYSTONE_CLIENT = KeystoneClient(token=_CONFIG.keystone.auth_token, timeout=_CONFIG.keystone.timeout, endpoint=_CONFIG.keystone.endpoint, insecure=_CONFIG.keystone.insecure) X_AUTH_TOKEN = 'X-Auth-Token' X_TENANT_NAME = 'X-Tenant-Name' application = Flask(__name__) def _cached_token_exists(token): if uwsgi.cache_get(token, _CONFIG.cache.cache_name) is not None: return True return False def _token_is_valid(token, tenant_name):
def __init__(self): self.ks_args = util.get_credentials() self.ksclient = KeystoneClient(**self.ks_args)