Looking at a nova resource allocations on a compute where DB is consistent (no
hanging allocations).
===================================================================================
=================
1) List VMs on a compute
[root@overcloud-ovscompute-18 ~]# for i in `virsh list --all | grep instance | awk
'{print $1}'` ; do echo $i && virsh dumpxml $i | grep "<uuid>" ; done
44
<uuid>3567fd12-d77f-44fb-87d4-6be8c39547fe</uuid>
45
<uuid>36e770f9-cd0c-4092-9d76-bd386cc5b085</uuid>
46
<uuid>912e7b9a-e803-43a3-ab06-7ddad46eaf54</uuid>
47
<uuid>6e588104-da7f-4ab8-9a3f-c21dc7526f5e</uuid>
48
<uuid>8d0845b2-2531-4697-884a-7097ff5b0a12</uuid>
2) Find resource provider uuid of a compute
[cbis-admin@overcloud-controller-0 (overcloudrc) ~]$ openstack resource provider
list
+--------------------------------------+-------------------------------------
+------------+
| uuid | name |
generation |
+--------------------------------------+-------------------------------------
+------------+
| d69709d7-5d3f-4d5a-9729-82656318bcb8 | overcloud-ovscompute-18.localdomain |
67 |
2a) Verify resource provider uuid of a compute in a DB
MariaDB [nova_api]> select * from resource_providers where uuid='d69709d7-5d3f-
4d5a-9729-82656318bcb8';
+---------------------+---------------------+----
+--------------------------------------+-------------------------------------
+------------+----------+------------------+--------------------+
| created_at | updated_at | id | uuid
| name | generation | can_host | root_provider_id |
parent_provider_id |
+---------------------+---------------------+----
+--------------------------------------+-------------------------------------
+------------+----------+------------------+--------------------+
| 2020-06-04 10:29:34 | 2021-04-08 12:23:08 | 2 | d69709d7-5d3f-4d5a-9729-
82656318bcb8 | overcloud-ovscompute-18.localdomain | 67 | NULL |
2 | NULL |
+---------------------+---------------------+----
+--------------------------------------+-------------------------------------
+------------+----------+------------------+--------------------+
1 row in set (0.03 sec)
3) Find allocations related to a specific VM
MariaDB [nova_api]> select * from allocations where consumer_id='3567fd12-d77f-
44fb-87d4-6be8c39547fe';
+---------------------+------------+-------+----------------------
+--------------------------------------+-------------------+------+
| created_at | updated_at | id | resource_provider_id | consumer_id
| resource_class_id | used |
+---------------------+------------+-------+----------------------
+--------------------------------------+-------------------+------+
| 2021-04-08 12:14:35 | NULL | 29442 | 2 | 3567fd12-d77f-
44fb-87d4-6be8c39547fe | 0 | 4 |
| 2021-04-08 12:14:35 | NULL | 29445 | 2 | 3567fd12-d77f-
44fb-87d4-6be8c39547fe | 1 | 8192 |
| 2021-04-08 12:14:35 | NULL | 29448 | 2 | 3567fd12-d77f-
44fb-87d4-6be8c39547fe | 2 | 20 |
+---------------------+------------+-------+----------------------
+--------------------------------------+-------------------+------+
3a) Similar, using openstack cli
[cbis-admin@overcloud-controller-0 (overcloudrc) ~]$ openstack resource provider
allocation show 3567fd12-d77f-44fb-87d4-6be8c39547fe
+--------------------------------------+------------
+--------------------------------------------------+
| resource_provider | generation | resources
|
+--------------------------------------+------------
+--------------------------------------------------+
| d69709d7-5d3f-4d5a-9729-82656318bcb8 | 67 | {u'VCPU': 4, u'MEMORY_MB':
8192, u'DISK_GB': 20} |
+--------------------------------------+------------
+--------------------------------------------------+
4) Find allocations mapped to a specific compute
MariaDB [nova_api]> select * from allocations where resource_provider_id=2;
+---------------------+------------+-------+----------------------
+--------------------------------------+-------------------+-------+
| created_at | updated_at | id | resource_provider_id | consumer_id
| resource_class_id | used |
+---------------------+------------+-------+----------------------
+--------------------------------------+-------------------+-------+
| 2021-04-08 12:14:35 | NULL | 29442 | 2 | 3567fd12-d77f-
44fb-87d4-6be8c39547fe | 0 | 4 |
| 2021-04-08 12:14:45 | NULL | 29604 | 2 | 912e7b9a-e803-
43a3-ab06-7ddad46eaf54 | 0 | 8 |
| 2021-04-08 12:14:46 | NULL | 29649 | 2 | 6e588104-da7f-
4ab8-9a3f-c21dc7526f5e | 0 | 8 |
| 2021-04-08 12:19:19 | NULL | 29685 | 2 | 36e770f9-cd0c-
4092-9d76-bd386cc5b085 | 0 | 8 |
| 2021-04-08 12:23:08 | NULL | 29811 | 2 | 8d0845b2-2531-
4697-884a-7097ff5b0a12 | 0 | 8 |
| 2021-04-08 12:14:35 | NULL | 29445 | 2 | 3567fd12-d77f-
44fb-87d4-6be8c39547fe | 1 | 8192 |
| 2021-04-08 12:14:45 | NULL | 29607 | 2 | 912e7b9a-e803-
43a3-ab06-7ddad46eaf54 | 1 | 32768 |
| 2021-04-08 12:14:46 | NULL | 29652 | 2 | 6e588104-da7f-
4ab8-9a3f-c21dc7526f5e | 1 | 32768 |
| 2021-04-08 12:19:19 | NULL | 29688 | 2 | 36e770f9-cd0c-
4092-9d76-bd386cc5b085 | 1 | 32768 |
| 2021-04-08 12:23:08 | NULL | 29814 | 2 | 8d0845b2-2531-
4697-884a-7097ff5b0a12 | 1 | 32768 |
| 2021-04-08 12:14:35 | NULL | 29448 | 2 | 3567fd12-d77f-
44fb-87d4-6be8c39547fe | 2 | 20 |
| 2021-04-08 12:14:45 | NULL | 29610 | 2 | 912e7b9a-e803-
43a3-ab06-7ddad46eaf54 | 2 | 50 |
| 2021-04-08 12:14:46 | NULL | 29655 | 2 | 6e588104-da7f-
4ab8-9a3f-c21dc7526f5e | 2 | 50 |
| 2021-04-08 12:19:19 | NULL | 29691 | 2 | 36e770f9-cd0c-
4092-9d76-bd386cc5b085 | 2 | 50 |
| 2021-04-08 12:23:08 | NULL | 29817 | 2 | 8d0845b2-2531-
4697-884a-7097ff5b0a12 | 2 | 50 |
+---------------------+------------+-------+----------------------
+--------------------------------------+-------------------+-------+
5) Deleting allocations of a specific VM (assuming that VM was deleted in the past
and does not exist anymore, but allocations were not deleted by some reason)
openstack resource provider allocation delete <consumer_id> <=== VM uuid