VMware Cloud Community
SOMVCOE
Contributor
Contributor

Problem converting vCenter object to VumVIInventory

I am attempting to execute the follow code within an action, and receiving the error below. The error suggests that VumVIInventory.id doesn't exist, but the API documentation says differently. Does anybody have any suggestions?

Code:

****Note**** This action takes the input of a VcHostSystem(variable named inputHostSystem)

// create the new VUM Inventory object and assign values.

// first define a new instance of the object, pointing to the vCenter Server of the host

var vumItem = new VumVIInventory(inputHostSystem.sdkConnection.name);

System.log(inputHostSystem.sdkConnection.name);

System.log(inputHostSystem.reference.value);

System.log(inputHostSystem.vimType);

System.log(inputHostSystem.name);

// get the Managed Object Reference

vumItem.id = inputHostSystem.reference.value;

// get the Managed Object Type

vumItem.type = inputHostSystem.vimType;

// get the ESXi Host name

vumItem.name = inputHostSystem.name;

// the VUMVIInventory object must be an array, so create a dummy one and push the host value in

var vumHosts = [];

vumHosts.push(vumItem);

// return the array of VUM objects (even if it is just one)

return vumHosts;

Error Message:

[2017-02-07 07:47:35.352] [E] (<REMOVED>/findVUMobjectfromvCenter) Property or method 'id' not found on object VumVIInventory

[2017-02-07 07:47:35.362] [E] Workflow execution stack:

***

item: 'Patch host with vUM/item3', state: 'failed', business state: 'null', exception: 'Property or method 'id' not found on object VumVIInventory'

workflow: 'Patch host with vUM' (fb97061b-cdb9-487f-b915-bbe897105ca4)

|  'attribute': name=serverURI type=string value=

|  'attribute': name=entities type=Array/VUM:VIInventory value=null

|  'attribute': name=baselines type=Array/VUM:Baseline value=__NULL__

|  'attribute': name=excludedPatches type=Array/VUM:PatchInfo value=null

|  'attribute': name=autoAcceptEULA type=boolean value=true

|  'input': name=inputHostSystem type=VC:HostSystem value=<REMOVED>'

|  'no outputs'

*** End of execution stack.

Reply
0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee

I'm not very familiar with VUM plug-in and VUM in general, but it is likely that VumVIInventory is a managed entity that cannot be directly instantiated using var item = new VumVIInventory(...); syntax.

Instead, you should probably try to fetch it by other means, eg. using var items = VumObjectManager.getEntities(...); or other suitable methods.

Reply
0 Kudos
PetarGeorgiev
VMware Employee
VMware Employee

Hello,

The  VumVIInventory is managed object and instance of that type need to be retrieved from the Update Manager API.

For example to retrieve all VumVIInventory instances form the vCenter server (with associated  Update Manager server ) the following API shall be used:

var  list = VumObjectManager.getEntities(serverUri);

The build in Update Manager plugin code might be used as reference code.

Best Regards,

Petar Georgiev

Reply
0 Kudos