1.5. Interacting with the CLI
The CLI is an interactive shell for controlling your Red Hat Enterprise Virtualization environment from the command line. Type the required command and any additional parameters.
Example 1.1. Entering a shell command
[RHEVM shell (connected)]# show vm RHEL6-Server
[RHEVM shell (connected)]# show vm RHEL6-Server
To support the construction of command and parameter combinations, the CLI includes the functionality to list and automatically complete commands and parameters by pressing the
TAB
key twice, similar to the bash shell.
Example 1.2. Listing and automatic completion of commands and parameters
Press double
TAB
at a blank prompt to list all available commands.
Choose a command and press double
TAB
to view the next set of available parameters for the command. For the add
command, this lists all resources.
Double
TAB
also completes commands and parameters.
Note that the double
TAB
also automatically formats na
to the --name
parameter, including the prefix.
If the incomplete parameter matches multiple parameters, double
TAB
lists them.
[RHEVM shell (connected)]# add vTAB TAB vmpool vm
[RHEVM shell (connected)]# add vTAB TAB
vmpool vm
The CLI provides functions to run Linux commands using either the
shell
command or the bang (!
) character.
Example 1.3. Running Linux shell commands
Use the
shell
command:
[RHEVM shell (connected)]# shell ls -la
[RHEVM shell (connected)]# shell ls -la
Or use the bang (
!
) character:
[RHEVM shell (connected)]# !ls -la
[RHEVM shell (connected)]# !ls -la
Similar to the Linux shell, the CLI can pipe data to other commands and sources.
Example 1.4. Piping CLI commands
Pipe CLI data to a Linux shell command:
Pipe CLI data to a file:
[RHEVM shell (connected)]# list vms --show-all > list vms --show-all > VM_List.txt
[RHEVM shell (connected)]# list vms --show-all > list vms --show-all > VM_List.txt
The CLI also contains an online help system to provide descriptions and syntax for each command via the
help
command.
Example 1.5. Using online help for the show
command
[RHEVM shell (connected)]# help show
[RHEVM shell (connected)]# help show
You can also connect to the Manager from the Linux shell to execute specific commands, in the form of "command resource" and print them to STDIO
Example 1.6. Connecting to the Manager to execute specific commands
Use the
--execute
or -E
parameter to connect to the Manager to execute the specific commands.