From 36c75d6c5e1e8fdf1fbdf969b176a15914adcf5e Mon Sep 17 00:00:00 2001 From: "szk.kentaro" Date: Wed, 15 Oct 2014 01:16:49 +0900 Subject: [PATCH] Add --pretty option for gce inventory plugin --- plugins/inventory/gce.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/inventory/gce.py b/plugins/inventory/gce.py index c8eeb43ab1b..c98e6b585b6 100755 --- a/plugins/inventory/gce.py +++ b/plugins/inventory/gce.py @@ -103,11 +103,13 @@ class GceInventory(object): # Just display data for specific host if self.args.host: print self.json_format_dict(self.node_to_dict( - self.get_instance(self.args.host))) + self.get_instance(self.args.host)), + pretty=self.args.pretty) sys.exit(0) # Otherwise, assume user wants all instances grouped - print(self.json_format_dict(self.group_instances())) + print(self.json_format_dict(self.group_instances(), + pretty=self.args.pretty)) sys.exit(0) def get_gce_driver(self): @@ -187,6 +189,8 @@ class GceInventory(object): help='List instances (default: True)') parser.add_argument('--host', action='store', help='Get all information about an instance') + parser.add_argument('--pretty', action='store_true', default=False, + help='Pretty format (default: False)') self.args = parser.parse_args()