diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-05-27 14:52:13 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-05-27 14:52:13 -0400 |
commit | a9533cd924e8eae89234a19d8359a87c23a30e12 (patch) | |
tree | 964e1d39334ab79f77f7dd435ff56a596cd559f9 | |
parent | 71e4da45263e6cb3eb5d5938908656ed04c3db9f (diff) | |
download | vyos-cloud-init-a9533cd924e8eae89234a19d8359a87c23a30e12.tar.gz vyos-cloud-init-a9533cd924e8eae89234a19d8359a87c23a30e12.zip |
add nicer main
-rw-r--r-- | cloudinit/sources/DataSourceSmartOS.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/cloudinit/sources/DataSourceSmartOS.py b/cloudinit/sources/DataSourceSmartOS.py index 9c249ddf..3d7297c9 100644 --- a/cloudinit/sources/DataSourceSmartOS.py +++ b/cloudinit/sources/DataSourceSmartOS.py @@ -755,4 +755,23 @@ def get_datasource_list(depends): if __name__ == "__main__": import sys jmc = jmc_client_factory() - jmc.get(sys.argv[1]) + if len(sys.argv) == 1: + keys = (list(SMARTOS_ATTRIB_JSON.keys()) + + list(SMARTOS_ATTRIB_MAP.keys())) + else: + keys = sys.argv[1:] + + data = {} + for key in keys: + if key in SMARTOS_ATTRIB_JSON: + keyname = SMARTOS_ATTRIB_JSON[key] + data[key] = jmc.get_json(keyname) + else: + if key in SMARTOS_ATTRIB_MAP: + keyname, strip = SMARTOS_ATTRIB_MAP[key] + else: + keyname, strip = (key, False) + val = jmc.get(keyname, strip=strip) + data[key] = jmc.get(keyname, strip=strip) + + print(json.dumps(data, indent=1)) |