From dbca4bf5dd95256cfc16b3dffc2cbd25fc428ab2 Mon Sep 17 00:00:00 2001 From: Matt Bruzek Date: Wed, 22 Apr 2015 11:36:37 -0500 Subject: [PATCH] Using python to parse the json output from Juju. --- cluster/juju/return-node-ips.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 cluster/juju/return-node-ips.py diff --git a/cluster/juju/return-node-ips.py b/cluster/juju/return-node-ips.py new file mode 100755 index 00000000000..a8848f019a6 --- /dev/null +++ b/cluster/juju/return-node-ips.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +import json +import sys +# This script helps parse out the private IP addreses from the +# `juju run` command's JSON object, see cluster/juju/util.sh + +if len(sys.argv) > 1: + # It takes the JSON output as the first argument. + nodes = json.loads(sys.argv[1]) + # There can be multiple nodes to print the Stdout. + for num in nodes: + print num['Stdout'].rstrip() +else: + exit(1)