VMware Cloud Community
alexdglover
Contributor
Contributor
Jump to solution

Call to vCenter API - getAllVirtualMachines returns Undefined

Hey all, hoping this is an easy on.


I have an Orchestrator workflow to set the notes/annotation on a VM in vCenter (based on the example in this forum post). The workflow only has one scriptable object, content is as follows:



var xml = XMLManager.fromString(vm.toXml());

//System.log("XML is " + xml);

var vimObjectRef = xml.getElementsByTagName("ns9:VmVimObjectRef").item(0);

System.log("vimObjectRef is " + vimObjectRef);

var moRef = vimObjectRef.getElementsByTagName("ns9:MoRef").item(0);

System.log("moRef is " + moRef);

var vmId = moRef.textContent;

System.log("vmId is " + vmId);


// the "conn" object is my SDK on my DEV vCenter server

vcVm = conn.getAllVirtualMachines(null, "xpath:id='"+vmId+"'")[0];

System.log("vcVM is " + vcVm);

var configSummary = vcVm.summary.config;

System.log("configSummary is " + configSummary);

System.log("Old annotation: " + configSummary.annotation);

System.log("New annotation: " + notes);

var configSpec = new VcVirtualMachineConfigSpec();

configSpec.annotation = notes;

var task = vcVm.reconfigVM_Task(configSpec);

System.log(task);


In one of my environments, the workflow works fine. In my DEV environment, the workflow dies with the following error message:


TypeError: Cannot read property "summary" from undefined (Workflow:GEHC Util Change VM Annotation / Scriptable task (item0)#20)


Looking at the workflow, it seems that my getAllVirtualMachines is returning undefined, but can't for the life of me figure out why. I've looked at the Orchestrator logs, but it doesn't provide much beyond what I already saw in the Orchestrator client. I started looking in the vCenter logs, but not sure what to look for.


Any help or direction would be appreciated.

0 Kudos
1 Solution

Accepted Solutions
alexdglover
Contributor
Contributor
Jump to solution

In our environment, we run two vCenter instances - one for our management cluster, and one for our consumer cluster. Turns out I was pointing to the SDK on the management cluster and not the consumer cluster (where the VMs that I was trying to update reside). Thanks for the help.

View solution in original post

0 Kudos
4 Replies
mcfadyenj
Hot Shot
Hot Shot
Jump to solution

I would check the certificate is valid for the vcenter sdk.

validate your vco config has that cert on the dev environment. it is unlikely to be code related if the same workflow is running on another environment.

mcfadyenj
Hot Shot
Hot Shot
Jump to solution

can you detail what the conn object type is that you are passing in to the wf?

0 Kudos
alexdglover
Contributor
Contributor
Jump to solution

The object type is "VC:SdkConnection". The input variable is https://myVCenterServer.com:443/sdk

0 Kudos
alexdglover
Contributor
Contributor
Jump to solution

In our environment, we run two vCenter instances - one for our management cluster, and one for our consumer cluster. Turns out I was pointing to the SDK on the management cluster and not the consumer cluster (where the VMs that I was trying to update reside). Thanks for the help.

0 Kudos