VCF Automation Blog

from Stefan Schnell

In some cases it may be necessary or simply interesting to find out which version of the VMware Orchestrator is being used during the runtime of a JavaScript action.

Detect Orchestrator Version


Here an approach to detect the current Orchestator version.

/**
 *
 * @module de.stschnell
 *
 * @version 0.1.0
 *
 * @outputType String
 *
 */

function getOrchestratorVersion() {

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

/**
 * Detects the VCF Automation Orchestrator version.
 *
 * Parts of the code are from Mischa Buijs
 * https://be-virtual.net/vrealize-orchestrator-identifying-version-running/
 *
 * @author Stefan Schnell <mail@stefan-schnell.de>
 * @license MIT
 * @version 0.1.0
 *
 * Checked with VMware Aria Automation 8.12.0, 8.14.0 and 8.16.2.
 */

/**
 * https://[yourFqdn]/vco/api/about delivers the following XML:
 *
 * <ns2:about-info>
 *   <ns2:build-number>22610007</ns2:build-number>
 *   <ns2:build-date>2023-10-14T16:17:05Z</ns2:build-date>
 *   <ns2:version>8.14.0.22610007</ns2:version>
 *   <ns2:api-version>8.x</ns2:api-version>
 *   <ns2:time-zone>
 *     <ID>GMT</ID>
 *     <rawOffset>0</rawOffset>
 *   </ns2:time-zone>
 *   <ns2:features/>
 *   <ns2:id>302e3139-3630-3532-3337-343132333136</ns2:id>
 * </ns2:about-info>
 */

/**
 * The JVM options of the Orchestration are specified in the JVM_OPTS
 * environment variable.
 */
var jvmOpts = java.lang.System.getenv("JVM_OPTS");
if (jvmOpts !== null) {

  var fqdn = "";
  var options = jvmOpts.split(" ");
  options.forEach( function(option) {
    // -D sets an environment variable.
    if (option.substring(0, 19) === "-Dvco.app.hostname=") {
      fqdn = option.substring(19, option.length);
    }
  });
  if (fqdn !== "") {

    url = "http://" + fqdn + "/vco/api/about";
    try {
      var urlObject = new URL(url);
      var result = urlObject.getContent() ;
    } catch (exception) {
      url = "https://" + fqdn + "/vco/api/about";
      try {
        var urlObject = new URL(url);
        var result = urlObject.getContent() ;
      } catch (exception) {
        throw "Could not find VCF Automation Orchestrator (" +
          exception.message + ")";
      }
    }

    try {

      var jsonObject = JSON.parse(result);
      var aboutVersion = jsonObject.version;
      var aboutBuildNumber = jsonObject["build-number"];
      var aboutBuildDate = jsonObject["build-date"];
      var aboutApiVersion = jsonObject["api-version"];

      System.log(fqdn);
      System.log("Version: " + aboutVersion);
      System.log("Build number: " + aboutBuildNumber);
      System.log("Build date: " + aboutBuildDate);
      System.log("API Version: " + aboutApiVersion);

      return aboutVersion;

    } catch (exception) {
      throw "Error at JSON object (" + exception.message + ")";
    }

  }

}

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

}

vcf automation orchestrator version detection