IBM Support

Make An LPAR Tool = malt

How To


Summary

Here is a suite of files to create an LPAR on an IBM Power System without using the HMC GUI. There are shell scripts and configuration files.

You need to make changes to suit your particular environment. I'd say that the chance of them working on your systems without such modifications is nil.

A tar file is available for download in the "Attachment" section at the bottom of this page.

Objective

image 7832

It is assumed that you are familiar with shell scripting (ksh) and with the general terminology used when discussing IBM Power Systems.
All of this material is provided "as-is". IBM and I cannot take any responsibility if you use the code and it doesn't do exactly what you expect.
My original motivation for developing the suite was when I was working on a particular project. To access the HMCs from my desktop, network packets had to go through several firewalls using a complicated WAN. There were many LPARs on numerous Enterprise Class systems and many users of the HMCs' GUIs. The HMCs were busy and paging was happening. The result was a slow network connection; both low bandwidth and more importantly, high latency! It could easily take over 5 minutes to fill in the HMC pages and create the LPAR, even when all of the properties were already defined and I just had to complete the forms. Then, I had to use DLPAR to add virtual adapters to the VIOSes and edit the VIOSes' profiles.
Using "malt", I could achieve all of the steps in under 30 seconds. Sometimes, I was tasked with creating several (maybe 10) LPARs with similar configurations but with different LPARid numbers, you can imagine the time which the scripting saved.
I found that improvements to the HMC and new powerful products like PowerVC and the "LPAR Provisioning Toolkit" took over from malt, so I did not post my utility. Recently, several customers have asked for access to it, so here it is.
I understand that it has some limitations, but it is what it is. I am not doing any more development on it. If people extend it, for example to use SSP storage, and let me have the code, I'll consider posting it here.

Environment

The files are deployed on a suitable OS environment, such as AIX or Linux. The AIX userid does not need to be root, but does need to be able to ssh commands to the HMC without being challenged for a password. The HMC userid does need to have permission to create LPARs and edit the VIOS profiles etc, so an hmcsuperadmin such as hscroot is ideal.
There is guidance on setting up and exchanging ssh keys here: <URL FOR BLOG ENTRY - IT ISN'T THERE YET. I SHALL UPDATE THIS PAGE WHEN IT IS.>
There are some fundamental assumptions including:
  • Dual VIO Servers, each providing virtual networking, and storage
  • The virtual socket number for the vhost in the VIOS is the same as the LPARid of the client
  • No physical devices in the client LPAR
You can alter the configuration files to suit your environment. In fact, it is necessary to make some changes. Some of these changes  only need to be made once (for example the LPARid of the VIOSes), others are made for each LPAR you make (for example the LPARid).
If your Power System is managed by a redundant HMC, as soon as the LPAR is created, the second HMC "sees" the new LPAR too.
It is fairly straightforward to extend (for example add more networks) or simplify (for example use a single VIOS).  The tricky part tends to be using the correct number of backslashes to "quote" various parts of the HMC commands.  You simply need to follow the patterns in my scripts.
Ensure that when a backslash is used to continue a command on the following line, the backslash must be the final character on the line, no trailing white space.

Steps

Here is a list of the files:
bkprofiles              a script to backup profile data from a Power System to its HMC
chprof_vios             a script to add the virtual adapters into the VIO Servers
chprof_vios.npiv        a script to add the virtual adapters into the VIO Servers
config                  the main configuration file to drive malt
dlpar_vios              a script to dlpar the virtual adapters into the VIO Servers
dlpar_vios.npiv         a script to dlpar the virtual adapters into the VIO Servers
malt                    the main program
malt.npiv               the main program
mklpar_client_2vio      a script to create an LPAR
mklpar_client.npiv      a script to create an LPAR
README.malt             this file
Here is a flow diagram:
malt flow diagram
Each time that malt is run, it calls bkprofiles, which takes a backup of all of the profiles of all of the LPARs. The backup is saved to the HMC in the normal way by using the bkprofdata command:
###############################################################
#                                                             #
#        NB THIS IS TO BE USED AT YOUR OWN RISK, SUPPLIED     #
#        "AS-IS" WITH NO WARRANTY, EXPRESS OR IMPLIED.        #
#                                                             #
#     Written by Gareth Coates gaz@uk.ibm.com (c) IBM 2012    #
#                                                             #
#     part of the "malt" suite and requires the config file   #
#                                                             #
###############################################################
#
# a script to backup profile data from a Power System box to its HMC
#
# this program is called from "malt" and requires the config file

DATE=`date +%d%b%Y_%T`
set -a

ssh hscroot@${HMC} "

bkprofdata -m ${MACH} -f ${MACH}-${DATE}

"
The config file is where you set up the properties of the LPAR to be created. The file is "sourced" and so does not need execute permission.
At the top are the variables that usually need to be changed:
###############################################################
#                                                             #
#        NB THIS IS TO BE USED AT YOUR OWN RISK, SUPPLIED     #
#        "AS-IS" WITH NO WARRANTY, EXPRESS OR IMPLIED.        #
#                                                             #
#     Written by Gareth Coates gaz@uk.ibm.com (c) IBM 2012    #
#                                                             #
#      part of the "malt" suite - This is the config file     #
#                                                             #
###############################################################
#

##########################################
#                                        #
# USUALLY NEED TO CHANGE THESE VARIABLES #
#                                        #
##########################################

HMC=hmc16               # the name or IP address of the HMC
MACH=P9-S922-amber      # the name of the system
CLIENTID=107            # the numeric id of the client LPAR
LPARNAME=vm107-malt     # the name of the LPAR to create
CLIENTPROF=normal       # the name of the profile on the client
MINMEM=512              # minimum memory to configure in the client (MB)
DESMEM=768              # desired memory to configure in the client (MB)
MAXMEM=1024             # maximum memory to configure in the client (MB)
MINPROCUNITS=0.2        # minimum processing units (CE) in the client
DESPROCUNITS=0.5        # desired processing units (CE) in the client
MAXPROCUNITS=1.8        # maximum processing units (CE) in the client
MINPROCS=1              # minimum number of Virtual Processsors in the client
DESPROCS=1              # desired number of Virtual Processsors in the client
MAXPROCS=2              # maximum number of Virtual Processsors in the client
WEIGHT=100              # the uncapped weight of the client
The variables should be self-explanatory.
Then, some variables which you typically only need to set once for your particular environment:
###########################################
#                                         #
#      SET THE VARIABLES BELOW HERE       #
#          FOR YOUR ENVIRONMENT           #
# THEN USUALLY DON'T NEED TO CHANGE THEM  #
#                                         #
###########################################

SERVERID_0=2            # the ID of the 1st VIO server
SERVERID_1=3            # the ID of the 2nd VIO server
SERVERPROF=default_profile      # the name of the profile on VIO server
SERVERSLOT=${CLIENTID}  # the slot for the v.scsi server - usually = $CLIENTID
MAXVSLOTS=200           # the maximum number of virtual slots in the client

# VIRTUAL SCSI STUFF

S0SLOT=11               # the slot for the 1st v.scsi adapter in the client
S0REQ=1                 # is it required?

S1SLOT=12               # the slot for the 2nd v.scsi adapter in the client
S1REQ=1                 # is it required?

# VIRTUAL ETHERNET STUFF

E0SLOT=2                # The adapter nos are not necessarily the same in AIX
E0PVID=62               # the PVID of this adapter
E0TRUNK=0               # 0=no _OR_ 1-15 implies yes and gives the priority
E0REQ=1                 # 0=no _OR_ 1=yes

E1SLOT=4                # The adapter nos are not necessarily the same in AIX
E1PVID=104              # the PVID of this adapter
E1TRUNK=0               # 0=no _OR_ 1-15 implies yes and gives the priority
E1REQ=1                 # 0=no _OR_ 1=yes

E2SLOT=5                # The adapter nos are not necessarily the same in AIX
E2PVID=105              # the PVID of this adapter
E2TRUNK=0               # 0=no _OR_ 1-15 implies yes and gives the priority
E2REQ=1                 # 0=no _OR_ 1=yes

E3SLOT=6                # The adapter nos are not necessarily the same in AIX
E3PVID=106              # the PVID of this adapter
E3TRUNK=0               # 0=no _OR_ 1-15 implies yes and gives the priority
E3REQ=1                 # 0=no _OR_ 1=yes
Again, these should be easy to understand.
Finally, we set up a shell function to request confirmation:
# define the yesno function
yesno(){
while :
do
        echo "
        Do you want to continue [yYnN] ? \c"
        read ANS

        case $ANS in

                y|Y)    echo YES; break;;
                n|N)    exit ;;
                *)      echo "  valid options are yYnN";;
        esac
done

}
The main program, malt for vSCSI storage or malt.npiv for vFC storage, sources the configuration file defined as $1 or defaults to config. It checks that it is you want to continue:
#!/usr/bin/ksh

###############################################################
#                                                             #
#        NB THIS IS TO BE USED AT YOUR OWN RISK, SUPPLIED     #
#        "AS-IS" WITH NO WARRANTY, EXPRESS OR IMPLIED.        #
#                                                             #
#     Written by Gareth Coates gaz@uk.ibm.com (c) IBM 2012    #
#                                                             #
#     part of the "malt" suite and requires the config file   #
#                                                             #
###############################################################

VERSION=0.7

SMSO=$(tput smso)
RMSO=$(tput rmso)

# a program to make the creation of a VIO client LPAR easier.
#
# 1st the profile data is backed up. If this fails, the script exits
# 2nd virtual scsi adapters are added to the profiles of the VIO servers
# 3rd virtual scsi adapters are added to the running LPARS using DLPAR
# 4th the client LPARs are created
#
# the default configuration file is ./config
#
# an alternative config file can be specified on the command line as $1

echo
echo "${SMSO}  Make An LPAR Tool               Version: ${VERSION}  ${RMSO}"
echo

# set the config file to be $1 or default back to ./config

CONFIG=${1}
CONFIG=${CONFIG:=./config}

# tell ksh to export all variables

set -a

# source the config file to set variables

. $CONFIG

# check that we should do it

echo
echo "Running \"yesno\" using \"${CONFIG}\" as the config file?"

yesno
Assuming that you continue, it calls
  • bkprofiles to take the backup
  • chprof_vios to modify the VIOSes' profiles
  • dlpar_vios to add the virtual adapters to the VIOSes
  • mklpar_client_2vio to define the LPAR
# run the various programs

# backup the profiles

echo Backing up the profile definitions - exit if it fails

./bkprofiles || exit 99

# add virtual scsi adapters to the profiles of the VIO servers

echo Adding virtual scsi adapters to the profiles of the VIO servers

./chprof_vios

# add virtual scsi to VIO servers using DLPAR

echo Adding virtual scsi adapters to VIO servers using DLPAR

./dlpar_vios

# make the client lpar

echo Making the client LPAR

./mklpar_client_2vio
If you are using virtual Fibre Channel, then similar code is used for NPIV:
$ diff malt malt.npiv
69c69
< ./chprof_vios
---
> ./chprof_vios.npiv
75c75
< ./dlpar_vios
---
> ./dlpar_vios.npiv
81c81
< ./mklpar_client_2vio
---
> ./mklpar_client.npiv
Here is the chprof_vios file:
###############################################################
#                                                             #
#        NB THIS IS TO BE USED AT YOUR OWN RISK, SUPPLIED     #
#        "AS-IS" WITH NO WARRANTY, EXPRESS OR IMPLIED.        #
#                                                             #
#     Written by Gareth Coates gaz@uk.ibm.com (c) IBM 2012    #
#                                                             #
#     part of the "malt" suite and requires the config file   #
#                                                             #
###############################################################
#
# a script to add the virtual adapters into the VIO Servers
#

set -a
ssh hscroot@${HMC} "

        echo starting 1st server

        chsyscfg -r prof                                \
                -m ${MACH}                              \
                -i                                      \
                \"name=${SERVERPROF},                   \
                lpar_id=${SERVERID_0},                  \
                virtual_scsi_adapters+=\"               \
                ${SERVERSLOT}/server/${CLIENTID}//${S0SLOT}/1\"\"

        echo starting 2nd server

        chsyscfg -r prof                                \
                -m ${MACH}                              \
                -i                                      \
                \"name=${SERVERPROF},                   \
                lpar_id=${SERVERID_1},                  \
                virtual_scsi_adapters+=\"               \
                ${SERVERSLOT}/server/${CLIENTID}//${S1SLOT}/1\"\"
        "
Again the version for vFC is similar:
$ diff chprof_vios chprof_vios.npiv
27,28c27,28
<               virtual_scsi_adapters+=\"               \
<               ${SERVERSLOT}/server/${CLIENTID}//${S0SLOT}/1\"\"
---
>               virtual_fc_adapters+=\"                 \
>               ${SERVERSLOT}/server/${CLIENTID}//${S0SLOT}//1\"\"
37,38c37,38
<               virtual_scsi_adapters+=\"               \
<               ${SERVERSLOT}/server/${CLIENTID}//${S1SLOT}/1\"\"
---
>               virtual_fc_adapters+=\"                 \
>               ${SERVERSLOT}/server/${CLIENTID}//${S1SLOT}//1\"\
... and here is the dlpar_vios file:
###############################################################
#                                                             #
#        NB THIS IS TO BE USED AT YOUR OWN RISK, SUPPLIED     #
#        "AS-IS" WITH NO WARRANTY, EXPRESS OR IMPLIED.        #
#                                                             #
#     Written by Gareth Coates gaz@uk.ibm.com (c) IBM 2012    #
#                                                             #
#     part of the "malt" suite and requires the config file   #
#                                                             #
###############################################################
#
# a script to dlpar the virtual adapters into the VIO Servers
#

set -a

ssh hscroot@${HMC} "

# set -xv

        echo starting 1st VIO server

        chhwres -r virtualio                    \
                --rsubtype scsi                 \
                -m ${MACH}                      \
                -o a                            \
                --id ${SERVERID_0}              \
                -s ${SERVERSLOT}                \
                -a                              \
                \"adapter_type=server,          \
                remote_lpar_id=${CLIENTID},     \
                remote_slot_num=${S0SLOT}\"

        echo starting 2nd VIO server

        chhwres -r virtualio                    \
                --rsubtype scsi                 \
                -m ${MACH}                      \
                -o a                            \
                --id ${SERVERID_1}              \
                -s ${SERVERSLOT}                \
                -a                              \
                \"adapter_type=server,          \
                remote_lpar_id=${CLIENTID},     \
                remote_slot_num=${S1SLOT}\"

"
The vFC version has minor variations:
$ diff dlpar_vios dlpar_vios.npiv
24c24
<               --rsubtype scsi                 \
---
>               --rsubtype fc                   \
37c37
<               --rsubtype scsi                 \
---
>               --rsubtype fc                   \
47c47
< "
---
> "
Finally, here is the mklpar_client_2vio file:
###############################################################
#                                                             #
#        NB THIS IS TO BE USED AT YOUR OWN RISK, SUPPLIED     #
#        "AS-IS" WITH NO WARRANTY, EXPRESS OR IMPLIED.        #
#                                                             #
#     Written by Gareth Coates gaz@uk.ibm.com (c) IBM 2012    #
#                                                             #
#     part of the "malt" suite and requires the config file   #
#                                                             #
###############################################################
#
# a script to create an LPAR
#

ssh hscroot@${HMC} "
      mksyscfg -r lpar -m ${MACH} -i \"         \
\\\"virtual_scsi_adapters=${S0SLOT}/client/${SERVERID_0}//${SERVERSLOT}/${S0REQ},       \
                        ${S1SLOT}/client/${SERVERID_1}//${SERVERSLOT}/${S1REQ}\\\",     \
        \\\"virtual_eth_adapters=${E0SLOT}/0/${E0PVID}//${E0TRUNK}/${E0REQ},            \
                               ${E1SLOT}/0/${E1PVID}//${E1TRUNK}/${E1REQ},              \
                               ${E2SLOT}/0/${E2PVID}//${E2TRUNK}/${E2REQ},              \
                               ${E3SLOT}/0/${E3PVID}//${E3TRUNK}/${E3REQ}\\\",          \
        name=${LPARNAME},                       \
        lpar_id=${CLIENTID},                    \
        lpar_env=aixlinux,                      \
        work_group_id=none,                     \
        shared_proc_pool_util_auth=0,           \
        power_ctrl_lpar_ids=none,               \
        boot_mode=norm,                         \
        auto_start=0,                           \
        profile_name=${CLIENTPROF},             \
        min_mem=${MINMEM},                      \
        desired_mem=${DESMEM},                  \
        max_mem=${MAXMEM},                      \
        proc_mode=shared,                       \
        min_proc_units=${MINPROCUNITS},         \
        desired_proc_units=${DESPROCUNITS},     \
        max_proc_units=${MAXPROCUNITS},         \
        min_procs=${MINPROCS},                  \
        desired_procs=${DESPROCS},              \
        max_procs=${MAXPROCS},                  \
        sharing_mode=uncap,                     \
        uncap_weight=${WEIGHT},                 \
        io_slots=none,                          \
        lpar_io_pool_ids=none,                  \
        max_virtual_slots=${MAXVSLOTS},         \
        boot_mode=norm,                         \
        conn_monitoring=0,                      \
        auto_start=0,                           \
        power_ctrl_lpar_ids=none                \
        \"
"
I have tried to format the files so that they are easy to understand and more importantly, easy to modify to suit a particular environment.
Let's run malt:
image 7833
As you can see, the whole process took less than 12 seconds.

Additional Information

You can contact me: 

Document Location

Worldwide

Operating System

Power:All operating systems listed

Here is a tar file with all of the files. It uses relative path names.
malt0.7.tar   30720 bytes
$ tar tvf malt0.7.tar
-rw-r--r-- 0   0      588 15 Jan 01:42:30 2021 ./README.malt
-rwxr-xr-x 0   0      879 15 Jan 01:27:43 2021 ./bkprofiles
-rwxr-xr-x 0   0     1194 15 Jan 01:37:34 2021 ./chprof_vios
-rwxr-xr-x 0   0     1193 15 Jan 11:13:39 2021 ./chprof_vios.npiv
-rw-r--r-- 0   0     3674 15 Jan 10:35:47 2021 ./config
-rwxr-xr-x 0   0     1272 15 Jan 11:17:31 2021 ./dlpar_vios
-rwxr-xr-x 0   0     1269 15 Jan 11:17:15 2021 ./dlpar_vios.npiv
-rwxr-xr-x 0   0     2029 15 Jan 10:05:01 2021 ./malt
-rwxr-xr-x 0   0     2039 15 Jan 09:56:26 2021 ./malt.npiv
-rwxr-xr-x 0   0     1941 15 Jan 01:31:23 2021 ./mklpar_client_2vio
-rwxr-xr-x 0   0     1753 15 Jan 10:19:38 2021 ./mklpar_client.npiv

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"HW1A1","label":"IBM Power Systems"},"Component":"","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF050","label":"BMC"},{"code":"PF041","label":"HMC"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
27 April 2021

UID

ibm16404542