Created
September 3, 2015 17:39
-
-
Save trebortech/53b627e12421e1164684 to your computer and use it in GitHub Desktop.
vbox python script to clone vm
This file contains hidden or 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
def cloneVm(ctx, srcname, newname): | |
vbox = ctx['vb'] | |
clonemode = ctx['const'].all_values('CloneMode') | |
sourcevm = vbox.findMachine(srcname) | |
mach = vbox.createMachine("", newname, [], sourcevm.OSTypeId, "") | |
clone = sourcevm.cloneTo(mach, clonemode['MachineState'], "") | |
mach.saveSettings() | |
print "created clone of machine with UUID", mach.id | |
vbox.registerMachine(mach) | |
# update cache | |
getMachines(ctx, True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment