Skip to content

Instantly share code, notes, and snippets.

@jamielennox
Created February 17, 2015 02:52
Show Gist options
  • Save jamielennox/4e22049c5bc57f4b68ec to your computer and use it in GitHub Desktop.
Save jamielennox/4e22049c5bc57f4b68ec to your computer and use it in GitHub Desktop.
Load an auth plugin and session from options on the command line.
import argparse
import sys
from keystoneclient import auth
from keystoneclient import session
parser = argparse.ArgumentParser('myapp')
auth.register_argparse_arguments(parser, sys.argv[1:])
session.Session.register_cli_options(parser)
args = parser.parse_args()
plugin = auth.load_from_argparse_arguments(args)
sess = session.Session.load_from_cli_options(args, auth=plugin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment