From 7802db4862ebbf483ad3300d4635363a569a7583 Mon Sep 17 00:00:00 2001 From: Matt Bruzek Date: Mon, 20 Apr 2015 16:57:42 -0500 Subject: [PATCH] Added protetecion if the arguments are not there. --- cluster/juju/return-node-ips.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cluster/juju/return-node-ips.py b/cluster/juju/return-node-ips.py index a1fc703fb6a..c652ccd079d 100755 --- a/cluster/juju/return-node-ips.py +++ b/cluster/juju/return-node-ips.py @@ -1,7 +1,13 @@ #!/usr/bin/env python import json import sys -nodes = json.loads(sys.argv[1]) -for num in nodes: - print num['Stdout'].rstrip() +# 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: + print(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()