Openstack 清除openstack网络与路由 (十七)

一)清除openstack网络与路由

“清除openstack网络与路由”和”添加openstack网络与路由”的操作步骤相反。

添加网络或路由时是先建

搭建网络>搭建子网>建立端口,

而清除网络与路由则相反,顺序如下:

删除网络的顺序

删除设备的顺序>删除端口->删除设备

删除路由

删除设备端口->删除子网->删除网络

下面,我们以删除一个路由设备为例,讲解整个过程(以下命令都在控制节点执行)。

1.列出所有路由设备,获得要删除的路由器id

# neutron router-list
[root@controller ~]# neutron router-list
+-------------------------------------+--------+--------------------------------------+-------------+-------+
| id | name | external_gateway_info | distributed | ha |
+-------------------------------------+--------+--------------------------------------+-------------+-------+
| 9f708e67-a46b-4c2d- | router | {"network_id": "4e716df7-3f74-409e- | False | False |
| abb9-5993457bb1b5 | | af54-69a4d22b9b33", "enable_snat": | | |
| | | true, "external_fixed_ips": | | |
| | | [{"subnet_id": "569ccbbf-2081-45be-a | | |
| | | 221-4a6bfb3df17a", "ip_address": | | |
| | | "203.0.113.108"}]} | | |
+-------------------------------------+--------+--------------------------------------+-------------+-------+

2 根据路由器id,删除其网关端口

# neutron router-gateway-clear <router_id>
[root@controller ~]# neutron router-gateway-clear 9f708e67-a46b-4c2d-abb9-5993457bb1b5
Removed gateway from router 9f708e67-a46b-4c2d-abb9-5993457bb1b5

3.根据路由设备id,列出其其他端口

# neutron router-port-list <router_id>
[root@controller ~]# neutron router-port-list 9f708e67-a46b-4c2d-abb9-5993457bb1b5
+--------------------------------------+------+-------------------+----------------------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+----------------------------------------+
| 7d4671ce-e1f4-4007-947c-213139dcb8da | | fa:16:3e:f3:31:ad | {"subnet_id": "0809f03e-a454-4dee- |
| | | | afdf-2e0db8b79f76", "ip_address": |
| | | | "172.16.1.1"} |
+--------------------------------------+------+-------------------+----------------------------------------+

4.根据路由器id与subnet_id删除路由器其他端口

# neutron router-interface-delete <router-id> <subnet-id>
[root@controller ~]# neutron router-interface-delete 9f708e67-a46b-4c2d-abb9-5993457bb1b5 7d4671ce-e1f4-4007-947c-213139dcb8da
[root@controller ~]# neutron router-interface-delete 9f708e67-a46b-4c2d-abb9-5993457bb1b5 0809f03e-a454-4dee-afdf-2e0db8b79f76
Removed interface from router 9f708e67-a46b-4c2d-abb9-5993457bb1b5.

5.最后删除路由

# neutron router-delete <router-id>
[root@controller ~]# neutron router-delete 9f708e67-a46b-4c2d-abb9-5993457bb1b5
Deleted router(s): 9f708e67-a46b-4c2d-abb9-5993457bb1b5

6.列出所有使用网络的端口

neutron port-list
[root@controller ~]# neutron port-list
+--------------------------------------+------+-------------------+----------------------------------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+----------------------------------------------------+
| 113de2ee-fb17-4a48-acfe-6264eeae192c | | fa:16:3e:5b:35:7f | {"subnet_id": "0809f03e-a454-4dee-afdf- |
| | | | 2e0db8b79f76", "ip_address": "172.16.1.2"} |
| c1b00df5-37e8-4cfa-a892-4297b5de01c6 | | fa:16:3e:da:3a:fa | {"subnet_id": |
| | | | "569ccbbf-2081-45be-a221-4a6bfb3df17a", |
| | | | "ip_address": "203.0.113.101"} |

7.删除端口

neutron port-delete <port_id>
[root@controller ~]# neutron port-delete 113de2ee-fb17-4a48-acfe-6264eeae192c
Deleted port(s): 113de2ee-fb17-4a48-acfe-6264eeae192c
[root@controller ~]# neutron port-delete c1b00df5-37e8-4cfa-a892-4297b5de01c6
Deleted port(s): c1b00df5-37e8-4cfa-a892-4297b5de01c6

8.删除子网

列出所有子网,获得要删除子网的subnet_id
# neutron subnet-list
[root@controller ~]# neutron subnet-list
+--------------------------------------+-------------+----------------+----------------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+-------------+----------------+----------------------------------------------------+
| 0809f03e-a454-4dee-afdf-2e0db8b79f76 | selfservice | 172.16.1.0/24 | {"start": "172.16.1.2", "end": "172.16.1.254"} |
| 569ccbbf-2081-45be-a221-4a6bfb3df17a | provider | 203.0.113.0/24 | {"start": "203.0.113.101", "end": "203.0.113.250"} |
+--------------------------------------+-------------+----------------+----------------------------------------------------+

9.列出网络,获得要删除的网络id

# neutron net-list
[root@controller ~]# neutron subnet-list
+--------------------------------------+-------------+----------------+----------------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+-------------+----------------+----------------------------------------------------+
| 0809f03e-a454-4dee-afdf-2e0db8b79f76 | selfservice | 172.16.1.0/24 | {"start": "172.16.1.2", "end": "172.16.1.254"} |
| 569ccbbf-2081-45be-a221-4a6bfb3df17a | provider | 203.0.113.0/24 | {"start": "203.0.113.101", "end": "203.0.113.250"} |
+--------------------------------------+-------------+----------------+----------------------------------------------------+

10.根据获得的网络id,删除网络

# neutron net-delete <net-id>
[root@controller ~]# neutron subnet-delete 0809f03e-a454-4dee-afdf-2e0db8b79f76
Deleted subnet(s): 0809f03e-a454-4dee-afdf-2e0db8b79f76
[root@controller ~]# neutron subnet-delete 569ccbbf-2081-45be-a221-4a6bfb3df17a Deleted subnet(s): 569ccbbf-2081-45be-a221-4a6bfb3df17a

  

 

posted @ 2018-04-16 20:34  jimmy_xuli  阅读(3949)  评论(0编辑  收藏  举报