Skip to content

Instantly share code, notes, and snippets.

@clayrichardson
Created March 21, 2012 22:21
Show Gist options
  • Save clayrichardson/2153759 to your computer and use it in GitHub Desktop.
Save clayrichardson/2153759 to your computer and use it in GitHub Desktop.
Grab info from rs_tag
import json, commands, re
import pprint
machines = json.loads(commands.getstatusoutput('rs_tag -q "ip:internal"')[1])
internal_addresses = []
external_addresses = []
host_string = ''
for machine,tags in machines.items():
for tag in tags['tags']:
if re.match('ip:internal', tag):
ip = re.sub(r'^ip:internal=', '', tag)
internal_addresses.append(ip)
if re.match('ip:external', tag):
ip = re.sub(r'^ip:external=', '', tag)
external_addresses.append(ip)
for internal_address in internal_addresses:
host_string = host_string + "," + internal_address + ","
print host_string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment