Purpose
This script is to perform VIOS command as user ID padmin on one or multiple VIO servers remotely. It is very useful for managing several VIO servers and submitting batch job remotely.
Prerequisite:
1. Install the following packages from AIX Toolbox CD on the AIX server where you will run the dshvio script.
tcl-8.4.7-3.aix5.1.ppc.rpm
tk-8.4.7-3.aix5.1.ppc.rpm
expect-5.42.1-3.aix5.1.ppc.rpm
Note: Your version might be newer than the example sh0wn above.
2. Set up SSH key authentication between that AIX server and VIO servers.
On AIX server:
ssh-keygen -t dsa (press ENTER for all prompts)
On VIO Servers:
scp $HOME/.ssh/id_dsa.pub padmin@VIOserver:.ssh/authorized_keys2
3. Modify sshd parameter PermitUserEnvironment to “yes†on VIO Servers.
Log on to each VIO servers as padmin, then change to the root shell via oem_setup_env
Edit /etc/ssh/sshd_config
Change: PermitUserEnvironment no
To: PermitUserEnvironment yes
Refresh sshd :
stopsrc -s sshd
startsrc -s sshd
Now you are ready to use dshvio script below.
You can download the script here.
dshvio
#!/bin/ksh
# Created by Dean Rowswell, IBM, April 26, 2006
# Modified by Dean Rowswell, IBM, October 11, 2007
# Added a check for the -r flag for a root user command
# NOTE: this flag will require the expect RPM package to be installed
# Modified by Dean Rowswell, IBM, October 12, 2007
# Added a check for the -n flag to specify a single or multiple VIO servers
#
#——————————————————————————
# Assumption: this server is a trusted host for running ssh commands to
# the VIO server(s)
# To set this up:
# ssh-keygen -t dsa (press ENTER for all prompts)
# scp $HOME/.ssh/id_dsa.pub padmin@VIOserver:.ssh/authorized_keys2
#
# NOTE: if the VIO server responds with “rksh: ioscli: not found” then
# login to the VIO server and change to the root shell via oem_setup_env.
# Edit /etc/ssh/sshd_config
# Change: PermitUserEnvironment no
# To: PermitUserEnvironment yes
# Run: stopsrc -s sshd ; startsrc -s sshd
#——————————————————————————
#===========================================================#
# Define the list of VIO servers in this variable
#===========================================================#
VIOS=”vios1 vios3″
#===========================================================#
DisplayUsage() {
echo “Syntax: dshvio COMMAND\n Run dshvio -? for the valid parameters”
exit
}
if [ ${#*} -eq 0 ]
then
DisplayUsage
else
while getopts :rn: PARMS
do
case $PARMS in
r) lslpp -L|grep -w expect >/dev/null
if [ $? -ne 0 ]
then
echo “ERROR: cannot use -r flag because expect\
RPM package is not installed”
exit 1
else
ROOT=1
fi ;;
n) VIOS=${OPTARG}
VIOS=`echo ${VIOS}|sed ‘s/,/ /g’`;;
?) echo “Valid parameters are:\n -r for a root command\n\
-n for a list of VIO servers\n -n vios1\n -n vios1,vios2” ; exit ;;
esac
done
shift $(($OPTIND -1))
VIOSCMD=${*}
if [ ${#VIOSCMD} -eq 0 ]
then
DisplayUsage
fi
fi
for VIO in ${VIOS}
do
ping -c1 ${VIO} >/dev/null 2>/dev/null
if [ $? -eq 0 ]
then
echo “======================\nVIO server –> ${VIO}\n\
======================”
if [ ${ROOT:=0} -ne 1 ]
then
ssh padmin@${VIO} “ioscli ${VIOSCMD}”
else
expect -c “spawn ssh padmin@${VIO} ;expect \”\$\*\”;\
send \”oem_setup_env\\r\”;expect \”\#\*\”;send \”${VIOSCMD}\\r\”;\
send \”exit\\r\”;expect \”\$\*\”;send \”exit\\r\””|egrep -v “^spawn\
|^Last|oem_setup_env|^exit|^#”
fi
else
echo “===================\\nVIO server –> ${VIO}\n\
===================”
echo “VIO server: ${VIO} is not responding”
fi
done
Syntax:
root@coenim:/:# dshvio -?
Valid parameters are:
-r for a root command
-n for a list of VIO servers
-n vios1
-n vios1,vios2
Examples:
A regular VIOS command:
root@coenim:/:# dshvio ioslevel
=========================
VIO server –> coevios1
=========================
1.5.1.1-FP-10.1
=========================
VIO server –> coevios2
=========================
1.5.1.1-FP-10.1
An example of running a command through oem_setup_env automatically:
dshvio -r fget_config -Av
=========================
VIO server –> coevios1
=========================
—dar0—
User array name = ‘COE-DS4700’
dac0 ACTIVE dac1 ACTIVE
Disk DAC LUN Logical Drive
hdisk2 dac1 0 coenim_nim
hdisk3 dac1 1 coesap01_disk1
=========================
VIO server –> coevios2
=========================
—dar0—
User array name = ‘COE-DS4700’
dac0 ACTIVE dac1 ACTIVE
Disk DAC LUN Logical Drive
hdisk2 dac1 0 coenim_nim
hdisk3 dac1 1 coesap01_disk1
And here’s a command that I ran in my environment:
./dshvio.ksh -r “lscfg | grep disk”
=========================
VIO server –> vios1
=========================
vios1:/home/padmin # oem_setup_env
+ hdisk0 U787F.001.DPM1XRD-P1-T10-L3-L0 16 Bit LVD SCSI
Disk Drive (73400 MB)
+ hdisk1 U787F.001.DPM1XRD-P1-T10-L4-L0 16 Bit LVD SCSI
Disk Drive (73400 MB)
+ hdisk2 U787F.001.DPM1XRD-P1-T10-L5-L0 16 Bit LVD SCSI
Disk Drive (73400 MB)
=========================
VIO server –> vios3
=========================
vios3:/home/padmin # oem_setup_env
* hdisk0 U787F.001.DPM1XRD-P1-C1-T1-W5005076801103022-L0
MPIO Other FC SCSI Disk Drive
* hdisk1
U787F.001.DPM1XRD-P1-C6-T1-W5005076801202FFF-L1000000000000 MPIO
Other FC SCSI Disk Drive
* hdisk2 U787F.001.DPM1XRD-P1-C6-T1-W5005076801202FFF-
MPIO Other FC SCSI Disk Drive
This means that I can run commands across all of my VIO servers from my AIX machine, in either the padmin or oem_setup_env environment when I specify the -r option.