清除虚拟机记录

清除虚拟机数据库记录(不真实删除虚拟机), 用于虚拟机记录异常或者删除失败的情况, 由于此操作比较复杂,且不常用,因此只支持climc命令行操作

以虚拟机Id为 a77d4f36-5484-47d9-8f12-26c7f0dd48f3 进行举例

1. 查找虚拟机的宿主机Id

$ climc server-show a77d4f36-5484-47d9-8f12-26c7f0dd48f3 | grep host_id
| host_id                  | 84c82f1f-7b25-4260-8996-58d60e79ef7d

2. 禁用虚拟机所在的宿主机

$ climc host-disable 84c82f1f-7b25-4260-8996-58d60e79ef7d
+--------------------------------------+------------------+-------------------+---------------+---------+---------+-------------+--------+----------------+---------+--------------+-----------------+--------------+---------------------+----------+------------+-----------+------------+--------------------+-------------------+------------------+------------+----------+--------------+-----------+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+-----------+----------------+--------------+
|                  ID                  |       Name       |    Access_mac     |   Access_ip   | Status  | enabled | host_status | Guests | Running_guests | storage | storage_used | storage_virtual | storage_free | storage_commit_rate | mem_size | mem_commit | cpu_count | cpu_commit |  cpu_commit_rate   |  mem_commit_rate  | cpu_commit_bound | node_count |    sn    | storage_type | host_type |                        version                        |                                                                                        schedtags                                                                                        | storage_size | domain_id | project_domain | public_scope |
+--------------------------------------+------------------+-------------------+---------------+---------+---------+-------------+--------+----------------+---------+--------------+-----------------+--------------+---------------------+----------+------------+-----------+------------+--------------------+-------------------+------------------+------------+----------+--------------+-----------+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+-----------+----------------+--------------+
| 84c82f1f-7b25-4260-8996-58d60e79ef7d | office-03-host01 | 6c:0b:84:0c:e8:44 | 192.168.222.3 | running | false   | online      | 37     | 21             | 7381235 | 3332096      | 7381235         | 4049139      | 0.45                | 128703   | 95232      | 24        | 73         | 3.0416666666666665 | 0.803896575301993 | 8                | 2          | PC0169QS | rotate       | cloudpods | hotfix/qj-cleanup-openvswitch-conf(d7f77fff821092421) | [{"id":"a9c14466-e63d-46c9-80f4-52a14945b9d5","name":"container","res_name":"schedtag"},{"id":"01fa585c-c670-4b2e-83bd-9070ac7a37d7","name":"wcl-test-避免使用","res_name":"schedtag"}] | 7569007      | default   | Default        | none         |
+--------------------------------------+------------------+-------------------+---------------+---------+---------+-------------+--------+----------------+---------+--------------+-----------------+--------------+---------------------+----------+------------+-----------+------------+--------------------+-------------------+------------------+------------+----------+--------------+-----------+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+-----------+----------------+--------------+
***  Total: 1  ***

3. 禁用虚拟机删除保护

$ climc server-update --delete enable a77d4f36-5484-47d9-8f12-26c7f0dd48f3
+--------------------------------------+---------+--------------+----------------+-------+---------+------------+-----------+------------+--------------------------------------+-----------------------------+------------+---------+------------------+--------+-----------+
|                  ID                  |  Name   | Billing_type |      IPs       | Disk  | Status  | vcpu_count | vmem_size |  Secgroup  |              Secgrp_id               |         Created_at          | Hypervisor | os_type |       Host       | Tenant | is_system |
+--------------------------------------+---------+--------------+----------------+-------+---------+------------+-----------+------------+--------------------------------------+-----------------------------+------------+---------+------------------+--------+-----------+
| a77d4f36-5484-47d9-8f12-26c7f0dd48f3 | zy-test | postpaid     | 192.168.10.245 | 30720 | unknown | 2          | 2048      | Default-19 | b48ea3b1-4e3c-4303-8bfe-5bb2223fdc45 | 2021-09-16T07:29:28.000000Z | cloudpods  | Linux   | office-03-host01 | system | false     |
+--------------------------------------+---------+--------------+----------------+-------+---------+------------+-----------+------------+--------------------------------------+-----------------------------+------------+---------+------------------+--------+-----------+
***  Total: 1  ***

4. 清理虚拟机数据库记录

$ climc server-purge a77d4f36-5484-47d9-8f12-26c7f0dd48f3
+--------------------------------------+---------+--------------+----------------+-------+--------------+------------+-----------+------------+--------------------------------------+-----------------------------+------------+---------+------------------+--------+-----------+
|                  ID                  |  Name   | Billing_type |      IPs       | Disk  |    Status    | vcpu_count | vmem_size |  Secgroup  |              Secgrp_id               |         Created_at          | Hypervisor | os_type |       Host       | Tenant | is_system |
+--------------------------------------+---------+--------------+----------------+-------+--------------+------------+-----------+------------+--------------------------------------+-----------------------------+------------+---------+------------------+--------+-----------+
| a77d4f36-5484-47d9-8f12-26c7f0dd48f3 | zy-test | postpaid     | 192.168.10.245 | 30720 | start_delete | 2          | 2048      | Default-19 | b48ea3b1-4e3c-4303-8bfe-5bb2223fdc45 | 2021-09-16T07:29:28.000000Z | cloudpods  | Linux   | office-03-host01 | system | false     |
+--------------------------------------+---------+--------------+----------------+-------+--------------+------------+-----------+------------+--------------------------------------+-----------------------------+------------+---------+------------------+--------+-----------+
***  Total: 1  ***

5. 启用宿主机

$ climc host-enable 84c82f1f-7b25-4260-8996-58d60e79ef7d
+--------------------------------------+------------------+-------------------+---------------+---------+---------+-------------+--------+----------------+---------+--------------+-----------------+--------------+---------------------+----------+------------+-----------+------------+--------------------+-------------------+------------------+------------+----------+--------------+-----------+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+-----------+----------------+--------------+
|                  ID                  |       Name       |    Access_mac     |   Access_ip   | Status  | enabled | host_status | Guests | Running_guests | storage | storage_used | storage_virtual | storage_free | storage_commit_rate | mem_size | mem_commit | cpu_count | cpu_commit |  cpu_commit_rate   |  mem_commit_rate  | cpu_commit_bound | node_count |    sn    | storage_type | host_type |                        version                        |                                                                                        schedtags                                                                                        | storage_size | domain_id | project_domain | public_scope |
+--------------------------------------+------------------+-------------------+---------------+---------+---------+-------------+--------+----------------+---------+--------------+-----------------+--------------+---------------------+----------+------------+-----------+------------+--------------------+-------------------+------------------+------------+----------+--------------+-----------+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+-----------+----------------+--------------+
| 84c82f1f-7b25-4260-8996-58d60e79ef7d | office-03-host01 | 6c:0b:84:0c:e8:44 | 192.168.222.3 | running | true    | online      | 36     | 21             | 7381235 | 3301376      | 7381235         | 4079859      | 0.45                | 128703   | 95232      | 24        | 73         | 3.0416666666666665 | 0.803896575301993 | 8                | 2          | PC0169QS | rotate       | cloudpods | hotfix/qj-cleanup-openvswitch-conf(d7f77fff821092421) | [{"id":"a9c14466-e63d-46c9-80f4-52a14945b9d5","name":"container","res_name":"schedtag"},{"id":"01fa585c-c670-4b2e-83bd-9070ac7a37d7","name":"wcl-test-避免使用","res_name":"schedtag"}] | 7569007      | default   | Default        | none         |
+--------------------------------------+------------------+-------------------+---------------+---------+---------+-------------+--------+----------------+---------+--------------+-----------------+--------------+---------------------+----------+------------+-----------+------------+--------------------+-------------------+------------------+------------+----------+--------------+-----------+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+-----------+----------------+--------------+
***  Total: 1  ***