diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2015-03-02 17:05:35 -0600 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2015-04-18 23:04:51 -0500 |
| commit | 5649695c658505b0217fb6d03cf199797b90ca4c (patch) | |
| tree | 277dc72a93e7fa4c557a1dbe0d4d021d69e94c5d /examples/osc-lib.py | |
| parent | a5e79d58ae508e218a113bfa3976fae369980688 (diff) | |
| download | python-openstackclient-5649695c658505b0217fb6d03cf199797b90ca4c.tar.gz | |
Add --os-cloud support
This adds a new option --os-cloud that allows the configuration values
for multiple clouds to be stored in a local file and selected with
a single option.
Internal option names have had 'os_' removed to be comptible with
the options returned from OpenStackConfig().get_one_cloud().
The config file is ~/.config/openstack/clouds.yaml:
Sample
------
clouds:
devstack:
auth:
auth_url: http://192.168.122.10:35357/
project_name: demo
username: demo
password: 0penstack
region_name: RegionOne
devstack:
auth:
auth_url: http://192.168.122.10:35357/
project_name: demo
username: demo
password: 0penstack
region_name: RegionOne
Co-Authored-By: Monty Taylor <mordred@inaugust.com>
Change-Id: I4939acf8067e44ffe06a2e26fc28f1adf8985b7d
Depends-On: I45e2550af58aee616ca168d20a557077beeab007
Diffstat (limited to 'examples/osc-lib.py')
| -rwxr-xr-x | examples/osc-lib.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/examples/osc-lib.py b/examples/osc-lib.py index 2960a2f7..84501903 100755 --- a/examples/osc-lib.py +++ b/examples/osc-lib.py @@ -29,6 +29,8 @@ import common from openstackclient.common import clientmanager +from os_client_config import config as cloud_config + LOG = logging.getLogger('') @@ -36,6 +38,16 @@ LOG = logging.getLogger('') def run(opts): """Run the examples""" + # Do configuration file handling + cc = cloud_config.OpenStackConfig() + LOG.debug("defaults: %s", cc.defaults) + + cloud = cc.get_one_cloud( + cloud=opts.cloud, + argparse=opts, + ) + LOG.debug("cloud cfg: %s", cloud.config) + # Loop through extensions to get API versions # Currently API versions are statically selected. Once discovery # is working this can go away... @@ -59,7 +71,7 @@ def run(opts): # Collect the auth and config options together and give them to # ClientManager and it will wrangle all of the goons into place. client_manager = clientmanager.ClientManager( - cli_options=opts, + cli_options=cloud, verify=verify, api_version=api_version, ) |
