VCF Automation Blog

from Stefan Schnell


The VMware Photon OS is the operating system of the runtime environment (RTE) containers of VCF Automation. This post shows approaches how to detect the OS version of the different RTEs.

Get Photon OS Version


Three approaches, in Python, JavaScript for Node and PowerShell, and the output in release 8.18.0 and 8.18.1 are presented below, to detect OS details. VMware Photon OS 4 is returned in all cases with release 8.18.0. With release 8.18.1 return the PowerShell runtime environments VMware Photon OS 5, Python and Node continue to deliver the previous information.

Python

import json
import subprocess

def handler(context, inputs):

    result = subprocess.run(
        ["cat", "/etc/os-release"],
        capture_output = True,
        text = True
    )

    """
    result = subprocess.run(
        ["cat", "/etc/photon-release"],
        capture_output = True,
        text = True
    )

    # Prints basic information about the os name and system hardware
    result = subprocess.run(
        ["uname", "-a"],
        capture_output = True,
        text = True
    )

    result = subprocess.run(
        ["/lib/libc.so.6", "--version"],
        capture_output = True,
        text = True
    )
    """

    outputs = {
      "status": "done",
      "result": result.stdout
    }

    return outputs

Node

exports.handler = (context, inputs, callback) => {

    var result = require("child_process").execSync(
        "cat /etc/os-release"
    );

    callback(
        undefined,
        {
            status: "done",
            result: result.toString()
        }
    );

}

PowerShell

function Handler($context, $inputs) {

    $result = & "cat" @("/etc/os-release") | Out-String

    $output=@{
        status = "done"
        result = $result
    }

    return $output

}

Result of VCF Automation 8.18.0

The result is from all runtime environments.
NAME="VMware Photon OS"
VERSION="4.0"
ID=photon
VERSION_ID=4.0
PRETTY_NAME="VMware Photon OS/Linux"
ANSI_COLOR="1;34"
HOME_URL="https://vmware.github.io/photon/"
BUG_REPORT_URL="https://github.com/vmware/photon/issues"

Result of VCF Automation 8.18.1

The result is from the PowerShell runtime environments. Python and Node delivers the same result as 8.18.0.
NAME="VMware Photon OS"
VERSION="5.0"
ID=photon
VERSION_ID=5.0
PRETTY_NAME="VMware Photon OS/Linux"
ANSI_COLOR="1;34"
HOME_URL="https://vmware.github.io/photon/"
BUG_REPORT_URL="https://github.com/vmware/photon/issues"