Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Having some fun with VSAN HCL JSON
#!/usr/bin/env python
# William Lam
# www.virtuallyghetto.com
import json
import urllib2
# download json
response = urllib2.urlopen('http://partnerweb.vmware.com/service/vsan/all.json')
#load json
all_data = json.load(response)
controllers = {}
total = 0
for i in sorted(all_data['data']['controller']):
vendor = i['vendor']
if vendor not in controllers.keys():
controllers[vendor] = 1
else:
controllers[vendor] += 1
total += 1
print "Total VSAN Controllers: " + str(total)
for key,value in controllers.items():
#print str(key) + "," + str(value)
per = format((1.0 * value / total) * 100,'.2f')
print str(key) + "," + str(per)
print
hdd = {}
total = 0
for i in sorted(all_data['data']['hdd']):
vendor = i['vendor']
if vendor not in hdd.keys():
hdd[vendor] = 1
else:
hdd[vendor] += 1
total += 1
print "Total VSAN HDD: " + str(total)
for key,value in hdd.items():
#print str(key) + "," + str(value)
per = format((1.0 * value / total) * 100,'.2f')
print str(key) + "," + str(per)
print
ssd = {}
total = 0
for i in sorted(all_data['data']['ssd']):
vendor = i['vendor']
if vendor not in ssd.keys():
ssd[vendor] = 1
else:
ssd[vendor] += 1
total += 1
print "Total VSAN SSD: " + str(total)
for key,value in ssd.items():
#print str(key) + "," + str(value)
per = format((1.0 * value / total) * 100,'.2f')
print str(key) + "," + str(per)
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.