VMware {code} Community
tedmoyses
Contributor
Contributor

PHP + NuSoap TraversalSpec help

Hi,

I would really appreciate some help here. I am an expereinced OOPHP dev working for a datacentre with VMware Enterprise+ cloud.

I am using PHP and NuSoap to connect to vcenter, I can log in, get ServiceContent and query for some information successfully.

My issue is I have to find the names of all subfolders in a folder called 'End Users' - these subfolders represent each of our end users and contains their VMs.

I need the names of each of these subfolders as the name contains the end users customerID. If this ID matches my current customer ID (this is part of a self service portal) I can then query all their VMs and get some metrics to display.

I can get the 'End Users' Folder (using SearchIndex->findByInventoryPath) and the childEntity property (using propertyColector) but I do not want to have then query for each child as this folder has many children.

I need to be able to use traversalSpec to get me all the childrens(sub folders) names in one query, I can then iterate over to find CustomerID and do what I need.

HELP!

I cannot get traversalSpec to give me anything other than "Object not found". I am using NuSoap and have tried a few ways of forming the traversalSpec but not even sure if I have got this right.

My code so far - skipping login

$soapmsg = new soapval('_this', false, $serviceContent, false, false, array('type' => 'PropertyCollector'));
$soapmsg = 'Folder';
$soapmsg = 'childEntity';
$soapmsg = new soapval('obj', false, $endUsersFolder, false, false, array('type' => 'Folder'));
$soapmsg = true;

then call RetreiveProperties

This gets me the End Users Folder childEntity Property, but when I try to use traversalSpec by adding:

$soapmsg = array('name' => 'folderToChild', 'type' => 'Folder', 'skip' => false, 'path' => 'childEntity', 'selectSet' => array('name' => 'folderToChild'));

I get "ServerFaultCode: Object not found"

If this traversalSpec is properly formed (I have been through a few variations some with Parameter errors) then it is pointing to somewhere that does not exist or does not meet my propSet.

Please can anyone help me form the TraversalSpec in PHP (or show me what the XML request body should look like)?

Thanks in advance

Ted

0 Kudos
2 Replies
tedmoyses
Contributor
Contributor

actually the above code is mangled by this forum (although it looked fine in the preview).

If anyone has any idea what I am talking about or can decipher the code above, please do get in touch.

Please see attached file for better code listing.

Thanks for reading

Ted

0 Kudos
tedmoyses
Contributor
Contributor

Nobody?

If anyone could show me some XML of a PropertyCollector working with a Traversal Spec, that could help.

Or any advice on use of TraversalSpec would be most gratefully received.

Thanks

Ted

0 Kudos