Skip to content

Instantly share code, notes, and snippets.

@deeso
Created August 29, 2015 01:22
Show Gist options
  • Save deeso/465e4fec4cab4c65d7a3 to your computer and use it in GitHub Desktop.
Save deeso/465e4fec4cab4c65d7a3 to your computer and use it in GitHub Desktop.
simple script to build clones of a standard machine
new_host = 'python-workx64-{:02d}'
new_mac = '52:55:00:00:00:{:02d}'
file_fmt = "python-workx64-{:02d}.xml"
new_uuid = "<uuid>{}</uuid>"
mac_target = '52:55:00:00:00:7f'
file_replacement = "python-workx64-replaceme"
uuid_replacement = "<uuid>e048e39c-270d-1219-dba5-303b127d443e</uuid>"
data = open(file_replacement+'.xml').read()
for i in xrange(0, 20):
new_data = data.replace('replaceme', '%02d'%i)
new_data = new_data.replace(mac_target, new_mac.format(i))
new_data = new_data.replace(uuid_replacement, new_uuid.format(uuid.uuid1()))
open(file_fmt.format(i), 'w').write(new_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment