Get Orchestrator Hostname and IP using JavaScript

There is no official API for the Orchestrator appliance hostname, so here are two workarounds: parse JVM_OPTS through a local Command, or read the vRA plugin host URL, then resolve the FQDN to an IP with System.resolveHostName().

In this article

To get the vRealize Orchestrator (vRO) appliance’s hostname using JavaScript within a vRO workflow, there is no official API call for this purpose, but there are practical workarounds:

Method 1: Parse Environment Variables

In vRO 8.x (containerized), you might be able to extract the hostname from JVM arguments in the environment:

Prerequisite: Enable local process execution.

var com = new Command(["printenv", "|", "fgrep", "JVM_OPTS"]);
var res = com.execute(true); // makes the call blocking
var output = com.output;
var nodeName = output.match(/-Dvco.app.hostname=([^\s]+)/)[1];
System.log('vRO Hostname: ' + nodeName); // vRO Hostname: vra_fqdn.domain.local

Method 2: Extract embedded vRO Hostname from vRA Plugin

If local command execution is not permitted, you can try to extract the hostname or IP from the vRA Plugin class :

System.log(VraHostManager.defaultHostData.vraHost); // https://vra_fqdn.domain.local

Getting IP from FQDN

System.log(System.resolveHostName("vra_fqdn.domain.local")); // 10.242.1.8
System.log(System.resolveIpAddress("10.242.1.8")); //10-242-1-8.kubernetes.default.svc.cluster.local

Summary Table

MethodReliabilityNotes
CommandHighNeeds local process enabled
vRA PluginLowMay return IP or hostname

Choose the method that matches your vRO configuration and security policy.
If you cannot enable local process execution, the vRA host url extraction is the safest alternative.

Citations:

  1. https://community.broadcom.com/vmware-cloud-foundation/discussion/getting-hostnameip-of-current-node-in-vro-cluster-using-a-workflow
  2. https://richdowling.wordpress.com/2020/09/14/vrealize-orchestrator-name-ip-lookups/


Discover more from Cloud Blogger

Subscribe to get the latest posts sent to your email.

Enjoyed this post?

Was this helpful?

Leave a Reply