Labus
Contributor
Contributor

Checking the existence

Hi all!

How can I check if vmFolder or vmResourcePool exist in vSphere? I need it for scripting in vCO.

Something like this:

Create vmFolder.

Check: if vmFolder exist => do nothing and use name of this folder as out parameter.

else CreateFolder(name).

Thx for comments (sorry my bad english)

0 Kudos
2 Replies
admin
Immortal
Immortal

Hi,

vmFolder is a property of a Datacenter and by default, datacenter has 4 folders:- vmFolder, hostFolder, networkFolder and datastoreFolder. You can take input parameter as a datacenter entity and fetch it's vmFolder property.

Regarding how to fetch resourcepool, you can fetch this from ComputeResource entity.

Let me know if this helps or you have any follow up questions.

- Angela -

Labus
Contributor
Contributor

Thanks for reply, Angela!

In my scripts I use template workflow (Create virtual machine folder). It has 2 input parameters: parentFolder (VC:vmFolder) and name (sting); output parameter is newFolder (VC:vmFoled). So, the script looks like:

newFolder = parentFolder.createFolder(name);

But, can you show me small example how can I fetch parentFolder (Folder "vm" in datacenter) and check existence name of newFolder before creating?

0 Kudos