Zowe CLI extensions enable workload automation
{Ecosystem}
Have you already experienced the power of the The Open Mainframe Project’s Zowe Command Line Interface (CLI)? In this blog, I’ll show you how to use Zowe CLI to create scripts that can fully automate some of your typical, repetitive job scheduling activities, eliminating manual effort and even reducing the potential for errors.
In general, a Command Line Interface offers the ability to concatenate commands in scripts to execute multi-step actions. These scripts can have variable substitution, use additional script functions (grep, awk, etc.) to build powerful productivity tools.
I know that there are Zowe CLI users that use it interactively to manage z/OS resources like dataset, job and so on, other users that leverage it in a more advanced way to perform multi-step actions within a script, that is launched automatically if an event is caught.
Let’s now think to job scheduling on mainframe, every mainframe customer has a job scheduler in their production environment. It can be a homegrown solution or a commercial product, and can range from being simple, complex to very advanced. IBM has provided a solution for decades under different names. The product is currently named IBM Z Workload Scheduler. There are users of this product that still refer to it using the original name, OPC (Operations, Planning & Control), indeed even if it is an long lived IBM product, it continues to evolve and be modernized to fit user needs and new expectations.
In order to allow IBM Z Workload Scheduler users to easily automate actions on job scheduling in a script, back in April 2020 the product was enhanced with the extension of the Zowe Command Line Interface (CLI) with a “workload automation” group of commands. If you want to know more about it, take a look here.
In this blog, I will go through a scenario that leverages IBM Z Workload Scheduler extension of the Zowe CLI to manage job and jobstream submission and monitoring … and more! In the description, I will use the command line interface interactively, but obviously it is not limited to this kind of use, as mentioned above, possibly the real power is to concatenate the different commands in a script to have a real automation of the worklflow.
There are many users that already leverage the Zowe CLI, however I thought that could be useful to have this blog to show a Workload Scheduler scenario step by step.
Zowe CLI with workload-automation group of commands
I installed the Zowe CLI and the Workload Automation plugin … (also available on npm) so if I issue the following command: I get the online help and I can see the “workload-automation” group of commands:
zowe -h
To see what commands are available as part of workload-automation group, I can leverage again the online help:
zowe wa -h or zowe workload-automation — help
I could iterate with the online help for each command to drill down on the different commands, their parameters and so on, but I find more consumable to open the web help where I can find all the commands available for Zowe CLI, easy to navigate. So I issue the following command
zowe wa –help-web
The page opened is easy to navigate, it includes the options available for each command
and even examples that can be easily copied and customized:
Submit a jobstream Scenario
In this scenario, I leverage a simple jobstream (called DEMOZOWE), that includes 3 jobs (Zowe1, Zowe2 and Zowe3) each one dependent on the previous one, so the execution of Zowe2 will start when and only if the execution of Zowe1 is completed successfully and the execution of Zowe3 will start when and only if the execution of Zowe2. The following diagram illustrates this point — it comes from the Dynamic Workload Console (IBM Z Workload Scheduler web UI).
ZOWE2 JCL has an error in it, it is made on purpose to have the job failing.
We can check the presence of the jobstream in the IZWS model through the following command:
zowe wa list jobstreaminmodel — name DEMOZOWE
As you can see from the screen capture, wildcards are supported for the jobstream name as well as for many other options. So the jobstream is in the model, we need to add it to the current plan to have it submitted by IZWS. To take this action we can leverage the following command:
zowe wa submit jobstreaminplan — name DEMOZOWE
the command output is the jobstream ID in the current plan
The jobstream ID is needed to check the status of the jobstream, objective that we can achieve through the following command:
zowe wa list jobstreaminplan — name DEMOZOWE
As expected, the status of the jobstream is “ERROR” … let’s investigate what is causing the failure of the jobstream execution thought the visualization of the job status. We can leverage the following command for this step:
zowe wa list jobinplan — jobname ZOWE*
The output of the command shows that ZOWE1 job completed successfully, while ZOWE2 job completed in error … that takes ZOWE3 in WAITING status since it is waiting for ZOWE2 successful competition.
At this point, we can fix the problem on ZOWE2 job and once the problem is fixed, it is possible to change the status of the job directly from the Zowe CLI with the following command:
zowe wa set-status jobinplan — id <<ZOWE2ID>> — status complete
where the job ID for Zowe 2 can be retrieved from the previous command.
At this point we can check again the status of the job with the same command we used earlier and we will see that all the job completed successfully, including ZOWE3 since its execution was un-blocked by the success of Zowe2:
One more confirmation comes from the command to list the jobstream in plan, that now shows DEMOZOWE jobstream completed successfully:
Other workload-automation commands
Another command available from workload-automation group of command is the get command, that allows the user to get information about job and other resources in the plan:
Leveraging the data we used for the scenario above, we can get the detailed information for Zowe2 job with the following command:
zowe wa get jobinplan — id <<ZOWE2ID>>
It will return the detailed information of the job.
We can see that the “description” attribute of the job is empty, let’s assign to it a value through the update command of workload-automation group:
The command we will issue is:
zowe wa update jobinplan — id <<ZOWE2ID>> — des “job for zowe demo”
Issuing again the get command, we can see the description attribute updated:
Wrap-up
What was showed in the scenario is obviously a minimal part of the power of the IBM Z Workload Scheduler extension, there is no limit on how many scenarios can be implemented, how much automation you can achieve levering the workload-automation group of command in Zowe. As mentioned at the beginning, the power of the Zowe CLI is not just the individual commands but the ability to write scripts (in the scripting language of your choice) to build multi-step actions to automate IZWS or any other product with Zowe CLI extensions. These scripts can have variable substitution, use additional script functions (grep, awk, etc.) to build powerful productivity tools. I am aware of users that leverage this set of command to reply automatically to ticket that are submitted to add a job to a plan, monitor the status and close the ticket. Other possible scenarios include the possibility to make massive changes to your jobs, changes triggered by a system movement and so on, massive changes that, based on a user feedback, are becoming more and more frequent.
An important point to make is that customer that leverage IBM Z Workload Scheduler, get IBM Z Distribution for Zowe as supporting program, so the support (for the scenarios that are related to the integration) is granted from IBM at no charge. It is important because many enterprises do not accept to have un-supported software in their production environment.
If you want to learn more about IBM Z Distribution for Zowe, visit the content page, you can find there other details about IBM product extensions and more.
If you want to download the IBM Z Workload Scheduler extension for the Zowe CLI, go to the Automation Hub.
This blog was originally posted on AIOps on IBM Z Community, here. Join today for the latest: http://ibm.biz/AIOpsCommunity
#zowe #opensource #IBMz #scheduling
Learn more:
If you enjoyed this blog check out more Zowe blogs here. Or, ask a question and join the conversation on the Open Mainframe Project Slack Channel #zowe-client-sdk, #zowe-cli, #zowe-dev, #zowe-user, or #zowe-onboarding. If this is your first time using the Open Mainframe Slack Channel register here.
To learn more about IBM Z solutions that can help improve system management, IT operations, application performance, and operational resiliency with AI, visit our product portfolio page.
Zowe is owned and managed by the Open Mainframe Project, which is a Linux Foundation project.