oVirt is commonly managed via Engine WebAdmin interface. The reason is simple: it is very easy and intuitive. The official oVirt Administration manual shows the web interface as example too.
However, I can’t always rely on a web browser. There are sometimes that I have just the terminal. Because of my needs, I started to experiment the ovirt-shell alternative. For the basic tasks, I didn’t find problems: start vm, migrate vm, set a host in maintenance state, update some vm attribute… Below I will show some examples of the commands I’ve tried.
First, how can I connect?
[root@engine ~]# ovirt-shell -l https://engine.example.com/api -u admin@internal Password:
You will see something like this:
=================================================== >>> connected to oVirt manager 22.214.171.124 <<< =================================================== +++++++++++++++++++++++++++++++++++++++++++++++++++ Welcome to oVirt shell +++++++++++++++++++++++++++++++++++++++++++++++++++ [oVirt shell (connected)]#
Once connected, it’s possible use double <TAB> to see possible commands:
[oVirt shell (connected)]# <TAB> <TAB> EOF add clear console echo file history list remove show summary action capabilities connect disconnect exit help info ping shell status update
In case of doubt, the commands could be prefixed with ‘help’. For instance ‘help show host’. I won’t paste here the output of the commands because they are too big and I think you can see it by your own. Check some examples I used with descriptions:
Show details of VM web01.example.com:
show vm web01.example.com
Start VM web01.example.com:
action vm web01.example.com start
Run once VM web01.example.com in stateless mode:
action vm web01.example.com start --vm-stateless
Shutdown gracefully VM web01.example.com:
action vm web01.example.com shutdown
Migrate VM web01.example.com to any host:
action vm web01.example.com migrate
Migrate VM web01.example.com.br to host node01.example.com:
action vm web01.example.com migrate --host-name node01.example.com
Put host node02.example.com in maintenance mode:
action host node02.example.com deactivate
Activate host node03.example.com:
action host node03.example.com activate
List all VMs running on host node01.example.com:
list vms --query 'host=node01.example.com'
Edit VM web01.example.com to boot firstly via PXE and then HD:
update vm web01.example.com --os-boot 'boot.dev=network,boot.dev=hd'
You can run just one command without get the ovirt-shell prompt:
ovirt-shell -l https://engine.example.com/api -u admin@internal -E show vm web01.example.com
If you want to run a series of commands, write them in a file and use the ‘-f’ option:
ovirt-shell -l https://engine.example.com/api -u admin@internal -f cmds.txt
For more information, check the official page of CLI, in other words, ovirt-shell.