Skip to content

Instantly share code, notes, and snippets.

@trebortech
Created September 3, 2015 17:39
Show Gist options
  • Save trebortech/53b627e12421e1164684 to your computer and use it in GitHub Desktop.
Save trebortech/53b627e12421e1164684 to your computer and use it in GitHub Desktop.
vbox python script to clone vm
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