Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from keystoneclient.auth.identity import v3
- from keystoneclient import session
- from keystoneclient.v3 import client
- from os import environ
- from subprocess import Popen, PIPE, call, check_output, check_call
- #interactive-fu
- import rlcompleter, readline
- readline.parse_and_bind('tab: complete')
- debug=True
- os_auth_file='/etc/openrcV3' #where to find authentication bits
- def source(script, update=True, clean=True):
- """
- Source variables from a shell script
- import them in the environment (if update==True)
- and report only the script variables (if clean==True)
- """
- global environ
- if clean:
- environ_back = dict(environ)
- environ.clear()
- pipe = Popen(". %s; env" % script, stdout=PIPE, shell=True)
- data = pipe.communicate()[0]
- env = dict((line.split("=", 1) for line in data.splitlines()))
- if clean:
- # remove unwanted minimal vars
- env.pop('LINES', None)
- env.pop('COLUMNS', None)
- environ = dict(environ_back)
- if update:
- environ.update(env)
- return env
- os_auth = source(os_auth_file)
- auth = v3.Password(auth_url=os_auth['OS_AUTH_URL'],
- username=os_auth['OS_USERNAME'],
- password=os_auth['OS_PASSWORD'],
- project_domain_name='default',user_domain_name='default',
- project_name=os_auth['OS_TENANT_NAME'])
- sess = session.Session(auth=auth)
- keystone = client.Client(session=sess)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement