Skip to content

Instantly share code, notes, and snippets.

@iRedds
Created July 2, 2018 10:21
Show Gist options
  • Save iRedds/2c9865f7cb43bc286b8a72fb9cfe7d3c to your computer and use it in GitHub Desktop.
Save iRedds/2c9865f7cb43bc286b8a72fb9cfe7d3c to your computer and use it in GitHub Desktop.
import json
import sys
obj = json.loads(sys.stdin.read())
for row in obj["result"]:
ip = []
for ifs in row["interfaces"]:
ip.append("[id:{0},ip:{1}]".format(ifs["interfaceid"], ifs["ip"]))
print ("hostid : {0}, host : {1}, interfaces : {2}".format(row["hostid"], row["host"], ', '.join([str(x) for x in ip])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment