IBM Z and LinuxONE - IBM Z

IBM Z

The enterprise platform for mission-critical applications brings next-level data privacy, security, and resiliency to your hybrid multicloud.

 View Only

Bringing Command Line AI to z/OS Unix System Services

By Dan FitzGerald posted Fri October 30, 2020 09:43 AM

  

Michael Gildein contributed to this article.

The promise of general Artificial Intelligence (AI) has wide-reaching implications.  In an effort to apply AI to solve tangible domain-specific problems, IBM Research has been working on applying AI techniques to software development tasks under the "AI4Code" initiative.  The Command Line AI (CLAI) framework has been created as an open-source project that aims to bring the power of AI to the command line.  This framework enables various plug-ins (known as "skills") to be deployed to the Bash terminal, allowing a developer or administrator to be more productive and to learn new skills in line with their tasks.

The core CLAI team has provided a few starter skill plug-ins as examples:

  • The "fixit" skill helps correct issues with the previously entered command
  • The "helpme" skill responds to standard errors with relevant Stack Overflow posts
  • The "howdoi" skill searches Stack Overflow for relevant answers
  • The "man page explorer" skill answers your question with a relevant man page
  • The "nlc2cmd" skill suggests commands based on a natural language description
Examples of traditional CLAI plugins that would be run from an x86-based BASH session
The IBM Z Advanced Technology Team (zATT) recently ported CLAI to run on z/OS Unix System Services (USS), introducing new z/OS-centric skills and functionality.  This work included creating new skills targeted at USS users, modifying the behavior of some of the existing CLAI skills (helpme, nlc2cmd), and disabling on USS other skills that could not yet be ported (fixit, howdoi, man page explorer).

New Skills for Z

The ability to create new skills with CLAI presents z/OS developers with exciting opportunities to improve the USS end-user experience.  Particularly fertile ground are those areas related to providing online help in real-time.

linuss

A frequent problem experienced by new USS users is that many of the commands they may be familiar with from Linux don't exist in the same form on USS.  linuss, "the Linux to USS plugin", serves to bridge that gap.

This new CLAI skill uses a set of predefined equivalences found by comparing the man pages of common Linux commands against those of USS.  Whenever a command is entered on USS, the equivalences are checked and are suggested to the user if detected. Suggestions can range from an equivalent flag up to an entire command replacement.

Example of a USS user employing "linuss" skill on z/OS Unix System Services
Example of a z/OS Unix System Services user employing the "linuss" skill

zmsgcode

IBM Z error messages can seem daunting to an end user.  The zmsgcode skill tries to make them friendlier by automatically displaying a descriptive help message whenever the console detects any IBM Z style message codes.

Here's how it works: whenever text comes back to the shell over the standard error stream, zmsgcode will see if any of it fits the pattern of the message codes standardized for all IBM Z operating systems and related products.  If so, and if there is a hexidecimal reason code included, zmsgcode will try to get a message description using the bpxmtext application.  If there is no reason code or if bpxmtext doesn't return a message, zmsgcode will try to search the USS publications on the z/OS KnowledgeCenter website and will return the first result encountered.

Example of a z/OS Unix System Services user employing the "zmsgcode" skill
Example of a z/OS Unix System Services user employing the "zmsgcode" skill

Existing Skills Made Better

helpme

In the helpme skill, standard error text produced on a command failure is searched against data from the Unix & Linux Stack Exchange forum to find an accepted answer that solves the issue, or the most highly rated answer in the case of an accepted answer being unavailable. This employs a simple index-based text search to identify the relevant Stack Exchange post and the corresponding answer.  The body of the result is then compared against available Linux manpages using a REST API from CLAI's man page explorer skill to recommend a relevant command to explore.

This feature has the potential to be incredibly helpful to USS users, as the proprietary and often esoteric nature of IBM Z can make it difficult to simply search the Internet for a solution to any problems that may arise.  But this fact also limits the usefulness of helpme in its original form: by searching the Unix & Linux Stack Exchange forums, helpme is likely to return information that doesn't apply to USS or z/OS.  To address this, our team expanded helpme's search functionality to default to the z/OS KnowledgeCenter when run from USS.  Specifically, standard error is sent as a query to the z/OS KnowledgeCenter API with the tags for the USS product applied.  USS publications are searched first, then Redbooks, then DeveloperWorks articles, and then finally Technotes.  Unlike the Stack Exchange search, this is very simplistic: the first result found in any KnowledgeCenter database query is the result used for the manpages comparison and eventually returned to the user.

Example of a z/OS Unix System Services user employing the "helpme" skill
Example of a z/OS Unix System Services user employing the "helpme" skill

nlc2cmd

nlc2cmd allows users to specify tasks in English and retrieve Linux command line syntax with the aid of Watson Assistant-based natural language classifiers.  To support USS, the core CLAI team at IBM Research created a new classifier with the ability to identify eleven different USS commands from a natural language description.  As a result, nlc2cmd can not only respond to USS-specific phrases like "copy file to pds member", but can also respond to phrases such as "edit a file" with suggested USS commands instead of their Linux counterparts.

Example of a z/OS Unix System Services user employing the "nlc2cmd" skill
Example of a z/OS Unix System Services user employing the "nlc2cmd" skill

Bringing the Power of AI to the Z Command Line

While the new skills are the flashiest part of the work that the zATT did with CLAI, they are far from all that we accomplished.  Our team worked on a number of low-level fixes to the base CLAI project, modified CLAI to be able install and run on USS, improved the overall CLAI installation process, added a new user installation option for non-root users, and disabled on USS any CLAI skills whose dependencies we could not port.  We feel that the end result is a powerful demonstration of the kinds of improvements that artificial intelligence can bring to USS, and hope that it will serve as a springboard for future work in applying AI to command-line interfaces on IBM Z and its operating system families.

Trying it out for yourself

The best part of using CLAI on z/OS is that anybody with their own Unix Systems Services ID can try it out for themselves! Here's how to do it:

  1. Make sure that your z/OS system has the following prerequisites; if not, you may need to contact your system administrator.  Software requirements are available either through IzODA or are downloadable from Rocket Software.

    1. Bash 4.3 or higher 

    2. Python 3.6 or higher 

    3. Git 

    4. The path to the env program is /usr/bin/env

      • If this is not the case, your system administrator will need to create a symbolic link: ln -s /bin/env /usr/bin/env

  2. If your environment is not already configured for Bash and Python:

    1. Configure your .profile

      export SHELL=path_to_bash
      exec $SHELL --login
    2. Configure your .bash_profile to launch $HOME/.bashrc

    3. Configure your .bashrc to add Python to system paths
      • Add Python to system paths

        export PYTHON_HOME=/path/to/python
        export LIBPATH=$PYTHON_HOME/lib:$LIBPATH
        export FFI_LIB=$PYTHON_HOME/lib/ffi
        export MANPATH=$PYTHON_HOME/share/man:$MANPATH
        export PKG_CONFIG_PATH=$PYTHON_HOME/lib/pkgconfig:$PYTHON_HOME/share/pkgconfig
        export CURL_CA_BUNDLE=$PYTHON_HOME/etc/ssl/cacert.pem

      • Respect file tags for ASCII/EBCDIC conversion
        export _BPXK_AUTOCVT=ON
        export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"

      • Set TERMINFO so that vi works properly:
        export TERMINFO=/usr/share/lib/terminfo

      • If your z/OS system employs multiple TCP/IP stacks, specify the name of the particular TCP/IP stack to be used
        export _BPXK_SETIBMOPT_TRANSPORT=TCP342
    4. Restart your shell (log out and then back in again)

  3. Clone the CLAI git repository:
    git clone git@github.com:IBM/clai.git

  4. Follow the notes in known-issues.md with regards to your Python configuration

  5. Install CLAI

    cd path_to_zclai_repository
    make clean
    • To have the CLAI server use the default port number of 8010:
      make install
    • If you wish to have CLAI use a specific port number:
      ./install.sh --user --port=8nnn
  6. Restart your shell

  7. Use CLAI!

    1. Issue clai skills to see what skills are available for USS

    2. Use clai activate skillname to activate a skill

    3. Use clai deactivate skillname to deactivate a skill

    4. Issue clai stop to stop the CLAI server, and clai start to start the CLAI server

  8. If you want to uninstall CLAI:

    cd path_to_zclai_repository
    make uninstall

Further Reading

About the Authors

Dan FitzGerald (danfitz@us.ibm.com) is a member of the IBM Z Advanced Technology Team, a highly adaptive and innovative team composed of cross-product, varied skill, band, and tenure software engineers working together to discover, explore, and prototype new technology innovations through incubator projects for IBM Z.  Dan comes from the z/VM ecosystem, where they spent several years first in z/VM CP (kernel) development and where they were later a member of the IBM Wave for z/VM product team.  Before joining the zATT, they worked on the IBM Z Hardware Management Console and were a part of the software tooling team for IBM's Sierra and Summit supercomputers.  They received a BA in Computer Science from SUNY Geneseo and an MS in Computer Science from Binghamton Unversity (SUNY).

Michael Gildein (megildei@us.ibm.com) is the z/OS Test Innovation Architect actively driving new automation, analysis, and initiatives to further increase quality and test efficiencies throughout the z/OS stack.  Michael has been working in the software test domain in various roles since 2010.  He has been a System Tester of multiple z/OS components, the Senior Manager of z/OS Test Services, a z/OS Test Architect, and the Chief Product Owner of the Continuous Regression and Testware squads.  Michael actively promulgates testing practices by teaching collegiate classes on software testing and systems analysis.  Some of Michael’s current areas of focus are applying data science and machine learning methodologies to the software development lifecycle data to increase quality and reliability.  He holds a BS in Computer Science from Penn State and an MS in Computer Science from Marist College, where he is currently an Adjunct Instructor of Computer Science.

0 comments
54 views

Permalink