openstack——使用命令行删除租户所有信息

Posted jks212454

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openstack——使用命令行删除租户所有信息相关的知识,希望对你有一定的参考价值。

一、删除云硬盘

1.正常删除云硬盘

[root@controller ~(keystone_user)]# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 7de89cc2-7a95-40cd-a3f9-5a3c383b2e65 | available |   disk_01    |  5   |    iscsi    |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
[root@controller ~(keystone_user)]# cinder delete 7de89cc2-7a95-40cd-a3f9-5a3c383b2e65
[root@controller ~(keystone_user)]# cinder list
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+
|                  ID                  |  Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+
| 7de89cc2-7a95-40cd-a3f9-5a3c383b2e65 | deleting |   disk_01    |  5   |    iscsi    |  false   |             |
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+
[root@controller ~(keystone_user)]# cinder list
+----+--------+--------------+------+-------------+----------+-------------+
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+----+--------+--------------+------+-------------+----------+-------------+
+----+--------+--------------+------+-------------+----------+-------------+
[root@controller ~(keystone_user)]# 

2.强制删除云硬盘

[root@controller ~(keystone_user)]# cinder force-delete disk_01 #删除卷 

二、删除网络部分

1.清除网关

①查询路由信息-网关

[root@controller ~(keystone_user)]# neutron router-list
+--------------------------------------+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                                   | name     | external_gateway_info                                                                                                                                                                    |
+--------------------------------------+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| b0b583f4-52b6-49d7-a82a-c76994d33502 | route010 | "network_id": "7af32ea1-517f-4465-8a5c-1cd5c0f352bc", "enable_snat": true, "external_fixed_ips": ["subnet_id": "37e3ff01-fcdd-4e1b-9953-69b406249547", "ip_address": "192.168.9.60"] |
+--------------------------------------+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller ~(keystone_user)]# 

②清除网关报错

[root@controller ~(keystone_user)]# neutron router-gateway-clear route010
Conflict (HTTP 409) (Request-ID: req-31abd300-482e-4451-b733-463f33b9bed6)
[root@controller ~(keystone_user)]# 

③取消浮动IP后删除

[root@controller ~(keystone_user)]# neutron router-gateway-clear route010
Removed gateway from router route010
[root@controller ~(keystone_user)]# 

2.删除路由器接口

①查看子网信息

[root@controller ~(keystone_user)]# neutron subnet-list 
+--------------------------------------+------------+------------------+------------------------------------------------------+
| id                                   | name       | cidr             | allocation_pools                                     |
+--------------------------------------+------------+------------------+------------------------------------------------------+
| 37e3ff01-fcdd-4e1b-9953-69b406249547 | it_network | 192.168.9.0/24   | "start": "192.168.9.60", "end": "192.168.9.80"     |
| 35b7a77a-64dd-4568-ad0a-26b9d1488326 | it_net     | 192.168.120.0/24 | "start": "192.168.120.1", "end": "192.168.120.253" |
+--------------------------------------+------------+------------------+------------------------------------------------------+
[root@controller ~(keystone_user)]# 

②删除路由器接口

[root@controller ~(keystone_user)]# neutron router-interface-delete route010 subnet=it_net
Removed interface from router route010.
[root@controller ~(keystone_user)]# 

3.删除路由器

[root@controller ~(keystone_user)]# neutron router-delete route010
Deleted router: route010
[root@controller ~(keystone_user)]# 

三、删除VPC网络

1.删除子网报错

[root@controller ~(keystone_user)]# neutron subnet-delete it_net
Conflict (HTTP 409) (Request-ID: req-f57144cd-10e5-4e38-b7b3-e204fa3c976d)
[root@controller ~(keystone_user)]# 

报错原因:需要删除子网接口

2.列出子网接口

[root@controller ~(keystone_user)]# neutron port-list 
+--------------------------------------+------+-------------------+----------------------------------------------------------------------------------------+
| id                                   | name | mac_address       | fixed_ips                                                                              |
+--------------------------------------+------+-------------------+----------------------------------------------------------------------------------------+
| 22c43d2b-bbc4-4c1b-bc26-8c123e86819e |      | fa:16:3e:5d:86:89 | "subnet_id": "35b7a77a-64dd-4568-ad0a-26b9d1488326", "ip_address": "192.168.120.102" |
| d8b5fffc-67c8-4bea-bec8-7a9cdd4b21e3 |      | fa:16:3e:d6:ed:b4 | "subnet_id": "35b7a77a-64dd-4568-ad0a-26b9d1488326", "ip_address": "192.168.120.1"   |
+--------------------------------------+------+-------------------+----------------------------------------------------------------------------------------+

3.删除子网接口

[root@controller ~(keystone_user)]# neutron port-delete 22c43d2b-bbc4-4c1b-bc26-8c123e86819e
Deleted port: 22c43d2b-bbc4-4c1b-bc26-8c123e86819e
[root@controller ~(keystone_user)]# neutron port-delete  d8b5fffc-67c8-4bea-bec8-7a9cdd4b21e3
Deleted port: d8b5fffc-67c8-4bea-bec8-7a9cdd4b21e3

4.删除子网

[root@controller ~(keystone_user)]# neutron subnet-delete it_net
Deleted subnet: it_net

5.删除vpc网络

[root@controller ~(keystone_user)]# neutron net-delete vpc
Deleted network: vpc

四、删除安全组

1.查看安全组

[root@controller ~(keystone_user)]# neutron security-group-list 
+--------------------------------------+---------+-------------+
| id                                   | name    | description |
+--------------------------------------+---------+-------------+
| 2e4757f2-a7c1-4d99-a16e-8924009c2e9c | default | default     |
| 331cedb1-653f-42c1-8af8-f79332e3a701 | sg01    | sg01        |
+--------------------------------------+---------+-------------+
[root@controller ~(keystone_user)]# 

2.删除安全组

[root@controller ~(keystone_user)]# neutron security-group-delete sg01
Deleted security_group: sg01

五、删除密钥对

1.查看密钥

[root@controller ~(keystone_user)]# neutron security-group-delete sg01
Deleted security_group: sg01
[root@controller ~(keystone_user)]# nova keypair-list 
+--------+-------------------------------------------------+
| Name   | Fingerprint                                     |
+--------+-------------------------------------------------+
| key600 | 07:38:05:64:4a:b6:b7:dd:b6:a7:7c:bd:92:69:28:ef |
+--------+-------------------------------------------------+
[root@controller ~(keystone_user)]# 

2.删除密钥对

[root@controller ~(keystone_user)]# nova keypair-delete key600 
[root@controller ~(keystone_user)]# nova keypair-list 
+------+-------------+
| Name | Fingerprint |
+------+-------------+
+------+-------------+
[root@controller ~(keystone_user)]# 

六、删除浮动IP

[root@controller ~(keystone_user)]# neutron floatingip-list
+--------------------------------------+------------------+---------------------+---------+
| id                                   | fixed_ip_address | floating_ip_address | port_id |
+--------------------------------------+------------------+---------------------+---------+
| ac2e6c2c-7daf-4766-aa7c-e3fc9aee46dd |                  | 192.168.9.61        |         |
+--------------------------------------+------------------+---------------------+---------+
[root@controller ~(keystone_user)]# neutron floatingip-delete ac2e6c2c-7daf-4766-aa7c-e3fc9aee46dd
Deleted floatingip: ac2e6c2c-7daf-4766-aa7c-e3fc9aee46dd
[root@controller ~(keystone_user)]# 

七、删除对象存储

[root@controller ~(keystone_user1)]# swift delete test

八、删除外部网路

1.进入管理权限环境下

[root@controller ~(keystone_user)]# source keystonerc_admin 

2.查看外部网络

[root@controller ~(keystone_admin)]# neutron net-list
+--------------------------------------+--------+-----------------------------------------------------+
| id                                   | name   | subnets                                             |
+--------------------------------------+--------+-----------------------------------------------------+
| 7af32ea1-517f-4465-8a5c-1cd5c0f352bc | public | 37e3ff01-fcdd-4e1b-9953-69b406249547 192.168.9.0/24 |
+--------------------------------------+--------+-----------------------------------------------------+

3.删除外部网络

[root@controller ~(keystone_admin)]# neutron net-delete public
Deleted network: public

九、删除镜像

1.查看镜像

[root@controller ~(keystone_admin)]# glance image-list
+--------------------------------------+-----------------+-------------+------------------+-----------+--------+
| ID                                   | Name            | Disk Format | Container Format | Size      | Status |
+--------------------------------------+-----------------+-------------+------------------+-----------+--------+
| e27e36f2-7919-4ae5-a0aa-4779a2ef96de | Centos7.1_64bit | qcow2       | bare             | 356777984 | active |
+--------------------------------------+-----------------+-------------+------------------+-----------+--------+

2.删除镜像

[root@controller ~(keystone_admin)]# glance image-delete Centos7.1_64bit
[root@controller ~(keystone_admin)]# glance image-list
+----+------+-------------+------------------+------+--------+
| ID | Name | Disk Format | Container Format | Size | Status |
+----+------+-------------+------------------+------+--------+
+----+------+-------------+------------------+------+--------+
[root@controller ~(keystone_admin)]# 

3.删除受保护的镜像

[root@controller ~(keystone_admin)]# glance image-update --is-protected False small

十、删除云主机规格

1.查看云主机规格

[root@controller ~(keystone_admin)]# nova  flavor-list 
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID                                   | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1                                    | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2                                    | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3                                    | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4                                    | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5                                    | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
| ef383240-4e58-4f8c-b26d-140969a7fd46 | m1.web    | 1024      | 10   | 0         |      | 2     | 1.0         | True      |
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+

2.删除云主机规格

[root@controller ~(keystone_admin)]# nova  flavor-delete m1.web
+--------------------------------------+--------+-----------+------+-----------+------+-------+-------------+-----------+
| ID                                   | Name   | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+--------+-----------+------+-----------+------+-------+-------------+-----------+
| ef383240-4e58-4f8c-b26d-140969a7fd46 | m1.web | 1024      | 10   | 0         |      | 2     | 1.0         | True      |
+--------------------------------------+--------+-----------+------+-----------+------+-------+-------------+-----------+
[root@controller ~(keystone_admin)]# nova  flavor-list 
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
[root@controller ~(keystone_admin)]# 


十一、删除云主机

[root@controller ~(keystone_user)]# nova list
+--------------------------------------+---------+---------+------------+-------------+----------+
| ID                                   | Name    | Status  | Task State | Power State | Networks |
+--------------------------------------+---------+---------+------------+-------------+----------+
| 1d8d1b63-5720-4425-9044-e56ebf3914db | mysql10 | SHUTOFF | -          | Shutdown    |          |
+--------------------------------------+---------+---------+------------+-------------+----------+
[root@controller ~(keystone_user)]# nova delete mysql10 
Request to delete server mysql10 has been accepted.
[root@controller ~(keystone_user)]# 

十二、删除租户与用户

1.查看用户列表

[root@controller ~(keystone_admin)]# keystone user-list 
+----------------------------------+------------+---------+----------------------+
|                id                |    name    | enabled |        email         |
+----------------------------------+------------+---------+----------------------+
| f199c9647c0640ce9026b028208322e4 |   admin    |   True  |    root@localhost    |
| 72b20a1d097b440fbc2e78e50d179492 | ceilometer |   True  | ceilometer@localhost |
| 79ed6e09859b45adabd9cfe224f08cc3 |   cinder   |   True  |   cinder@localhost   |
| c376ec183b914448961d29b36278dfb0 |   glance   |   True  |   glance@localhost   |
| add2c05800d44ef4b182525d3ca0fe47 |  neutron   |   True  |  neutron@localhost   |
| 4828e19232634e388d2246d03243aa4f |    nova    |   True  |    nova@localhost    |
| 29e96756e0494aa4ac3bfbc4298ab3b5 |   swift    |   True  |   swift@localhost    |
| 7bc5356de3854f6e8b2e9ff16f001d65 |    user    |   True  |     user@qq.com      |
+----------------------------------+------------+---------+----------------------+
[root@controller ~(keystone_admin)]# 

2.删除用户

[root@controller ~(keystone_admin)]# keystone user-delete user
[root@controller ~(keystone_admin)]# keystone user-list 
+----------------------------------+------------+---------+----------------------+
|                id                |    name    | enabled |        email         |
+----------------------------------+------------+---------+----------------------+
| f199c9647c0640ce9026b028208322e4 |   admin    |   True  |    root@localhost    |
| 72b20a1d097b440fbc2e78e50d179492 | ceilometer |   True  | ceilometer@localhost |
| 79ed6e09859b45adabd9cfe224f08cc3 |   cinder   |   True  |   cinder@localhost   |
| c376ec183b914448961d29b36278dfb0 |   glance   |   True  |   glance@localhost   |
| add2c05800d44ef4b182525d3ca0fe47 |  neutron   |   True  |  neutron@localhost   |
| 4828e19232634e388d2246d03243aa4f |    nova    |   True  |    nova@localhost    |
| 29e96756e0494aa4ac3bfbc4298ab3b5 |   swift    |   True  |   swift@localhost    |
+----------------------------------+------------+---------+----------------------+
[root@controller ~(keystone_admin)]# 

3.删除租户

[root@controller ~(keystone_admin)]# keystone tenant-list 
+----------------------------------+----------+---------+
|                id                |   name   | enabled |
+----------------------------------+----------+---------+
| 284089db6b6f45e995b0cc9958d476c6 |  admin   |   True  |
| a00aa09c6c5d4c0488896f08f354ea8d | huawei01 |   True  |
| 88f54bcc11334644a8bb7c735ab36a99 | services |   True  |
+----------------------------------+----------+---------+
[root@controller ~(keystone_admin)]# keystone tenant-delete huawei01
[root@controller ~(keystone_admin)]# 

以上是关于openstack——使用命令行删除租户所有信息的主要内容,如果未能解决你的问题,请参考以下文章

openstack——使用命令行发放云主机

Redhat OpenStack使用命令行发放云主机

Redhat OpenStack使用命令行发放云主机

Redhat OpenStack使用命令行发放云主机

openstack的云主机相关命令

sh Openstack CLI命令使用标识V3(包含组)创建新项目/租户和网络