下面,我们以删除一个路由设备为例,讲解整个过程(以下命令都在控制节点执行)
列出所有路由设备,获得要删除的路由器id
# neutron router-list
[root@controller ~]# neutron router-list
+--------------------------------------+-------+-----------------------------------------------------------------------------+
| id | name | external_gateway_info |
+--------------------------------------+-------+-----------------------------------------------------------------------------+
| 9e397a85-2284-4809-8143-bee6bd075cf5 | route | {"network_id": "f9684976-0d44-4bd8-9116-048602a6c3e1", "enable_snat": true} |
+--------------------------------------+-------+-----------------------------------------------------------------------------+
根据路由器id,删除其网关端口
# neutron router-gateway-clear <router_id>
[root@controller ~]# neutron router-gateway-clear 9e397a85-2284-4809-8143-bee6bd075cf5
Removed gateway from router 9e397a85-2284-4809-8143-bee6bd075cf5
根据路由设备id,列出其其他端口
# neutron router-port-list <router_id>
[root@controller ~]# neutron router-port-list 9e397a85-2284-4809-8143-bee6bd075cf5
+--------------------------------------+------+-------------------+------------------------------------------------------------------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+------------------------------------------------------------------------------------+
| 5163bb3d-03d6-471d-b8fc-81d0405110e2 | | fa:16:3e:b6:ca:00 | {"subnet_id": "d8a13476-2952-4618-a968-6a7d524b76c2", "ip_address": "192.168.0.1"} |
+--------------------------------------+------+-------------------+------------------------------------------------------------------------------------+
根据路由器id与subnet_id删除路由器其他端口
# neutron router-interface-delete <router-id> <subnet-id>
[root@controller ~]# neutron router-interface-delete 9e397a85-2284-4809-8143-bee6bd075cf5 d8a13476-2952-4618-a968-6a7d524b76c2
Removed interface from router 9e397a85-2284-4809-8143-bee6bd075cf5.
最后删除路由
# neutron router-delete <router-id>
[root@controller ~]# neutron router-delete 9e397a85-2284-4809-8143-bee6bd075cf5
Deleted router: 9e397a85-2284-4809-8143-bee6bd075cf5
列出所有使用网络的端口
# neutron port-list
[root@controller ~]# neutron port-list
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
| 3f80b739-5c75-4317-8fdc-a4ab4d195d51 | | fa:16:3e:e0:17:5e | {"subnet_id": "d8a13476-2952-4618-a968-6a7d524b76c2", "ip_address": "192.168.0.50"} |
| 577f3e54-bf56-4220-b761-a08993209c1c | | fa:16:3e:7b:b4:3b | {"subnet_id": "e7b1f3dd-3397-445b-aa6d-881d70f4e5a0", "ip_address": "192.168.100.54"} |
| 647f35aa-8bf4-43cb-b4a3-180b48b60ec5 | | fa:16:3e:4d:04:7b | {"subnet_id": "e7b1f3dd-3397-445b-aa6d-881d70f4e5a0", "ip_address": "192.168.100.56"} |
| dca0e651-38c8-427d-8d48-af0f4c007c0a | | fa:16:3e:0e:95:24 | {"subnet_id": "e7b1f3dd-3397-445b-aa6d-881d70f4e5a0", "ip_address": "192.168.100.52"} |
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
删除端口
neutron port-delete <port_id>
[root@controller ~]# neutron port-delete 3f80b739-5c75-4317-8fdc-a4ab4d195d51
Deleted port: 3f80b739-5c75-4317-8fdc-a4ab4d195d51
[root@controller ~]# neutron port-delete dca0e651-38c8-427d-8d48-af0f4c007c0a
Deleted port: dca0e651-38c8-427d-8d48-af0f4c007c0a
删除子网
列出所有子网,获得要删除子网的subnet_id
# neutron subnet-list
[root@controller ~]# neutron subnet-list
+--------------------------------------+------------+------------------+-------------------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+------------+------------------+-------------------------------------------------------+
| d8a13476-2952-4618-a968-6a7d524b76c2 | int-subnet | 192.168.0.0/24 | {"start": "192.168.0.50", "end": "192.168.0.150"} |
| e7b1f3dd-3397-445b-aa6d-881d70f4e5a0 | net-subnet | 192.168.100.0/24 | {"start": "192.168.100.50", "end": "192.168.100.150"} |
+--------------------------------------+------------+------------------+-------------------------------------------------------+
列出网络,获得要删除的网络id
[root@controller ~]# neutron subnet-list
+--------------------------------------+------------+------------------+-------------------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+------------+------------------+-------------------------------------------------------+
| d8a13476-2952-4618-a968-6a7d524b76c2 | int-subnet | 192.168.0.0/24 | {"start": "192.168.0.50", "end": "192.168.0.150"} |
| e7b1f3dd-3397-445b-aa6d-881d70f4e5a0 | net-subnet | 192.168.100.0/24 | {"start": "192.168.100.50", "end": "192.168.100.150"} |
+--------------------------------------+------------+------------------+-------------------------------------------------------+
根据获得的网络id,删除网络
# neutron net-delete <net-id>
[root@controller ~]# neutron subnet-delete d8a13476-2952-4618-a968-6a7d524b76c2
Deleted subnet: d8a13476-2952-4618-a968-6a7d524b76c2
参考博客:
清除OpenStack网络与路由
https://www.cnblogs.com/jimmy-xuli/p/8858376.html
转载于:https://www.cnblogs.com/djlsunshine/p/10293258.html