Created
November 15, 2013 00:43
-
-
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...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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