Openstack instance management using CLI

Dear friends today we will see, how to manage instance using CLI in openstack. Such as how to start, stop, suspend, resume, reboot and rescue instance. Suppose if our instance operating system has some problem and we need to go to rescue mode to debug some think, then we need to go to rescue mode in our instance.

We will see such types of commands in this tutorial with example. So that you can easily manager your instance using CLI commands. Once you need to manage your instance using CLI. So let’s start one by one command with example.

How to get instance list?

We can use nova list commands to display all our instance. You can also use grep commands to display selected instance. Like below output. I am selecting my cirros instance using nova list |grep instance commands.

#Command:-nova list |grep <instance-name>
test@urclouds:~$ nova list |grep cirros
| 5aa3612d-9f25-4777-9275-2ff6900a8496 | cirros       | ACTIVE | -          | Running     | provider=172.21.144.217                                                    |
test@urclouds:~$

How to pause instance?

We can use nova pause commands to pause instance in openstack. You can see below nova pause command output.

#Command:-nova pause <instance-name>
test@urclouds:~$ nova pause cirros
test@urclouds:~$
test@urclouds:~$ nova list |grep cirros
| 5aa3612d-9f25-4777-9275-2ff6900a8496 | cirros       | PAUSED | -          | Paused      | provider=172.21.144.217                                                    |
test@urclouds:~$

How to unpause instance?

We can unpause instance using nova unpause commands. You can see nova unpause commands output.

test@urclouds:~$ nova unpause cirros
test@urclouds:~$ nova list |grep cirros
| 5aa3612d-9f25-4777-9275-2ff6900a8496 | cirros       | ACTIVE | -          | Running     | provider=172.21.144.217                                                    |
test@urclouds:~$

How to suspend instance?

We can suspend instance using nova suspend commands. You can see below output of suspend commands.

#Command:-nova suspend <instance-name>
test@urclouds:~$ nova suspend cirros
test@urclouds:~$ nova list |grep cirros
| 5aa3612d-9f25-4777-9275-2ff6900a8496 | cirros       | SUSPENDED | -          | Shutdown    | provider=172.21.144.217                                                    |
test@urclouds:~$

How to unsuspend instance?

We can unsuspend instance using nova resume commands. You can see below output of resume commands.

#Command:-nova rescue <instance-name>
test@urclouds:~$ nova resume cirros
test@urclouds:~$ nova list |grep cirros
| 5aa3612d-9f25-4777-9275-2ff6900a8496 | cirros       | ACTIVE | -          | Running     | provider=172.21.144.217                                                    |
test@urclouds:~$

How to stop instance?

We can shutdown instance using nova stop commands. You can see nova stop commands output in below output.

#Command:-nova stop <instance-name>
test@urclouds:~$ nova stop cirros

Request to stop server cirros has been accepted.

How to start instance?

We can start instance using nova start commands. You can see below nova start commands output.

#Command:-nova start <instance-name>

test@urclouds:~$ nova start cirros
Request to start server cirros has been accepted.
test@urclouds:~$ nova list |grep cirros
| 5aa3612d-9f25-4777-9275-2ff6900a8496 | cirros       | ACTIVE | -          | Running     | provider=172.21.144.217                                                    |
test@urclouds:~$

How to go to rescue mode in instance?

Some time we need to go to rescue mode for debugging in instance. In this case we can use nova rescue mode to go to rescue mode in instance. You can see output of nova rescue commands.

#Command:-nova rescue <instance-name>
test@urclouds:~$ nova rescue cirros
+-----------+--------------+
| Property  | Value        |
+-----------+--------------+
| adminPass | mPDTzj39vWiB |
+-----------+--------------+
test@urclouds:~$ nova list |grep cirros
| 5aa3612d-9f25-4777-9275-2ff6900a8496 | cirros       | RESCUE | -          | Running     | provider=172.21.144.217                                                    |
test@urclouds:~$

You can see in above output we have successfully entered in rescue mode in cirros instance.

How to remove rescue mode?

We can move out from rescue mode using nova unrescue commands once our debugging will be completed. You can see output of unrescue commands.

#Command:-nova unrescue <instance-name>
test@urclouds:~$ nova unrescue cirros
test@urclouds:~$ nova list |grep cirros
| 5aa3612d-9f25-4777-9275-2ff6900a8496 | cirros       | ACTIVE | -          | Running     | provider=172.21.144.217                                                    |
test@urclouds:~$

How to reboot instance?

We can reboot our instance using nova reboot commands. You can see nova reboot output commands in below.

#Command:-nova reboot <instance-name>
test@urclouds:~$ nova reboot cirros
Request to reboot server <Server: cirros> has been accepted.
test@urclouds:~$ nova list |grep cirros
| 5aa3612d-9f25-4777-9275-2ff6900a8496 | cirros       | ACTIVE | -          | Running     | provider=172.21.144.217                                                    |
test@urclouds:~$

That’s all we have seen some cli commands to manage instance in openstack in this tutorial.

Leave a Reply