Skip to content

Instantly share code, notes, and snippets.

@craigcalef
Created November 15, 2013 00:43
Show Gist options
  • Save craigcalef/7477201 to your computer and use it in GitHub Desktop.
Save craigcalef/7477201 to your computer and use it in GitHub Desktop.
Rackspace gave me a 'dump' from VMware of all my VMs, so I made a crappy little python script to parse it into something more usable...
import pprint
import re
pattern = r'.*(\d*) GB \[(.*)\]'
example = '______|Virtual Disk: 25 GB [421451-san-fc-hlu00]'
vmd = [l.strip() for l in open("vmmap.txt", "r").readlines()]
vmm = {}
latch = False
for l in vmd:
if l == "":
latch = False
else:
if latch == False:
latch = l
else:
if latch in vmm:
vmm[latch].append(re.match(pattern, l).groups())
else:
vmm[latch] = [re.match(pattern, l).groups()]
#pprint.pprint(vmm)
for vmname,parts in vmm.items():
for part in parts:
print "%s,%s,%s" % (vmname, part[1], part[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment