zCX, Python, and ZOAU, oh my!

Anthony Giorgio
Theropod
Published in
3 min readSep 21, 2021

🖥 🖥 🖥

I’m a function tester on the z/OS Container Extensions (zCX) team, and I spend a lot of time writing scripts and tools to drive various code paths for testing. These tools invoke various system commands, in a variety of environments. I’ve found that the various ZOAU programs to be very helpful in writing these tools. The opercmd command is especially helpful, as it allows you to submit a z/OS operator command from a z/OS UNIX environment.

While working with zCX, I found that I was working with a large inventory of appliance instances. As new versions of the appliances were made available, these instances needed to be upgraded. When starting the instance, the GLZB022I message will show if a newer appliance version is available. This is helpful, but I wanted something that could check an entire inventory of instances.

To solve this need, I wrote a script that iterates over the zCX registry directory, where all the instance configuration files are stored. I wanted to write a tool that would run from z/OS UNIX, as I’m most comfortable in that environment. I decided to write it using Python, as IBM now ships a Python environment for z/OS. Python makes it simple to perform many common programming tasks, using both built-in language features and an extensive package library.

In order to determine whether an instance needed updating, I decided to parse theGLZB022I message. The first step to doing this is to get the contents of that message into a Python string variable. I was able to do that using the ZOAU utility opercmd. I used the Python subprocess module to issue the shell command opercmd "MODIFY ZCXANGIO,DISPLAY,VERSION" , where ZCXANGIO is the name of my running zCX instance.

angio@pkstnp8 ~> opercmd "MODIFY ZCXANGIO,DISPLAY,VERSION"GLZB022I zCX instance ZCXANGIO version information
Bootloader: HZDC7C0 oa61857
3.19.1 1.2.3
Current Appliance: HZDC7C0 oa61436
3.19.1 1.16.1
20210525T132155Z
Available Appliance: HZDC7C0 oa61559
3.19.1 1.16.5
20210625T173715Z
Virtualization Layer: HBB77C0 OA61804 08/10/21
Started on 2021/09/09 09:40:07
Workflows Performed:
Provision: 1.0.38 OA61108 2021/06/01 13:11
Reconfigure: N/A N/A N/A
Upgrade: N/A N/A N/A
Add Data Disks: N/A N/A N/A

The output of this command contains theGLZB022I message, and is stored into a string. Since the message is printed in a well-defined format, I can iterate over the lines until I find the one relating to the instance version.

Python code showing invocation of opercmd

Once I find the version of the instance, I can compare it to the available version, and print a message if they do not match. This can then be repeated for every running instance in the registry directory. If the instance is not running, the opercmd will fail, and the script will move on to the next entry. A potential improvement for this script would be to identify the version from the information in the instance directory in the registry.

Python code showing console message parsing
angio@pkstnp8 ~> python3 zcx_versions.py -p /global/zcx_zos/instances                   
Looking for running zCX instances in directory /global/zcx_zos/instances
Instance ZCXTEST is version 1.16.5 (oa61559)
Instance ZCXPOC2 is version 1.16.1 (oa61436) and can be upgraded to 1.16.5 (oa61559)
Instance ZCXECO is version 1.16.1 (oa61436) and can be upgraded to 1.16.5 (oa61559)
Instance HWKLM1 is version 1.15.6 (oa60513) and can be upgraded to 1.16.5 (oa61559)

Writing this script was a fun exercise, and it showed me the power of using Python to parse z/OS console messages, as well as issuing operator commands from a script. I find that using modern tooling makes accomplishing tasks in z/OS a lot more convenient, while lowering the barriers to entry for new users.

--

--

Anthony Giorgio
Theropod

I’m a mainframe software engineer working at IBM.