VMware Cloud Community
knjb
Contributor
Contributor
Jump to solution

Get Orchestrator Hostname in vRO8

Hi,

in our vRO 7.x environment we use a workflow to get the hostname of the current orchestrator.

Due to the Kubernetes setup in VRO 8.x we can’t get the orchestrator name by the “hostname” command anymore.

Has someone a good idea how to get the hostname of the orchestrator?

Background:

Our environment consists of multiple orchestrators instances and all of them have the same workflows, actions and configuration elements on them.

Depending on the hostname of the orchestrator there are different configurations loaded.

We don’t want to set a custom configuration element on every orchestrator to avoid this customizations.

Thanks!

1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Right, the 'hostname' command is not available inside the container.

Currently, there is no official API to fetch the hostname from scripting code. One very hacky way is to try to get it from environment variables passed to vRO container. Check if the following code works for you:

var cmd = new Command('printenv');

cmd.execute(true);

var out = cmd.output;

var prop = "-Dvco.app.hostname=";

var posStart = out.indexOf(prop);

var posSpace = out.indexOf(" ", posStart);

var hostname = out.substring(posStart + prop.length, posSpace);

System.log("hostname = " + hostname + "'");

Again, this is not a supported way to get the hostname, and there is no guarantee that the above code will work in future vRO releases.

View solution in original post

3 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

What do you mean by can't get the name by 'hostname' command? If you make an SSH connection to vRO 8.x appliance, you should be able to invoke 'hostname'. It's the same as 7.x.

Or perhaps you want to have more that 1 pod replicas in the same appliance and get a unique hostname for each replica?

Reply
0 Kudos
knjb
Contributor
Contributor
Jump to solution

We execute this command as system command from a workflow:

var cmd = new Command('hostname');

cmd.execute(true);

In vRO 8 this command seems to be executed in a container which does not know the hostname command.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Right, the 'hostname' command is not available inside the container.

Currently, there is no official API to fetch the hostname from scripting code. One very hacky way is to try to get it from environment variables passed to vRO container. Check if the following code works for you:

var cmd = new Command('printenv');

cmd.execute(true);

var out = cmd.output;

var prop = "-Dvco.app.hostname=";

var posStart = out.indexOf(prop);

var posSpace = out.indexOf(" ", posStart);

var hostname = out.substring(posStart + prop.length, posSpace);

System.log("hostname = " + hostname + "'");

Again, this is not a supported way to get the hostname, and there is no guarantee that the above code will work in future vRO releases.