Hello.
Does anybody know how to get hostname or IP address of the vCO server within a workflow running on that server? Is there any kind of property or method returning hostname of the local host?
Thank you.
Try this :
function getVcoHostname() {
var answerUrl = workflow.getAnswerUrl().url;
var re = new RegExp('^(?:f|ht)tp(?:s)?\://([^/]+)', 'im');
return answerUrl.match(re)[1].toString().split(":")[0];
}
I'm not aware of any off the top of my head... A quick look in the api explorer didn't show anything obvious either.. If I had to do this, I would use the "command" object and then use the "hostname" command to get the hostname, or use ipconfig or ifconfig depending on the OS to get the IP info.
See Joerg's great post here to learn more about running local commands:
http://www.vcoportal.de/2011/08/small-but-useful-command-line-tools-for-vco-workflows/
Try this :
function getVcoHostname() {
var answerUrl = workflow.getAnswerUrl().url;
var re = new RegExp('^(?:f|ht)tp(?:s)?\://([^/]+)', 'im');
return answerUrl.match(re)[1].toString().split(":")[0];
}
In my case that returns an IP address, which I then use the System.resolveIpAddress() function on to actually get the hostname.
This script is not working with 6.0.2.1 orchestrator
That's right, that code is no longer expected to work as it is using a method that was part of the webviews which is now deprecated.
Here's another way to get the info.. requires editing the hosts file:
1. Edit /etc/hosts on your Orchestrator server
2. Add the FQDN and hostname to the line that starts 127.0.0.1: For example:
127.0.0.1 vro.vcoteam.lab vro localhost
3. Use the following in your scriptable tasks/actions:
var myHostname = System.resolveIpAddress("127.0.0.1");
System.log("vRO Hostname: "+ myHostname);
Thanks Burke.. but wanted the ip address of the vco server?
Hello,
I think you can use also
var command = new Command("hostname");
command,execute(true);
var vROHostname = command.output;
cheers
Harald
Another way to get the IP
netInterface = Config.getNetworkInterfaces();
System.log(netInterface.getValidBindInterfaces());
That will give you a list of valid binding ip's which will inclust the ip of the vRO.
This topic has come up again while I was working with a client this week.
I want to add a note here that the Config object in the last reply is now no longer valid in vRO 7+ so we must find other work-arounds until vRO provides a more friendly way of getting this info.
One of the most simple ways would be to create a configuration element that had an attribute for each: IPAddress and HostName, then it would be quite easy to retrieve at any time in scripts.