Comments (18)
Is that the exact code you are running? Where does the "error is - " line come from? It would be good to print_r the array you are giving to CloneVM_Task so we can see exactly what is being sent.
from vmwarephp.
Oh, the "error is - " is coming from your debugging output in Service.php. You should echo something in between each line, maybe it's not even making it to the CloneVM_Task call.
from vmwarephp.
Thank you for a prompt reply.
Yes, it's my debugging code and I should have added at least the "\n" there..
Here is my debugging code : It in the catch block, so it happens after the error :
diff --git a/library/Vmwarephp/Service.php b/library/Vmwarephp/Service.php
index 52030ed..527e5e4 100644
--- a/library/Vmwarephp/Service.php
+++ b/library/Vmwarephp/Service.php
@@ -71,6 +71,9 @@ class Service {
$result = $this->soapClient->$method($soapMessage);
} catch (\SoapFault $soapFault) {
$this->soapClient->_classmap = null;
+ echo 'error is - ' ;
+ print_r($method);
+ print_r($soapMessage);
throw new \Vmwarephp\Exception\Soap($soapFault);
}
$this->soapClient->_classmap = null;
from vmwarephp.
I tried to do the print_r of the arguments array passed to the CloneVM_Task, but as the $vm->parent object has a lot of recursions it's likely worthless to include it here. Is there a working example with CloneVM_Task function ? may be someone is already using it in live systems?
from vmwarephp.
I use it all the time, which is why I was thinking it may be failing before it gets to that call. Looks like your clone spec is good. Are you positive it's making it to the CloneVM_Task call? Can you echo something in between each line of your code so it's easy to see where the error is thrown?
It looks like it's failing when it tries to retrieve the name
property of a folder with the ID ha-folder-vm
.
from vmwarephp.
Ok, If the code looks ok, then may be it's the esx host issue.. I have version 5.1.0 799733..
I also tried to use CreateVM_Task and got similar error. Can you paste me a working script for creating or cloning VM? I'd test it on my host and confirmed if problem is on the host or in the code..
The CloneVM_Task is definitely run, I updated the code like this :
$vhost = new \Vmwarephp\Vhost('*****','*****','*****');
$vm = $vhost->findManagedObjectByName("VirtualMachine", "test1", array());
echo "vms is : $vm->name\n";
$cfs = new VirtualMachineCloneSpec();
$cfs->powerOn=FALSE;
$cfs->template=FALSE;
$cfs->snapshot=$vm->snapshot->currentSnapshot;
$cfs->location =new VirtualMachineRelocateSpec();
$cfs->location->diskMoveType='createNewChildDiskBacking';
$args =array('folder' => $vm->parent, 'name' => $vm->name .'-clone', 'spec' => $cfs);
echo " running clone : \n";
$ret = $vm->CloneVM_Task($args);
Got output like this :
vms is : test1
running clone :
method : RetrieveProperties
error is : Array
(
[_this] => ManagedObjectReference Object
(
[_] => ha-property-collector
[type] => PropertyCollector
)
[specSet] => PropertyFilterSpec Object
...
the debug output is more readable now :)
from vmwarephp.
Try putting it in a different folder than $vm->parent
.
Also, side note, if the VM doesn't have any snapshots then $vm->snapshot
will be null
and you will get an error trying to do $vm->snapshot->currentSnapshot
.
from vmwarephp.
I'm using this host in standalone mode, so I can't create any other Folders in the hierarchy.
Thanks for the tip with snapshots, I pre-created a snapshot to avoid any errors like this :)
Is it worth to migrate to vsphere hypervisor 5.5 ? Would vmwarephp support it ?
In the readme it's said that it supports up to 5.1, but not a word about 5.5...
from vmwarephp.
I only have experience with 5.1.
No idea what's going on with this! Can you print_r that array you're passing to CloneVM_Task again, put it all in a gist and link it here?
from vmwarephp.
I think I found why it doesn't work in my config. It seems Clone operation is working only trough the vCenter server.
"You must be connected to vCenter Server in order to clone a virtual machine. You cannot clone virtual machines if you connect directly to an ESXi host. "
Are you running ESX in standalone mode without vCenter ?
from vmwarephp.
Here is a gist I've created dumping the arguments to CloneVM_Task :
https://gist.github.com/anikushkin/3c07155ce64f118e961f
from vmwarephp.
I don't know exactly what my setup is, somebody else manages it. I don't see any issues with your CloneVM_Task array, so your setup may be the issue.
from vmwarephp.
If you can create the Folders in the tree, then it's definitely trough the vCenter, I already tried to create a sub-folder and received clear error message about that.
It's really strange that I have the same error in CreateVM_Task, which should work on 100%. Will keep trying to hack it :)
from vmwarephp.
Yeah, I create folders, in fact I wrote the Folder ManagedObject Extension class :)
from vmwarephp.
I'm hacking with perl SDK now - their vmcreate.pl and vmclone.pl are working fine on my host. I assume it's something missing in my code, as the way it's done in perl contains much more operations and much more data passed via SOAP. If I'll manage to make it work, I'll paste working code here.
I think this issue is not a bug, may be just a lack of documentation in vmware SDK. Most likely it's just differencies in vCenter and standalone modes
from vmwarephp.
finally, I found the root cause of the problem.
- Clone is not supported on standalone ESX hosts
- we need to pass REFERENCES to the objects, instead of the objects themselves;
here is my final code and result confirming it :
$vhost = new \Vmwarephp\Vhost('*****','*****','*****');
$vm = $vhost->findManagedObjectByName("VirtualMachine", "test1", array('parent', 'name'));
echo "vms is : $vm->name\n";
$cfs = new VirtualMachineCloneSpec();
$cfs->powerOn=FALSE;
$cfs->template=FALSE;
$cfs->snapshot=$vm->snapshot->currentSnapshot->reference;
$cfs->location =new VirtualMachineRelocateSpec();
$cfs->location->diskMoveType='createNewChildDiskBacking';
$args =array('folder' => $vm->parent->reference, 'name' => $vm->name .'-clone', 'spec' => $cfs);
echo " running clone : \n";
$ret = $vm->CloneVM_Task($args);
while (in_array($ret->info->state, array('running', 'queued'))){
echo " " .$ret->info->progress .'%, ('. $ret->info->state .')';
sleep(1);
}
print_r($ret->info->error);
Result is :
vms is : test1
running clone :
LocalizedMethodFault Object
(
[fault] =>
[localizedMessage] => The operation is not supported on the object.
)
from vmwarephp.
Oh man, I should have caught the reference thing. Nice job debugging that, the error message you were getting did not give you much to go on!
from vmwarephp.
this error come because your user dnot have permission to clone vm task.
from vmwarephp.
Related Issues (20)
- I need help install or configure HOT 2
- trying to get Tasks, fails HOT 1
- Repo needs a version tag
- InvalidRequest error with vSphere 4.1.0 HOT 1
- Could you give me a example. HOT 10
- soap fault when calling EnterMaintenanceMode_Task or RebootHost_Task HOT 1
- Setting up the connection to vhost HOT 2
- Could anyone know how to register extension?
- vSphere API v6 causes segfault after a certain number of machines
- Using $vm->guestOperationsManager->fileManager fails
- Search Clustername - Hostname
- How to access virtual machine host information
- If this library can Reboot VM, RestartNIC...?
- Need help with getting information about VMs etc.
- Class 'Vmwarephp\Vhost' not found HOT 2
- version 7 support HOT 4
- RetrieveServiceContent() not found HOT 1
- tcp连接状态CLOSE WAIT过多
- Accessing VirtualMachine->snapshot when there are not snapshots creates an infinite loop
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vmwarephp.