PHP Howto use CloneMode

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
VBoxDeveloper
Posts: 1
Joined: 18. Jan 2018, 14:35

PHP Howto use CloneMode

Post by VBoxDeveloper »

I'm trying to clone a virtualmachine
The idea es a complete duplication (with new MAC's)

The machine is created as follows:

Code: Select all

$newMachine  = $this->virtualbox->createMachine(null, $cloneName, '/Clones', $originalMachine->OSTypeId, null);
$newMachine->saveSettings();
$this->virtualbox->registerMachine($newMachine);
$cm = new CloneMode();
$result = $originalMachine->CloneTo($newMachine, $cm->ValueMap['AllStates'], null);
The result is always the same:

Code: Select all

PHP Fatal error:  Uncaught SoapFault exception: [SOAP-ENV:Client] Validation constraint violation: invalid value in element 'mode' in vboxServiceWrappers.php:3465
Any hint for me?
Thanks in advance :)
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: PHP Howto use CloneMode

Post by noteirak »

As the error suggets, you didn't pass a valid clone mode. See the IMachine::cloneTo reference for order of arguments and their acceptable values.
Getting a new CloneMode instance seems wrong, I would think you need to use one of the properties of the static class instead.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply