Skip to content

Instantly share code, notes, and snippets.

@lamw
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lamw/4a7182994200f74e890a to your computer and use it in GitHub Desktop.
Save lamw/4a7182994200f74e890a to your computer and use it in GitHub Desktop.
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