Chapter 3: Nova - Advanced Commands
In this chapter, we will see the advanced nova commands useful debugging, complex topology, etc.
Commands :
1. Nova service status:
Note: This command is authorized by admin user only.
This command displays the status of nova-conductor, nova-scheduler, nova-compute nodes.
To list the nova services status,
nova service-list
2. Hypervisor(Compute) Node:
Note: This command is authorized by admin user only.
This command lists the compute nodes available in this openstack setup and status of each compute nodes .
List the compute nodes(hypervisor)
nova hypervisor-list
List the compute node CPU/Memory utilization details
To know the CPU, Memory, HDD usage of each compute node, and remaining resources available,
nova host-describe <hypervisor-name>
List the instances hosted in the specific compute node
nova list --host <compute name>
Create a instance in the specified compute node
The option "--availability-zone" in the "nova boot" command, enables the user to create the VM in the specific compute node.
Make sure you specify the compute node in "nova:<compute node name>" format. you can get this details from
nova availability-zone-list
Example
nova boot --flavor 6 --image u14 --key-name testkey --security-groups default --nic net-name=N1 --availability-zone nova:compute-0000 vm3
Migrate the instance from one compute to other compute
Migrating the VM from one compute to another compute.
nova live-migration --block-migrate <vm id> <target compute/hypervisor name>
For example, vm1 is running on compute0, As i want to upgrade the software in compute0 , i have to migrate the vm1 to compute1.
nova live-migration --block-migrate 694ac3f0-8ea6-46b5-b790-be7b43d66a91 compute-0001
3. Snapshot of the image:
Usecase:
I am running the VM, and i have installed some applications and configured. and i want to make the cloud image out of it, so that i can use it for spawn 'N' number of VMs.
- shut down your VM.
- snapshot the VM using nova image-create command.
nova stop <server name>
nova image-create --poll <vm name> <image name>
example:
nova image-create --poll myvm1 centos_suresh_img
4. Nova Aggregate:
Usecase:
I want to specify my VMs will be launched only on certain compute nodes (ex compute1, compute 3, compute 5).
Solution:
Create a nova aggreage with 3 Compute nodes, and add this aggregate in to the flavor.
So, whenever the VM is spawned with this flavor, it will created on the aggregate computes
Commands:
nova aggregate-create <aggregate name> <zone name>
nova aggregate-add-host <aggregate name> <compute/host name>
nova aggregate-set-metadata <aggregate name> <key=value>
nova flavor-key <flavor name> set <key=value>
Exmaple:
nova aggregate-create myagg nova
nova aggregate-add-host myagg compute-1
nova aggregate-add-host myagg compute-5
nova aggregate-add-host myagg compute-7
nova aggregate-set-metadata prox type=suresh
nova flavor-key suresh_flavor set type=suresh
Execution Logs:
1. Nova service status:
% nova service-list
+----------------+---------------+----------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+----------------+---------------+----------+---------+-------+----------------------------+-----------------+
| nova-conductor | novacon-0000 | internal | enabled | up | 2017-08-11T09:29:03.000000 | - |
| nova-scheduler | novasch-0000 | internal | enabled | up | 2017-08-11T09:29:00.000000 | - |
| nova-cert | novacer-0000 | internal | enabled | up | 2017-08-11T09:28:58.000000 | - |
| nova-compute | compute-0000 | nova | enabled | up | 2017-08-11T09:28:54.000000 | - |
| nova-compute | compute-0001 | nova | enabled | up | 2017-08-11T09:29:10.000000 | - |
+----------------+---------------+----------+---------+-------+----------------------------+-----------------+
2. Hypervisor(Compute) Node:
% nova hypervisor-list
+----+-----------------------------+-------+---------+
| ID | Hypervisor hostname | State | Status |
+----+-----------------------------+-------+---------+
| 1 | compute-0000.novalocal | up | enabled |
| 2 | compute-0001.novalocal | up | enabled |
+----+-----------------------------+-------+---------+
% nova host-describe compute-0000
+---------------+----------------------------------+-----+-----------+---------+
| HOST | PROJECT | cpu | memory_mb | disk_gb |
+--------------+----------------------------------+-----+-----------+---------+
| compute-0000 | (total) | 4 | 15671 | 49 |
| compute-0000 | (used_now) | 1 | 5394 | 6 |
| compute-0000 | (used_max) | 1 | 1024 | 10 |
| compute-0000 | bccf45eee4544264a526c4bca56fdb3c | 1 | 1024 | 10 |
+--------------+----------------------------------+-----+-----------+---------+
% nova list
+--------------------------------------+------+--------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+---------------+
| 2ce2bc7e-9954-4c08-9838-0ff5b487d8da | vm1 | ACTIVE | - | Running | N1=10.10.10.3 |
| 1f0a177e-175b-4ed7-9bfc-d500f71797f7 | vm3 | ACTIVE | - | Running | N1=10.10.10.4 |
| 502999ab-4ee4-4c66-ae1b-3e9914d28920 | vm4 | BUILD | spawning | NOSTATE | N1=10.10.10.5 |
+--------------------------------------+------+--------+------------+-------------+---------------+
% nova list --host compute-0000
+--------------------------------------+------+--------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+---------------+
| 2ce2bc7e-9954-4c08-9838-0ff5b487d8da | vm1 | ACTIVE | - | Running | N1=10.10.10.3 |
| 1f0a177e-175b-4ed7-9bfc-d500f71797f7 | vm3 | ACTIVE | - | Running | N1=10.10.10.4 |
+--------------------------------------+------+--------+------------+-------------+---------------+
% nova list --host compute-0001
+--------------------------------------+------+--------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+---------------+
| 502999ab-4ee4-4c66-ae1b-3e9914d28920 | vm4 | BUILD | spawning | NOSTATE | N1=10.10.10.5 |
+--------------------------------------+------+--------+------------+-------------+---------------+
# Migration example
$ nova list --host compute-0001
+--------------------------------------+---------+--------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+---------+--------+------------+-------------+---------------+
| 694ac3f0-8ea6-46b5-b790-be7b43d66a91 | server1 | ACTIVE | - | Running | N1=10.10.10.4 |
| 85e8b399-0dbe-4a7d-86ab-82be60faacdb | server2 | ACTIVE | - | Running | N1=10.10.10.5 |
+--------------------------------------+---------+--------+------------+-------------+---------------+
$ nova live-migration --block-migrate 694ac3f0-8ea6-46b5-b790-be7b43d66a91 compute-0000
$ nova list --host compute-0001
+--------------------------------------+---------+-----------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+---------+-----------+------------+-------------+---------------+
| 694ac3f0-8ea6-46b5-b790-be7b43d66a91 | server1 | MIGRATING | migrating | Running | N1=10.10.10.4 |
| 85e8b399-0dbe-4a7d-86ab-82be60faacdb | server2 | ACTIVE | - | Running | N1=10.10.10.5 |
+--------------------------------------+---------+-----------+------------+-------------+---------------+
$ nova list --host compute-0001
+--------------------------------------+---------+--------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+---------+--------+------------+-------------+---------------+
| 85e8b399-0dbe-4a7d-86ab-82be60faacdb | server2 | ACTIVE | - | Running | N1=10.10.10.5 |
+--------------------------------------+---------+--------+------------+-------------+---------------+
$ nova list --host compute-0000
+--------------------------------------+---------+--------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+---------+--------+------------+-------------+---------------+
| 98760737-4b82-45ff-a7eb-4cda3bfceb63 | monitor | ACTIVE | - | Running | N1=10.10.10.3 |
| 694ac3f0-8ea6-46b5-b790-be7b43d66a91 | server1 | ACTIVE | - | Running | N1=10.10.10.4 |
+--------------------------------------+---------+--------+------------+-------------+---------------+