diff options
author | Monty Taylor <mordred@inaugust.com> | 2015-12-30 09:46:21 -0600 |
---|---|---|
committer | Monty Taylor <mordred@inaugust.com> | 2015-12-30 09:46:21 -0600 |
commit | 7ee7156254381dc5c06405105c7de42c180c779f (patch) | |
tree | 0c646a1e8b5b44d4031eaad83a9d0cd9a8c2d4b3 | |
parent | 939862e55e42c5fafee9c2fec42b5f5fde8fc205 (diff) | |
download | os-client-config-7ee7156254381dc5c06405105c7de42c180c779f.tar.gz |
Allow filtering clouds on command line
Add a very basic filtering to the test command line function to allow
only printing one cloud or one cloud/region worth of config.
Change-Id: I0d09717430f41b4229f7743f8531f871b962969e
-rw-r--r-- | os_client_config/config.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py index 077c109..b970728 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -19,6 +19,7 @@ import collections import copy import json import os +import sys import warnings import appdirs @@ -976,4 +977,15 @@ class OpenStackConfig(object): if __name__ == '__main__': config = OpenStackConfig().get_all_clouds() for cloud in config: - print(cloud.name, cloud.region, cloud.config) + print_cloud = False + if len(sys.argv) == 1: + print_cloud = True + elif len(sys.argv) == 3 and ( + sys.argv[1] == cloud.name and sys.argv[2] == cloud.region): + print_cloud = True + elif len(sys.argv) == 2 and ( + sys.argv[1] == cloud.name): + print_cloud = True + + if print_cloud: + print(cloud.name, cloud.region, cloud.config) |