VMware Cloud Community
Vidal30
Contributor
Contributor
Jump to solution

Print information from VC:VirtualMachine, VCO WF

    Hi,

I try to create a new WF to receive a VC:VirtualMachine object from a user and print information on the machine (ID, Name, CPU, Memory, OS type).

The wf not works well :

System.log("VM ID: " + VmName.id  +  "VM Name : " + VmName.name  +  "VM CPU : "  + VmNme.cpu  +  "VM Memroy : " + VmName.memory  + "VM OS : "   + VmName.guestOS);

I got this log - [2017-09-04 12:02:35.616] [I] VM ID: vm-81VM Name : VM-SQLVM CPU : undefinedVM Memroy : undefinedVM OS : undefined

Some help...

1 Solution

Accepted Solutions
poorem
Enthusiast
Enthusiast
Jump to solution

Hi,

I can see why you've gone for those property names, but they're not right. If you use the vRO API explorer and get to the VcVirtualMachine object, you'll see that "cpu", "memory" and "guestOS" aren't properties of that object at all and hence why they're showing as "undefined".

201709247_110952-CapturFiles.png

The properties that you want can be found from some of the referenced objects. For example, VmName.config.hardware will return an object that contains the CPU and Memory configuration for the VM (amongst other things).

The line of javascript that you'd then end up with would be:

System.log("VM ID: " + VmName.id + " VM Name: " + VmName.name + " VM CPU: " + VmName.config.hardware.numCPU + " VM Memory: " + VmName.config.hardware.memoryMB + " VM OS: " + VmName.config.guestFullName);

Hopefully that should produce the output that you want.

Michael

View solution in original post

9 Replies
poorem
Enthusiast
Enthusiast
Jump to solution

Hi,

I can see why you've gone for those property names, but they're not right. If you use the vRO API explorer and get to the VcVirtualMachine object, you'll see that "cpu", "memory" and "guestOS" aren't properties of that object at all and hence why they're showing as "undefined".

201709247_110952-CapturFiles.png

The properties that you want can be found from some of the referenced objects. For example, VmName.config.hardware will return an object that contains the CPU and Memory configuration for the VM (amongst other things).

The line of javascript that you'd then end up with would be:

System.log("VM ID: " + VmName.id + " VM Name: " + VmName.name + " VM CPU: " + VmName.config.hardware.numCPU + " VM Memory: " + VmName.config.hardware.memoryMB + " VM OS: " + VmName.config.guestFullName);

Hopefully that should produce the output that you want.

Michael

iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

poorem - actually, I think the newer builds of vCenter plug-in has these properties of VcVirtualMachine Smiley Happy (at least I see them in the plug-in version shipped with vRO 7.3) They act as kind of aliases for vm.summary.config.numCpu, vm.summary.config.memorySizeMB and vm.summary.config.guestFullName, respectively.

Vidal30​ - could you confirm the version and build number of the vCenter plug-in you are using?

0 Kudos
poorem
Enthusiast
Enthusiast
Jump to solution

The original post was tagged with "vco 6" I think.

0 Kudos
Vidal30
Contributor
Contributor
Jump to solution

Thanks for the help!

Yes the version is VCO 6.0.5

0 Kudos
Vidal30
Contributor
Contributor
Jump to solution

The PrtScr from vco :

pastedImage_0.png

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Ah, yes, I missed the tag.

vRO 7.3 is the first vRO version that ships with a different implementation of vCenter plug-in. All previous vRO versions, including vRO 6.0.5, contain the "classic" implementation of vCenter plug-in, which does not have these properties directly exposed as top-level properties on VirtualMachine object.

So, to make sure your scripting code works in both plug-in implementations, you can use the longer property expressions (as shown in post 1 and post 2) to fetch the info you need.

Vidal30
Contributor
Contributor
Jump to solution

It's working, but why when I click on VC: VirtualMachine I don't see the property or function? has a picture above.

0 Kudos
poorem
Enthusiast
Enthusiast
Jump to solution

Try clicking on the link for "VcVirtualMachine" next to where it says "Scripting Object".

0 Kudos
poorem
Enthusiast
Enthusiast
Jump to solution

I must admit that I haven't fully explored the newer vCenter plugin yet. Useful to know, thank you.

0 Kudos