I am new to programming the VBox API, so apologies if this is a newbie question. I am writing in Python and using VBox 5.0. I am attempting to create a new machine cloned from another. The new machine needs to be created in a new machine group. When I execute the createMachine() API, I can save the settings and see that the group is there. However, after I cloneTo() the group setting is gone. I'm not sure if I'm calling things wrong, but here is the code:
Code: Select all
def create(self, groups=None, progress=None):
if self.exists:
return False
filename = self._VBOX.composeMachineFilename(
self.name, groups[0], None, None)
# create the new vm vbox vm
self.vbox_vmi = self._VBOX.createMachine(
filename, self.name,
groups, 'Other', '')
# clone the 'cvx-base' VM
cvx_base = self._CATALOG['clone-this-vm'] # _CATALOG is just a dictionary of existing VMs
cloning = cvx_base.cloneTo(
self.vbox_vmi,
self._ENUMS.CloneMode_MachineState, None)
if not progress:
cloning.waitForCompletion(-1)
else:
# TODO: should put in a failsafe for exceeding timeout
while not cloning.completed:
progress(self.name, cloning.percent, cloning.completed)
cloning.waitForCompletion(1000)
# one more for done
progress(self.name, cloning.percent, cloning.completed)
self.__class__._catalog_register(self)
return True
Really appreciate anyone's guidance.
Thank you!
-- Jeremy