From 16e351699dd572e5318505ed32aed6e38ce09a51 Mon Sep 17 00:00:00 2001 From: Sergey Lukjanov Date: Mon, 1 Apr 2013 21:52:03 +0400 Subject: [PATCH] get_auth_token is now uses default configs Change-Id: Iacec4f96e40d7ebb49b8939338564de88bd6372b --- bin/savanna-api | 2 +- tools/get_auth_token.py | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/bin/savanna-api b/bin/savanna-api index c9053d1972..ccde32cdd1 100755 --- a/bin/savanna-api +++ b/bin/savanna-api @@ -23,7 +23,7 @@ import sys # If ../savanna/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... -possible_topdir = os.path.normpath(os.path.join(os.path.abspath(__file__), +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)) if os.path.exists(os.path.join(possible_topdir, diff --git a/tools/get_auth_token.py b/tools/get_auth_token.py index d1fe7df712..714f91bbb3 100644 --- a/tools/get_auth_token.py +++ b/tools/get_auth_token.py @@ -1,8 +1,17 @@ from keystoneclient.v2_0 import Client as keystone_client +import os from oslo.config import cfg - import sys + +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, + 'savanna', + '__init__.py')): + sys.path.insert(0, possible_topdir) + cli_opts = [ cfg.StrOpt('username', default='', help='set username'), @@ -20,7 +29,16 @@ CONF.register_cli_opts(cli_opts) def main(): - CONF(sys.argv[1:], project='get_auth_token') + dev_conf = os.path.join(possible_topdir, + 'etc', + 'savanna', + 'savanna.conf') + config_files = None + if os.path.exists(dev_conf): + config_files = [dev_conf] + + CONF(sys.argv[1:], project='get_auth_token', + default_config_files=config_files) user = CONF.username or CONF.os_admin_username password = CONF.password or CONF.os_admin_password