VMware Cloud Community
rlustila1
Contributor
Contributor
Jump to solution

VRO extract host value from VC:HostSystem

Hi All,

I am working on setting up a self-healing datacenter workflow.  When an alert is triggered VROPS is kicking off an action using the vro management pack for vrops.

The issue I am running into is the VC:HostSystem output that vrops kicks out does not contain the host name specifically.  It looks like I have to parse threw VC:HostSystem to get the value = host-103 out of it that I need to run in a powershell script to get the real name which isnt a big deal.  So that being said, I am having a difficult time getting to the value = host-103 out of VC:HostSystem. 

Here is what VROPS sends me as VC:HostSystem:

DynamicWrapper (Instance) : [VcHostSystem]-[class com.vmware.o11n.plugin.vsphere_gen.HostSystem_Wrapper] -- VALUE : Stub: moRef = (ManagedObjectReference: type = HostSystem, value = host-103, serverGuid = null), binding = https://vcenter-test1.testingstuff.net:443/sdk

I have tried using regex, I have tried converting it over to a string because i thought maybe it wasnt able to work because VC:HostSystem is an Object.  I am a novice at javascript and still learning, does anyone have any examples of doing this properly?

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

In vRO Javascript code, once you have an object of type VC:HostSystem, you can retrieve the host name directly with a call that looks like

// let's assume you got the variable 'host' of type VC:HostSystem

var name = host.name;

System.log("host name: " + name);

You can check in vRO API Explorer what properties/methods are available for VC:HostSystem / VcHostSystem

View solution in original post

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

In vRO Javascript code, once you have an object of type VC:HostSystem, you can retrieve the host name directly with a call that looks like

// let's assume you got the variable 'host' of type VC:HostSystem

var name = host.name;

System.log("host name: " + name);

You can check in vRO API Explorer what properties/methods are available for VC:HostSystem / VcHostSystem

0 Kudos
rlustila1
Contributor
Contributor
Jump to solution

I cannot thank you enough for this!!!!  Works perfectly and far more simple then I was expecting. 

0 Kudos