The Simplest Script

Edit: Send me your scripts.

Originally posted October 13, 2015 on AIXchange

I was recently working with someone who had built some new LPARs. As part of the build out he decided his NIM server would make a good general purpose utility server. This NIM server would become a one-stop shop where he planned to stage fixes along with the base OS images he’d use to create his environment.

During the build out, he needed to get console access to servers so he could, for example, configure networking. That meant logging into the HMC and then running vtmenu. However, this extra step of logging into the HMC was taking too long.

He set it up so that he could ssh with keys to all of the LPARs in the environment, including the VIO servers and the HMCs from the NIM server. This became his central point of control. He could get anywhere by just logging into the NIM server first. (Obviously it then becomes critical to lock down NIM server access to prevent individual users from freely roaming this environment, but this can be accomplished easily enough.)

While these articles (herehere and here) note that vtmenu works fine for getting a console, it’s actually my preferred method of gaining console access. But why go to the hassle of logging into your HMC if you can just do it from your utility server?

Always interested in saving extra steps, my colleague went ahead and set up a simple script on his utility LPAR. Let me emphasize the word “simple” — this script is just a single line in /usr/local/bin:

    ssh -t hscroot@<hmc-ip-address> “vtmenu”

This works because he can log into the HMC without a password using his ssh keys. It brings him directly to the list of managed servers that you’d expect. From there, he can pick the frame and LPAR he wants to see. (Note: Of course, <hmc-ip-address> would need to be replaced with your actual HMC IP address for use in your environment.)

One way this could be further automated is to provide the capability to go through the script on the HMC /usr/hmcrbin/vtmenu and find different commands to run. For example:

    lssyscfg -r sys –Fname

      lssyscfg -m <machine name> -r lpar  -Fname

These commands would enable your own commands to run as they do in the script:

    mkvterm -m <machine name> -p <partition_name>

While further modifications weren’t needed in this case, I’d still like to see something that behaves this way. So if you’re willing to share your own time-saving scripts, I’d love to take a look. You may not consider your scripts to be suited for anything other than what you’re doing, but that’s not necessarily the case. We can all learn from one another.