VCF Automation Blog

from Stefan Schnell

Get Full Qualified Domain Name (FQDN)


/**
 * @module de.stschnell
 *
 * @version 0.1.0
 *
 * @outputType string
 *
 * @description Detects the Full Qualified Domain Name (FQDN)
 */
function getFQDN() {

// Begin ---------------------------------------------------------------

/**
 * @function getFQDN
 *
 * @returns {string} FQDN
 *
 * @author Stefan Schnell <mail@stefan-schnell.de>
 * @license MIT
 * @version 0.1.0
 *
 * Set com.vmware.scripting.javascript.allow-native-object in the
 * system properties to true.
 *
 * Checked with Aria Automation 8.12.0
 */

var fqdn = "";
var jvmOpts = java.lang.System.getenv("JVM_OPTS");
if (jvmOpts !== null) {
  var options = jvmOpts.split(" ");
  options.forEach( function(option) {
    if (option.substring(0, 19) === "-Dvco.app.hostname=") {
      fqdn = option.substring(19, option.length);
    }
  });
  if (fqdn !== "") {
    return fqdn;
  }
}
return null;

// End -----------------------------------------------------------------

}

vcf automation orchestrator action to get the full qualified domain name (fqdn)