VMware Cloud Community
orian
Hot Shot
Hot Shot
Jump to solution

get all template

Hi,

Is there a workflow\action which get all the templates available in the Orchestrator?

I would like to allow the user to choose a template from a list of templates which inform him also about the vCenter it is connected

Thanks!

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

There is a boolean flag in virtual machine configuration object, indicating whether the virtual machine is a template or not. Here is some sample scripting code showing how to get all templates from all configured vCenter server instances:

var vms = VcPlugin.allVirtualMachines;

var templates = []; // templates will be stored into this array

for each (var vm in vms) {

  if (vm.config != null && vm.config.template) {

    templates.push(vm);

  }

}

// iterate over all found templates and print their names

for each (var t in templates) {

  System.log("template -> " + t.name);

}

View solution in original post

0 Kudos
4 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

There is a boolean flag in virtual machine configuration object, indicating whether the virtual machine is a template or not. Here is some sample scripting code showing how to get all templates from all configured vCenter server instances:

var vms = VcPlugin.allVirtualMachines;

var templates = []; // templates will be stored into this array

for each (var vm in vms) {

  if (vm.config != null && vm.config.template) {

    templates.push(vm);

  }

}

// iterate over all found templates and print their names

for each (var t in templates) {

  System.log("template -> " + t.name);

}

0 Kudos
orian
Hot Shot
Hot Shot
Jump to solution

Can i know  on which vCenter the image is located?

0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

from mind: I think vm.sdkConnection should return the sdkConnection object that represents the vCenter connection this VM/template is located.

Regards,

Joerg

0 Kudos
orian
Hot Shot
Hot Shot
Jump to solution

I found the sdkConnection parameters.

Thanks!

0 Kudos