VMware Cloud Community
kevholland
Contributor
Contributor
Jump to solution

View Virtual Machine Specs with Orchestrator

I only recently started using vCenter Orchestrator and was hoping someone could help me out.  I have the need to pull the amount of RAM and the number of vCPUs on a VM and place them in a variable.  In powershell, I'd  do something like this:

$vmName = get-vm  vmname

$vmName.MemoryMB

$vmName.NumCpu

How do I go about doing this in orchestrator?  Thanks for your help.

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Like this:

cpuCount = vm.summary.config.numCpu;
memoryMB = vm.summary.config.memorySizeMB;

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter

View solution in original post

Reply
0 Kudos
12 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Like this:

cpuCount = vm.summary.config.numCpu;
memoryMB = vm.summary.config.memorySizeMB;

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
kevholland
Contributor
Contributor
Jump to solution

cdecanini_, this is great, thank-you.  Where can I go to view documentation that outlines other VM or Host attributes?

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

Use the API Explorer that is built into the vCO Client... it is in the right pane when you are editing a scriptable task or action and it is also available from the tools menu. Just locate the object you wish to know more about, then drill down into the various properties until you find what you need Smiley Happy

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
cdecanini_
VMware Employee
VMware Employee
Jump to solution

The same API search has links to the vCenter SDK API documentation if you need more details.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
DonDomel
Contributor
Contributor
Jump to solution

HI.

I'm learning vCO and I wanted to use this as excercise.

So I've created a flow with 2 steps (picture 0) :

1. Get Virtual machine by name   (from \Library\vCenter\Virtual Machine Management\Basic\Get virtual machine by name

2. scriptable task

Global input is: "vmName" and it's bind to the input of 1 step ( picture attached 1.jpg) and output attribute is "vms".

Than in scriptable task I have "in" attribute "vms" bind to the "vms" and two Out Attributes.

I have error:  "TypeError: Cannot read property "config" from undefined (Workflow:D_new_0.4 / Scriptable task (item2)#12758)"

What does it mean ?

DD

Reply
0 Kudos
ChristianWehner
VMware Employee
VMware Employee
Jump to solution

Hi DD,

I think you have to choose the first vm within your array of vms. So in your scriptabe task you can choose the first vm like this:

var vm = new new VcVirtualMachine() ;

vm = vms.shift(); // Returns the first item within the vms array

And then use vm to get the informations you want insted of vms.

If this is working. The error is, that you are trying to get the .config attribute from an array which only have the attribute length. Herefor you can take a look to the API explorer within orchestrator where you can see attributes and functions of objects like VcVirtualMachine or Array.

If this isn't, we have to see your code from the scriptable task to help you.

Regards,

Chris

Reply
0 Kudos
DonDomel
Contributor
Contributor
Jump to solution

Ok so I've moddify a bit this flow:

STEP1:

Get Virtual machine

input : vmNAME

Out Attrib : vms

(picture 001 attached)

STEP2

Scriptable Task

In Attrib : vms

Out Attrib : cpuCount

Out Attrib : memoryMB

Script:

System.log("VM: " + vms);
Server.log("VM: " + vms);

cpuCount = vms.summary.config.numCpu;
memoryMB = vms.summary.config.memorySizeMB;

(picture 002 and 002a attached)

When the flow run, I'm inserting vm name:  for example "I_VM"  (it exist in vCenter)

STEP1 it's finding this vm and passing to STEP2

Results failed...

Reply
0 Kudos
ChristianWehner
VMware Employee
VMware Employee
Jump to solution

I mean, you should change your script from STEP 2 to this:

System.log("VM: " + vms);
Server.log("VM: " + vms);

var vm = new new VcVirtualMachine() ;

vm = vms.shift(); // Returns the first item within the vms array

System.log("VM: " + vm.name);
Server.log("VM: " + vm.name);


cpuCount = vm.summary.config.numCpu;
memoryMB = vm.summary.config.memorySizeMB;

Cause your "vms" input is an array of virtualmachines and not one single virtualmachine. The attribute summary is not available on an array but on a virtualmachine object. So you have to pic the first virtualmachine object from within the array.

Regards

Reply
0 Kudos
DonDomel
Contributor
Contributor
Jump to solution

[I] Unable to create object : VcVirtualMachine : com.vmware.vmo.plugin.vi4.model.VimVirtualMachine

So now I'm confuse. Everything looks ok.... but .. ;/


Reply
0 Kudos
DonDomel
Contributor
Contributor
Jump to solution

OK got it:

System.log("VM: " + vms);
Server.log("VM: " + vms);

vm = vms.shift(); // Returns the first item within the vms array

System.log("VM: " + vm.name);
Server.log("VM: " + vm.name);

cpuCount = vm.summary.config.numCpu;
memoryMB = vm.summary.config.memorySizeMB;

Results in screen

cpuCount and memory MB retrieved

THANKS FOR YOU HELP Smiley Happy

Reply
0 Kudos
ChristianWehner
VMware Employee
VMware Employee
Jump to solution

Sorry there was an error on my side of the code. I wrote two times "new" where one was enough. Smiley Happy

Have fun on your other projects with vCO.

Reply
0 Kudos
DonDomel
Contributor
Contributor
Jump to solution

Yes but this "bold"  // var vm = VcVirtualMachine() ; in a code below is

System.log("VM: " + vms);
Server.log("VM: " + vms);

// var vm = VcVirtualMachine() ;

vm = vms.shift(); // Returns the first item within the vms array

System.log("VM: " + vm.name);
Server.log("VM: " + vm.name);


cpuCount = vm.summary.config.numCpu;
memoryMB = vm.summary.config.memorySizeMB;

not necessary, because vms is an object passed from STEP1 "get virtual machine by name" workflow

So I used only

vm = vms.shift();

Smiley Happy

Reply
0 Kudos