Skip to content

Instantly share code, notes, and snippets.

@ioggstream
Created May 3, 2017 19:01
Show Gist options
  • Save ioggstream/47bfda85d11c310b4c7b1aa0d466acb9 to your computer and use it in GitHub Desktop.
Save ioggstream/47bfda85d11c310b4c7b1aa0d466acb9 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
"""Get ips from nova hosts. Quick and dirty.
"""
from re import findall
from subprocess import check_output
from shlex import split
from json import dumps
def sh(cmd):
return check_output(split(cmd))
print(dumps(
dict(databases=
dict(hosts=
findall(r'\b(192.168.\d+.\d+)\b', sh('openstack server list --format=csv'))
)
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment