VMware Cloud Community
pezhorEL
Contributor
Contributor

How to convert from vCloud:VmwHost to VC:HostSystem

I'm curious if it's possible to convert a vCloud:Vmwhost In Parameter to a VC:HostSystem object as part of a comprehensive maintenance mode script. The goal is to first disable the host in vCloud (handled by the "Enable an ESX host" workflow, then call the "Enter maintenance mode" workflow.

Unfortunately, as the vCloud object is different than the VC object I'm running into issues. Is there an intermediary step that I can take to make this work?

0 Kudos
1 Reply
iiliev
VMware Employee
VMware Employee

vCloud and VC plug-ins don't know about each other so there is no direct conversion.

One possible way to get VcHostSystem object matching that VclVMWHost object is:

  • Using VcPlugin.getAllHostSystems(null,null) API, get the list of available VC hosts
  • Iterate over this list and get the element whose id matched the id of the provided VclVMWHost object

I don't have a working vCloud environment in front of me right now so I can't check the above, but in theory it should work.

Note that VcPlugin.getAllHostSystem() API has 2 parameters which should allow to narrow the search results, but I don't remember the exact syntax for them; for now, you can pass null in both, and the call will return all hosts.

Hope this helps,

-Ilian

0 Kudos