Under Construction
Selections
The HMC manages users, LPARs, profiles and much more as resources. Each of these resources has a number of attributes. Each attribute has a name and zero, one or more values:
<attribute-name>=
<attribute-name>=<value>[,<value>…]
Each of these resources is ultimately represented by the HMC as a list of one or more such attributes. In most cases, there are several resources of one type. The LPAR tool commands for displaying such a resource type show all resources of this type without any further arguments, e.g. HMC users:
$ hmc lshmcusr hmc01
NAME DESCRIPTION TASKROLE RESOURCEROLE
lawrence Jennifer Lawrence hmcviewer ALL:
bacon Kevin Bacon hmcviewer ALL:
lopez Jennifer Lopez hmcsuperadmin ALL:
root root hmcsuperadmin ALL:
costner Kevin Costner hmcviewer ALL:
hscroot HMC Super User hmcsuperadmin ALL:
johansson Scarlett Johansson hmcoperator ALL:
baldwin Adam Baldwin hmcsuperadmin ALL:
$
Especially in cases where the output is longer, you want the possibility to make a selection to display only certain resources. This can be achieved by specifying selections. A selection has one of the following forms:
<attribute-name>=<value>
matches resources where the specified attribute has the specified value
example: name=lopez
<attribute-name>~<regexp>
matches resources where the specified attribute matches the specified regular expression
example: description~[CLJ]o
<attribute-name>!=<value>
matches resources where the specified attribute does not have the specified value
example: name!=lopez
<attribute-name>!~<regexp>
matches resources where the specified attribute does not match the specified regular expression
example: description!~[CLJ]o
<attribute-name>:eq:<number>
matches resources where the specified attribute has a numeric value equal to the specified number
example: maxage:eq:180
<attribute-name>:ne:<number>
matches resources where the specified attribute has a numeric value not equal to the specified number
example: maxage:ne:180
<attribute-name>:ge:<number>
matches resources where the specified attribute has a numeric value greater than the specified number
example: maxage:ge:180
<attribute-name>:gt:<number>
matches resources where the specified attribute has a numeric value greater or equal than the specified number
example: maxage:gt:180
<attribute-name>:le:<number>
matches resources where the specified attribute has a numeric value less or equal than the specified number
example: maxage:le:180
<attribute-name>:lt:<number>
matches resources where the specified attribute has a numeric value less than the specified number
example: maxage:lt:180
All commands of the LPAR tool that produce resource output, support the option “-s” for specifying selections. Here again using the example of “hmc lshmcusr”:
$ hmc lshmcusr -s taskrole=hmcsuperadmin hmc01
NAME DESCRIPTION TASKROLE RESOURCEROLE
lopez Jennifer Lopez hmcsuperadmin ALL:
root root hmcsuperadmin ALL:
hscroot HMC Super User hmcsuperadmin ALL:
baldwin Adam Baldwin hmcsuperadmin ALL:
$
The option “-s” with argument must be specified before the keyword “lshmcusr” or after the keyword “lshmcusr” before the first argument (here hmc01)!
In addition to the “-s” option, all of these commands also support the “-S” option with argument. This will output the resources that are not selected by the selection (negation):
$ hmc lshmcusr -S taskrole=hmcsuperadmin hmc01
NAME DESCRIPTION TASKROLE RESOURCEROLE
lawrence Jennifer Lawrence hmcviewer ALL:
bacon Kevin Bacon hmcviewer ALL:
costner Kevin Costner hmcviewer ALL:
johansson Scarlett Johansson hmcoperator ALL:
$
But this can also be achieved like this:
$ hmc lshmcusr -s taskrole\!=hmcsuperadmin hmc01
NAME DESCRIPTION TASKROLE RESOURCEROLE
lawrence Jennifer Lawrence hmcviewer ALL:
bacon Kevin Bacon hmcviewer ALL:
costner Kevin Costner hmcviewer ALL:
johansson Scarlett Johansson hmcoperator ALL:
$
Note: Depending on the shell used, the exlamation mark must be protected with a backslash to prevent interpretation by the shell.
Selections can be combined with a comma:
$ hmc lshmcusr -s taskrole=hmcsuperadmin,description~Jennifer hmc01
NAME DESCRIPTION TASKROLE RESOURCEROLE
lopez Jennifer Lopez hmcsuperadmin ALL:
$
The combination with a comma is interpreted as a logical AND. This means that all conditions must be met. Any number of conditions can be combined with a comma. This also applies to the “-S” option.
If the options “-s” or “-S” are used multiple times, this is considered a logical OR:
$ hmc lshmcusr -s taskrole=hmcsuperadmin,description~Jennifer -s taskrole=hmcviewer,description~Costner hmc01
NAME DESCRIPTION TASKROLE RESOURCEROLE
lopez Jennifer Lopez hmcsuperadmin ALL:
costner Kevin Costner hmcviewer ALL:
$
Using the options “-s” and/or “-S” takes some getting used to. You have to remember that these have to be specified as an option before the first argument of the command. Depending on the version of the LPAR tool, this can lead to errors such as the following:
$ hmc lshmcusr hmc01 -s taskrole=hmcsuperadmin,description~Jennifer
USAGE:
hmc lshmcusr [-o <format>] [{-f|-j|-y}] [-F <fields>] [-s <selections>] [-v] <hmc>
ERROR: too many arguments for keyword 'lshmcusr'
$
$ hmc lshmcusr hmc01 -s taskrole=hmcsuperadmin,description~Jennifer
NAME DESCRIPTION TASKROLE RESOURCEROLE
$
Starting with version 1.9.2 of the LPAR tool, many LPAR tool commands support the possibility of specifying selections at the end of the command line without the “-s” option:
$ hmc lshmcusr hmc01 taskrole=hmcsuperadmin,description~Jennifer
NAME DESCRIPTION TASKROLE RESOURCEROLE
lopez Jennifer Lopez hmcsuperadmin ALL:
$
You can also specify several such arguments, which will then be interpreted as a logical OR:
$ hmc lshmcusr hmc01 description~Kevin taskrole=hmcsuperadmin
NAME DESCRIPTION TASKROLE RESOURCEROLE
bacon Kevin Bacon hmcviewer ALL:
baldwin Adam Baldwin hmcsuperadmin ALL:
costner Kevin Costner hmcviewer ALL:
hscroot HMC Super User hmcsuperadmin ALL:
lopez Jennifer Lopez hmcsuperadmin ALL:
root root hmcsuperadmin ALL:
$
A common case will be that you want to specify concrete users (attribute name):
$ hmc lshmcusr hmc01 name=bacon name=lopez
NAME DESCRIPTION TASKROLE RESOURCEROLE
bacon Kevin Bacon hmcviewer ALL:
lopez Jennifer Lopez hmcsuperadmin ALL:
$
Here you would wish that you could simply omit the part “name=” and this is also supported by the LPAR tool:
$ hmc lshmcusr hmc01 bacon lopez
NAME DESCRIPTION TASKROLE RESOURCEROLE
bacon Kevin Bacon hmcviewer ALL:
lopez Jennifer Lopez hmcsuperadmin ALL:
$
In addition to the name attribute, the LPAR tool generally supports other attributes that can be specified in this simplified form. With the command “hmc lshmcusr“, in addition to the name attribute, the description and taskrole attributes can also be specified in this simplified form:
$ hmc lshmcusr hmc01 "Kevin Bacon" hmcviewer
NAME DESCRIPTION TASKROLE RESOURCEROLE
bacon Kevin Bacon hmcviewer ALL:
costner Kevin Costner hmcviewer ALL:
lawrence Jennifer Lawrence hmcviewer ALL:
$
Note: Which attributes are supported for an LPAR tool command in this simplified form can be found in the online help of the command.
In addition to the commands for outputting resources, selections can also be used in many commands that change or delete resources. Instead of specifying the unique name of the resource, a resource can also be specified using selections. However, only one resource can then match the selections, otherwise you will receive an error message.
$ hmc rmhmcusr hmc01 description~Kevin
vhmc01: lshmcusr
USAGE:
hmc rmhmcusr [-v] <hmc> <user_selection>
ERROR: 'description~Kevin' matches more than one user:
did you mean: bacon
did you mean: costner
$
to be continued