I need to have a drop down on my vRA blueprints that will list the folders in vCenter allowing the user to specify which one they want to build their VM in. I can manually input the folder list as a Property Definition however our operations group creates quite a number of folders. What I would like to do is call a vRO workflow that will dynamically build this list for me so its not updated almost daily.
I found this code from an earlier post by Ilian Iliev
- // Search index object for the first registered vCenter
- var index = VcPlugin.allSdkConnections[0].searchIndex;
- // Inventory path of the folder to search for (note: starts with datacenter name; replace datacenter123 with your datacenter name)
- var invPath = "/datacenter123/vm/site1/servers/critical/";
- var folder = index.findByInventoryPath(invPath);
- System.log("folder: " + folder);
I did change the DC name to /mydatacenter/mycluster/ under which I have several top level folders and subfolders. When I run this workflow I get the following error message in vRO. I have tried this by declaring invPath as an attribute and hardcoding the datacenter and added folder as an output. I seem to have no luck either way.
[2017-07-20 09:15:44.132] [E] Error in (Workflow:getFolderList / Scriptable task (item1)#6) TypeError: Cannot call method "findByInventoryPath" of null
[2017-07-20 09:15:44.140] [E] Workflow execution stack:
***
item: 'getFolderList/item1', state: 'failed', business state: 'null', exception: 'TypeError: Cannot call method "findByInventoryPath" of null (Workflow:getFolderList / Scriptable task (item1)#6)'
workflow: 'getFolderList' (16cedf47-3abc-4e1b-ba60-e390b995e1bc)
| 'attribute': name=invPath type=string value=/p10dcvcenterha.amwins.local/P10/
| 'output': name=folder type=string value=null
| 'no inputs'
*** End of execution stack.
Any assistance would be great.
Thanks