Using LMI Commands

The LMI CLI command processor is invoked by entering “LMI”. You can use it to enter either a single command or multiple commands. Entering “LMI” with no arguments puts you into interactive mode until you enter CTRL-D to exit the CLI processor. In interactive mode you can enter multiple LMI commands.

In general you have to provide the target system, user, and password for each LMI command. This can be a nuisance if you are entering multiple LMI commands – in this case it is best to go into the LMI command processor’s interactive mode. You will have to enter the authentication information once, and the command processor will remember it for the rest of the session. The exception to this rule is when you are managing the local system and are logged in with root privileges.

Lets start with a simple example, getting a list of storage on the local system system. This is done by entering the command:

$ lmi storage list

Entered this way, the lmi command processor will default to localhost for the system and prompt you for the username and password to use (unless you have root privileges). The output of the command is printed to the screen:

Size Format

/dev/disk/by-id/dm-name-luks-ffc4ec65-f140-4493-a991-802ad6fa20b4 /dev/mapper/luks-ffc4ec65-f140-4493-a991-802ad6fa20b4 luks-ffc4ec65-f140-4493-a991-802ad6fa20b4 249531727872 physical volume (LVM)

/dev/disk/by-id/ata-ST3250410AS_6RY0WKF9 /dev/sda sda 250059350016 MS-DOS partition table

/dev/sr0 /dev/sr0 sr0 250059350016 Unknown

/dev/disk/by-id/ata-ST3250410AS_6RY0WKF9-part1 /dev/sda1 sda1 524288000 ext4

/dev/disk/by-id/ata-ST3250410AS_6RY0WKF9-part2 /dev/sda2 sda2 249533825024 Encrypted (LUKS)

/dev/disk/by-id/dm-name-fedora-home /dev/mapper/fedora-home home 191931351040 ext4

/dev/disk/by-id/dm-name-fedora-root /dev/mapper/fedora-root root 53687091200 ext4

/dev/disk/by-id/dm-name-fedora-swap /dev/mapper/fedora-swap swap 3909091328 swap

Note that the information includes the user friendly name – sda, sda1 and sda2 – as well as the persistent id’s. All of the LMI Storage commands accept any of the device id’s. The persistent id’s are more robust on servers, where you can run into situations where the user friendly names change. This can occur when you add or remove devices or controllers or move disks to different ports on an hba.

If you are going to enter multiple LMI commands, you should enter the LMI shell by entering

$ lmi

lmi>

At this point you can find out what commands are available by entering “?”.

lmi> ?

Documented commands (type help <topic>):

========================================

EOF help
Application commands (type help <topic>):

=========================================

exit help lf mount partition-table service sw

fs hwinfo lv partition raid storage vg

You can ask for more help on these commands by entering help <command>, for example:

lmi> help storage

Basic storage device information.

Usage:

storage list [ <device> …]

storage depends [ –deep ] [ <device> …]

storage provides [ –deep ] [ <device> …]

storage show [ <device> …]

storage tree [ <device> ]

lmi>

Let’s now show an example of changing system state with LMI. We will use the lmi service commands to list all available services, show service status, and start and stop a service. First, run lmi service list to list all available services (this takes time to run and produces a long output, so it isn’t shown here). Then use the lmi service show, stop, and start commands:

lmi> service show cups.service

Name=cups.service

Caption=CUPS Printing Service

Enabled=True

Active=True

Status=OK

Now we can stop the cups service and then check its status:

lmi> service stop cups.service

lmi> service show cups.service

Name=cups.service

Caption=CUPS Printing Service

Enabled=True

Active=False

Status=Stopped

Finally, start the cups service and then check its status:

lmi> service start cups.service

lmi> service show cups.service

Name=cups.service

Caption=CUPS Printing Service

Enabled=True

Active=True

Status=OK

lmi>

To use the LMI command processor against a remote system with OpenLMI installed, use the -h (host) option:

$ lmi -h managedsystem.mydomain.org

> service show cups.service

username: pegasus

password:

Name=cups.service

Caption=CUPS Printing Service

Enabled=True

Active=True

Status=OK

This should be enough to get you started using LMI Commands.

About Russell Doty

A technology strategist and product manager at Red Hat, working on the next generation of open source systems.
This entry was posted in System Management. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s