VMware Cloud Community
odesey
Enthusiast
Enthusiast
Jump to solution

vRO 8 - Array Iterator issue

I am working on a workflow that will get a list of VM's from a text file. I convert the text file to an array like so:

var split = textList.content.split("\n");

split.forEach(function(uuid) {
    actionResult.push(uuid);
});

return actionResult;

 

Here is the problem, when I iterate over the array to find the VC:VirtualMachine object, only the last entry in the array is found. I have tried the following but they all have the same result, only the last VM in the array is found:

This script is inside an Action Item:

var VM_LIST = new Array();
VM_LIST = ["TEST-001", "TEST-002","TEST-003","TEST-004"]

VM_LIST.forEach(function(vm, i){
  //searching by UUID, same result, only finds the last VM in the array
  vCenterVm = sdkConnection.searchIndex.findByUuid(null, vm, true, false);

  //searching by UUID, with true as the last argument, does not find anything
  vCenterVm = sdkConnection.searchIndex.findByUuid(null, vm, true, true);

  //searching by VM name, same result, only finds the last VM in the array
  vCenterVm = VcPlugin.getAllVirtualMachines(null, vm)
})

 

 

 

My question is, why is this happening? Is there another way to iterate over an array of items and find a VM?

Environment: vRO 8.2
vCenter (2x) 6.7, (2x) 7.0
vRA: 8.2
vCenter Plugin version: VC 7.0.0.18048864
vReplicator Plugin version: VR 8.4.0.17638044

 

 

Labels (6)
Reply
0 Kudos
21 Replies
xian_
Expert
Expert
Jump to solution

Same here: vRA integrated vRO (vRealize Orchestrator 8.3.0.17737345) with preinstalled vCenter plugin.

Reply
0 Kudos
odesey
Enthusiast
Enthusiast
Jump to solution

I opened a case with VMware and they finally found the issue. Due to the fact that I was creating the text file on a windows machine I needed to do the following when reading the file into vRO:

 

\\ notice the \r that fixed the problem!
var split = textList.content.split("\r\n");

split.forEach(function(uuid) {
    actionResult.push(uuid);
});

return actionResult;

 

Thanks for all the help and suggestions.

Reply
0 Kudos