Tuesday 19 March 2013

VIOS COMMAND LINE: UNDER THE COVERS


FROM root TO padmin: THERAPY FOR AIXers

When you log in to the VIO server as padmin, you are running the VIO server restricted shell. If you're a diehard AIX sysadmin who is frustrated by the VIOS command line, it can be difficult. Even a simple command like this:

lsdev -Ccdisk
 Gives you a Usage message like this:

Option flag is not valid.  # dang!

Usage: lsdev [-type DeviceType ...] [-virtual] [-state DeviceState]

[-field FieldName ...] [-fmt delimiter]

lsdev {-dev DeviceName | -plc PhysicalLocationCode} [-child]

[-field FieldName ...] [-fmt delimiter]

lsdev {-dev DeviceName | -plc PhysicalLocationCode} [-parent |

-attr [Attribute] | -range Attribute | -slot | -vpd]

Well, my friend, I feel your frustration and pain, so

let me unfrustrate you!



There are three ways of dealing with your VIOS CLI Aversion Disorder (VCAD).


  1. Read the documentation. VIOS command syntax is memorable, guessable and aesthetically pleasing
  2. View the underlying AIX commands  using CLI_DEBUG=33
  3. Upgrade to the full-blooded AIX command using oem_setup_env 

Allow Dr. Down Under to step you through each of these therapies.


Therapy 1: read the VIO doco (face your demons!) 

You could check the VIOS man pages and realise that VIOS commands are consistent, predictable and even elegant.


Make commands create or add something

  • mklv creates a logical volume
  • mklvcopy creates a mirror of a logical volume
  • mkpath adds another path to an MPIO capable device
  • mkvdev adds a virtual device to the system.


Change commands start with ch:

  • chdev changes the characteristics of a device
    • -dev for device name
    • -perm to make it permanent (or actually, postpone till the reboot)
    • -attr for an attribute
  • chpath changes the status of an MPIO device
  • chdate sets or displays the date, with flags that are easy to remember: How easy is that:
      -year
      Sets the year to YYyy.
      -month
      Sets the month to mm.
      -day
      Sets the day to dd.
      -hour
      Sets the hour to HH in 24-hour format.
      -minute
      Sets the minute to MM.
      -timezone
      Sets the time zone (for example, CST6CDT).

How easy is that? Makes you want to keep changing the time on your system, doesn’t it? It gets better:



List commands typically start with ls




A little annoying

Now, if you're used to the AIX lsdev and lsattr commands, those VIO server lsdev and chdev commands might be a little annoying. But once you understand the reasoning behind the flags, you’ll see the sense in it all:

  • -attr for attributes
  • -dev for device name (this is used EVERYWHERE on the VIOS command line)
  • -type to pick a device type, such as disk, adapter or even lv
 So you could change the health check interval of an MPIO disk using: 

chdev -dev hdisk5 -attr hcheck_interval=60 –perm 



And list the device attributes of hdisk5:


lsdev -dev hdisk5 -attr

The VIO CLI uses the Getopt::Long options. For example,

  • VIOS uses -dev when the AIX chdev command uses –l
  • VIOS uses -attr rather than AIX's –a


More typing, less checking

That makes for more typing, but less looking up. You can't always guess the flag for the AIX command, because when they want to put in a new flag, AIX has been around for so long, chances are it's often been used. List long user names, for example.


So the VIOS command line syntax is really worth learning, and it's all there in the VIOS documentation.You can see the VIOS commands listed alphabetically or by category (Devices, Installation, Logical volume, Virtual media and more). You should only need to read it once.


Therapy 2: Don't let the VIOS CLI bug you 

Did you know you can see what the AIX commands are running under the covers? Log in as padmin and enter:


export CLI_DEBUG=33

Here’s what the lsmap –all command really does:


lsmap -all|more 

AIX: "lsdev -c adapter -t IBM,v-scsi-host -s vdevice -F "name" | wc -l -c" 
AIX: "lsdev -c adapter -t IBM,v-scsi-host -s vdevice -F "name"" 
AIX: "lsdev -C -l vhost0 -F "physloc"" 
AIX: "lsdev -p vhost0 -F "name" | wc -l -c" 
AIX: "lsdev -p vhost0 -F "name"" 
AIX: "lsattr -E -l enim_cd0 -F "value" -a aix_tdev,LogicalUnitAddr"

And to configure new devices,


cfgdev 
AIX: "cfgmgr "   # Ha! I knew it!

Then you get the advantage of running the VIOS command but also seeing what it’s really doing (we like to know. This isn’t Windows, is it?)


Therapy 3: Take the escape hatch to AIX 

If the thought of a restricted shell is all too much, you can take the escape route by upgrading your shell to the full blown AIX using oem_setup_env

But you’re not supposed to! (unless you really, really have to)

Still, sometimes you want to leave the decaf skinny latte option to the people who are young enough to learn something new. I have even heard of some crusty old AIX admins who tailor the padmin .profile with

alias aix="oem_setup_env"

If you decide to run away at the first whiff of padmin danger, let me give you two pieces of advice:

  1. Make your padmin shell prompt more user friendly
  2. Don’t say I told you to 



No comments:

Post a Comment