はじめに
ZOAU(Z Open Automation Utilities)というフリーで利用できるツールがあります。このツールはz/OSの各種オペレーションをUSS(Unix System Service)上のシェルやPythonスクリプトから行うための仕組みを提供しています。つまり、z/OSの操作を行うためのシェルのコマンドやPython APIが提供されています。
これを利用することにより各種z/OS操作の自動化を行いやすくなります。実際にRed Hat Ansible Certified Content for IBM Zで提供されているモジュールはZOAUを前提に実装されています。
ここではZOAU V1.2.5.8をテスト環境のz/OS V2.5にインストールした時のログを残しておきます。
※この環境はPython 3.11がインストールされている前提です。
参考: Python for z/OS のインストール
インストール/構成手順例
基本的には以下の手順に従います。
Installing and configuring ZOAU
インストーラーのダウンロード
以下のサイトにアクセスします。
Download - IBM Enterprise DevOps
ZOAUの項目のdownloadのリンクをクリックしてインストーラーをPC上にダウンロードします。
ZFS作成
適当なサイズでzFSを作成し、USS上にZOAUのインストールディレクトリを作成しマウントしておきます。
zFSのサイズは15MB程度必要です。
インストールディレクトリは/usr/lpp/IBM/zoautilとします。
インストール
ダウンロードしたpax.Zファイルを上で作成したzFS上にバイナリ・モードで転送します。
[CICS004@EPLEX1:/V1R11/usr/lpp/IBM/zoautil] ls
zoau-1.2.5.8.pax.Z
paxコマンドを使用して同ディレクトリに解凍します。
[CICS004@EPLEX1:/V1R11/usr/lpp/IBM/zoautil] pax -ppx -rf zoau-1.2.5.8.pax.Z
展開されたディレクトリ、ファイルの確認
[CICS004@EPLEX1:/V1R11/usr/lpp/IBM/zoautil] ls -la
total 9184
drwxr-xr-x 10 0 CICS 8192 Apr 7 12:20 .
drwxr-xr-x 19 0 OMVSGRP 8192 Mar 25 14:12 ..
-rw-rw-rw- 1 0 CICS 0 Apr 7 12:20 .pax.Z
drwxr-xr-x 4 0 CICS 8192 Mar 26 11:54 LICENSES
-rw-r--r-- 1 0 CICS 358 Mar 26 11:04 README.txt
drwxr-xr-x 2 0 CICS 8192 Mar 26 11:04 bin
drwxr-xr-x 2 0 CICS 0 Mar 26 11:04 conf
drwxr-xr-x 3 0 CICS 8192 Mar 26 11:04 docs
drwxr-xr-x 2 0 CICS 8192 Mar 26 11:04 include
drwxr-xr-x 3 0 CICS 8192 Mar 26 11:54 lib
drwxr-xr-x 3 0 CICS 8192 Mar 26 11:04 samples
-rw-r----- 1 0 CICS 4032000 Apr 7 12:19 zoau-1.2.5.8.pax.Z
-rw-r--r-- 1 0 CICS 119842 Mar 26 11:46 zoautil_py-1.2.5.8-cp310-none-any.whl
-rw-r--r-- 1 0 CICS 90756 Mar 26 11:37 zoautil_py-1.2.5.8-cp311-none-any.whl
-rw-r--r-- 1 0 CICS 90953 Mar 26 11:29 zoautil_py-1.2.5.8-cp312-none-any.whl
-rw-r--r-- 1 0 CICS 119693 Mar 26 11:54 zoautil_py-1.2.5.8-cp39-none-any.whl
-rw-r--r-- 1 0 CICS 83497 Mar 26 11:54 zoautil_py-1.2.5.8.tar.gz
drwxr-xr-x 3 0 CICS 8192 Mar 26 11:54 zoautil_py-stubs
基本的なインストールとしてはpax.Zファイルを展開するだけでOK。
環境変数設定
以下の環境変数を設定します。(ユーザーの.profileなど)
export _BPXK_AUTOCVT=ALL
export ZOAU_HOME=/usr/lpp/IBM/zoautil
export PATH=$PATH:$ZOAU_HOME/bin
export LIBPATH=$LIBPATH:$ZOAU_HOME/lib
export MANPATH=$MANPATH:$ZOAU_HOME/docs/%L
zoaversionコマンドを実行してバージョン確認
[CICS004@EPLEX1:/u/cics004] zoaversion
2024/03/26 01:50:41 CUT V1.2.5.8 366c83be 5264 PH60332 1165 82cc154c
Python用構成
Python APIを使用するための構成を行います。
pax.Zファイルを展開すると、以下のwhlファイルが提供されます。
[CICS004@EPLEX1:/V1R11/usr/lpp/IBM/zoautil] ls -la | grep whl
-rw-r--r-- 1 0 CICS 119842 Mar 26 11:46 zoautil_py-1.2.5.8-cp310-none-any.whl
-rw-r--r-- 1 0 CICS 90756 Mar 26 11:37 zoautil_py-1.2.5.8-cp311-none-any.whl
-rw-r--r-- 1 0 CICS 90953 Mar 26 11:29 zoautil_py-1.2.5.8-cp312-none-any.whl
-rw-r--r-- 1 0 CICS 119693 Mar 26 11:54 zoautil_py-1.2.5.8-cp39-none-any.whl
利用環境のPythonのバージョンに応じて使用するwhlを選択します。今回の環境ではPython 3.11を使用しているので、"zoautil_py-1.2.5.8-cp311-none-any.whl"を使用します。
以下のように、"zoautil_py-1.2.5.8-cp311-none-any.whl"ファイルを指定してpip3コマンドにてZOAU Python APIをインストールします。
[CICS004@EPLEX1:/V1R11/usr/lpp/IBM/zoautil] pip3 install zoautil_py-1.2.5.8-cp311-none-any.whl
Processing ./zoautil_py-1.2.5.8-cp311-none-any.whl
Installing collected packages: zoautil-py
Successfully installed zoautil-py-1.2.5.8
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: There was an error checking the latest version of pip.
動作確認
/usr/lpp/IBM/zoautil/samples/python-samples/asynchronous-multiprocess/
以下に提供されているPythonのサンプル・スクリプト"multiprocess_mvscmd.py"を実行してみます。
[CICS004@EPLEX1:/V1R11/usr/lpp/IBM/zoautil/samples/python-samples/asynchronous-multiprocess] python multiprocess_mvscmd.py
CPU_COUNT=2
WORKERS=8
PROCESSES=10
mvscmd no. 1, waiting 1 seconds
mvscmd no. 2, waiting 2 seconds
mvscmd no. 4, waiting 4 seconds
mvscmd no. 3, waiting 3 seconds
mvscmd no. 5, waiting 5 seconds
mvscmd no. 6, waiting 0 seconds
mvscmd no. 7, waiting 1 seconds
mvscmd no. 8, waiting 2 seconds
Process 1 Finished.
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
mvscmd no. 9, waiting 3 seconds
Process 9 Finished.
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
Process 7 Finished.
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
Process 6 Finished.
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
Process 5 Finished.
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
Process 4 Finished.
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
Process 8 Finished.
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
Process 3 Finished.
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
Process 2 Finished.
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
[ZOAUResponse]
rc: 0
response_format: UTF-8
stdout_response:
stderr_response:
command: mvscmd --pgm=BPXBATCH
Pool of work is done
上のような出力がされて特にエラーが出ていなければOK。