OpenStack neutron删除网络设备出错解决办法
目标:要删除外网Ext-Net2
直接删网络也会出错:因为有一个或多个端口在使用该网络
root@controller:~# neutron net-list
+--------------------------------------+-------------+----------------------------------------------------+
| id | name | subnets |
+--------------------------------------+-------------+----------------------------------------------------+
| 739485b6-bc45-4a53-953d-f3c4cb07f601 | Ext-Net2 | ef86e785-8cec-486a-b67f-dcbba5311293 10.100.0.0/24 |
| 7c22bbd9-166c-4610-9a3d-3b8b92c77518 | tenantA-Net | c37d8ed0-372e-4b24-9ba2-897c38c6ddbf 10.0.0.0/24 |
| c8699820-7c6d-4441-9602-3425f2c630ec | Ext-Net | 2c4155c9-5a2e-471c-a4d8-40a86b45ab0a 10.1.101.0/24 |
+--------------------------------------+-------------+----------------------------------------------------+
root@controller:~# neutron net-delete 739485b6-bc45-4a53-953d-f3c4cb07f601
Unable to complete operation on network 739485b6-bc45-4a53-953d-f3c4cb07f601. There are one or more ports still in use on the network.
查看子网:删除子网会出错:一个或多个端口用了这个子网分配的浮动IP。
root@controller:~# neutron subnet-list
+--------------------------------------+-----------------+---------------+--------------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+-----------------+---------------+--------------------------------------------------+
| 2c4155c9-5a2e-471c-a4d8-40a86b45ab0a | | 10.1.101.0/24 | {"start": "10.1.101.80", "end": "10.1.101.100"} |
| c37d8ed0-372e-4b24-9ba2-897c38c6ddbf | | 10.0.0.0/24 | {"start": "10.0.0.2", "end": "10.0.0.254"} |
| ef86e785-8cec-486a-b67f-dcbba5311293 | subNet-Ext-Net2 | 10.100.0.0/24 | {"start": "10.100.0.100", "end": "10.100.0.120"} |
+--------------------------------------+-----------------+---------------+--------------------------------------------------+
root@controller:~# neutron subnet-delete ef86e785-8cec-486a-b67f-dcbba5311293
409-{u'NeutronError': {u'message': u'Unable to complete operation on subnet ef86e785-8cec-486a-b67f-dcbba5311293. One or more ports have an IP allocation from this subnet.', u'type': u'SubnetInUse', u'detail': u''}}
直接删port会出错,因为端口有浮点IP所以不能直接删除
root@controller:~# neutron port-list
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| 1653ec91-ad7d-40d9-b777-f74aec697026 | | fa:16:3e:51:a2:97 | {"subnet_id": "c37d8ed0-372e-4b24-9ba2-897c38c6ddbf", "ip_address": "10.0.0.9"} |
| 2df7c3ed-dfbb-480d-9cd3-fdefa079e66a | | fa:16:3e:da:41:49 | {"subnet_id": "c37d8ed0-372e-4b24-9ba2-897c38c6ddbf", "ip_address": "10.0.0.3"} |
| 81388454-30e0-45e4-b3dd-b7b2e8dbf067 | | fa:16:3e:f7:e6:9c | {"subnet_id": "c37d8ed0-372e-4b24-9ba2-897c38c6ddbf", "ip_address": "10.0.0.1"} |
| accd8dbf-0f16-4aec-b797-bbb33abcdc83 | | fa:16:3e:97:ee:cb | {"subnet_id": "ef86e785-8cec-486a-b67f-dcbba5311293", "ip_address": "10.100.0.103"} |
| bfe7eaa4-26bc-4fe9-9da2-550abf44beaa | | fa:16:3e:e1:00:41 | {"subnet_id": "2c4155c9-5a2e-471c-a4d8-40a86b45ab0a", "ip_address": "10.1.101.83"} |
| d7233b80-9d4b-4ef6-a60d-19b3be661069 | | fa:16:3e:75:e0:5a | {"subnet_id": "c37d8ed0-372e-4b24-9ba2-897c38c6ddbf", "ip_address": "10.0.0.10"} |
| eb60f9c4-2ddb-49ee-8b78-2fc2564a7600 | | fa:16:3e:78:39:e9 | {"subnet_id": "2c4155c9-5a2e-471c-a4d8-40a86b45ab0a", "ip_address": "10.1.101.80"} |
| f6812a11-c4ce-4880-8566-2206afcc612a | | fa:16:3e:9e:75:a2 | {"subnet_id": "2c4155c9-5a2e-471c-a4d8-40a86b45ab0a", "ip_address": "10.1.101.82"} |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
root@controller:~# neutron port-delete accd8dbf-0f16-4aec-b797-bbb33abcdc83
409-{u'NeutronError': {u'message': u'Port accd8dbf-0f16-4aec-b797-bbb33abcdc83 has owner network:floatingip and therefore cannot be deleted directly via the port API.', u'type': u'L3PortInUse', u'detail': u''}}
但是却查不到浮动IP
root@controller:~# nova floating-ip-list +----+-----------+----------+------+ | Ip | Server Id | Fixed Ip | Pool | +----+-----------+----------+------+ +----+-----------+----------+------+
root@controller:~# nova floating-ip-delete 10.100.0.103 ERROR: Floating ip 10.100.0.103 not found.
解除绑定浮动IP:这样做也不可行,因为这个ID不是虚拟机的ID。
root@controller:~# neutron port-list +--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+ | id | name | mac_address | fixed_ips | +--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+ | 1653ec91-ad7d-40d9-b777-f74aec697026 | | fa:16:3e:51:a2:97 | {"subnet_id": "c37d8ed0-372e-4b24-9ba2-897c38c6ddbf", "ip_address": "10.0.0.9"} | | 2df7c3ed-dfbb-480d-9cd3-fdefa079e66a | | fa:16:3e:da:41:49 | {"subnet_id": "c37d8ed0-372e-4b24-9ba2-897c38c6ddbf", "ip_address": "10.0.0.3"} | | 81388454-30e0-45e4-b3dd-b7b2e8dbf067 | | fa:16:3e:f7:e6:9c | {"subnet_id": "c37d8ed0-372e-4b24-9ba2-897c38c6ddbf", "ip_address": "10.0.0.1"} | | accd8dbf-0f16-4aec-b797-bbb33abcdc83 | | fa:16:3e:97:ee:cb | {"subnet_id": "ef86e785-8cec-486a-b67f-dcbba5311293", "ip_address": "10.100.0.103"} | | bfe7eaa4-26bc-4fe9-9da2-550abf44beaa | | fa:16:3e:e1:00:41 | {"subnet_id": "2c4155c9-5a2e-471c-a4d8-40a86b45ab0a", "ip_address": "10.1.101.83"} | | d7233b80-9d4b-4ef6-a60d-19b3be661069 | | fa:16:3e:75:e0:5a | {"subnet_id": "c37d8ed0-372e-4b24-9ba2-897c38c6ddbf", "ip_address": "10.0.0.10"} | | eb60f9c4-2ddb-49ee-8b78-2fc2564a7600 | | fa:16:3e:78:39:e9 | {"subnet_id": "2c4155c9-5a2e-471c-a4d8-40a86b45ab0a", "ip_address": "10.1.101.80"} | | f6812a11-c4ce-4880-8566-2206afcc612a | | fa:16:3e:9e:75:a2 | {"subnet_id": "2c4155c9-5a2e-471c-a4d8-40a86b45ab0a", "ip_address": "10.1.101.82"} | +--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+ root@controller:~# nova floating-ip-disassociate accd8dbf-0f16-4aec-b797-bbb33abcdc83 10.100.0.103 ERROR: No server with a name or ID of 'accd8dbf-0f16-4aec-b797-bbb33abcdc83' exists.
通过horizon查看,发现该浮动IP,没有被分配,但是用命令却查不到
root@controller:~# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 floating-ip-list ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500) (Request-ID: req-294eb77b-1615-46fb-93de-d10660a46b70)
没办法,只能手动从horizon释放掉浮动IP了。登录UserA,手动释放掉浮动IP10.100.0.3,现在就可以正常删除了。
现在删除Ext-Net2就没问题了。
root@controller:~# neutron net-list +--------------------------------------+-------------+----------------------------------------------------+ | id | name | subnets | +--------------------------------------+-------------+----------------------------------------------------+ | 739485b6-bc45-4a53-953d-f3c4cb07f601 | Ext-Net2 | ef86e785-8cec-486a-b67f-dcbba5311293 10.100.0.0/24 | | 7c22bbd9-166c-4610-9a3d-3b8b92c77518 | tenantA-Net | c37d8ed0-372e-4b24-9ba2-897c38c6ddbf 10.0.0.0/24 | | c8699820-7c6d-4441-9602-3425f2c630ec | Ext-Net | 2c4155c9-5a2e-471c-a4d8-40a86b45ab0a 10.1.101.0/24 | +--------------------------------------+-------------+----------------------------------------------------+ root@controller:~# neutron net-delete 739485b6-bc45-4a53-953d-f3c4cb07f601 Deleted network: 739485b6-bc45-4a53-953d-f3c4cb07f601
总结:用admin删除网络时注意,admin看不到租户分配的浮动IP,所以得用租户登录释放掉浮动IP。
目标:删除租户的网络
root@sc-ctrl01:~# neutron net-list +--------------------------------------+-------------+-------------------------------------------------------+ | id | name | subnets | +--------------------------------------+-------------+-------------------------------------------------------+ | 3ccfd309-df88-4301-bd96-7f9852bec855 | TenantB-Net | aa4b016f-dbf2-435e-9388-57824ae2c235 192.168.0.0/24 | | b009f565-10b5-407b-93e4-e187636cd99d | ext-net | ba2ddac5-5eaf-409a-a9c1-fdafd04d21d9 10.0.200.0/24 | +--------------------------------------+-------------+-------------------------------------------------------+ root@sc-ctrl01:~# neutron net-delete TenantB-Net Unable to complete operation on network 3ccfd309-df88-4301-bd96-7f9852bec855. There are one or more ports still in use on the network. (HTTP 409) (Request-ID: req-bcb58ccf-f95b-4a02-8f28-5384562dc0eb)
看一下子网
root@sc-ctrl01:~# neutron subnet-list +--------------------------------------+--------------------+------------------+------------------------------------------------------+ | id | name | cidr | allocation_pools | +--------------------------------------+--------------------+------------------+------------------------------------------------------+ | aa4b016f-dbf2-435e-9388-57824ae2c235 | TenantB-Net-SubNet | 192.168.0.0/24 | {"start": "192.168.0.2", "end": "192.168.0.254"} | | ba2ddac5-5eaf-409a-a9c1-fdafd04d21d9 | ext-subnet | 10.0.200.0/24 | {"start": "10.0.200.100", "end": "10.0.200.250"} | | 7fa4a398-b67b-462b-a9b3-c65802952f79 | sub_lxp_net | 192.168.1.0/24 | {"start": "192.168.1.150", "end": "192.168.1.200"} | | 2e985c9f-3668-417f-8b40-d7f551e668c0 | sub_lxp_net2 | 192.168.100.0/24 | {"start": "192.168.100.1", "end": "192.168.100.254"} | +--------------------------------------+--------------------+------------------+------------------------------------------------------+ root@sc-ctrl01:~# neutron port-list +--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+ | id | name | mac_address | fixed_ips | +--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+ | 6d0ec7ba-37e8-4784-8076-b2e39c3b8f00 | | fa:16:3e:8b:62:98 | {"subnet_id": "2e985c9f-3668-417f-8b40-d7f551e668c0", "ip_address": "192.168.100.3"} | | 7915e60f-a4d6-4f2c-875b-b402f8828571 | | fa:16:3e:54:f1:51 | {"subnet_id": "2e985c9f-3668-417f-8b40-d7f551e668c0", "ip_address": "192.168.100.1"} | | 963ceaa8-3750-449b-bebd-3f8e89e6dd0d | | fa:16:3e:96:29:98 | {"subnet_id": "7fa4a398-b67b-462b-a9b3-c65802952f79", "ip_address": "192.168.1.150"} | | a56330b4-3409-4b40-aadf-b0f2302b2c16 | | fa:16:3e:be:c9:54 | {"subnet_id": "2e985c9f-3668-417f-8b40-d7f551e668c0", "ip_address": "192.168.100.2"} | | b7792c1a-d284-494c-b1b8-8609f33957c3 | | fa:16:3e:1d:c1:d1 | {"subnet_id": "aa4b016f-dbf2-435e-9388-57824ae2c235", "ip_address": "192.168.0.1"} | | cdabb78e-11f1-4b0d-ab4d-59abba4c0ab1 | | fa:16:3e:1e:32:7f | {"subnet_id": "ba2ddac5-5eaf-409a-a9c1-fdafd04d21d9", "ip_address": "10.0.200.100"} | +--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+ root@sc-ctrl01:~# neutron port-delete b7792c1a-d284-494c-b1b8-8609f33957c3 Port b7792c1a-d284-494c-b1b8-8609f33957c3 has owner network:router_interface and therefore cannot be deleted directly via the port API. (HTTP 409) (Request-ID: req-500d34ea-9cdc-4566-b931-25fb934d9864)
要删port,先看路由
root@sc-ctrl01:~# neutron router-list +--------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+ | id | name | external_gateway_info | distributed | ha | +--------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+ | 9a5054d7-35a4-441f-a0fb-d5bf7070edc7 | TenantB-Router | {"network_id": "b009f565-10b5-407b-93e4-e187636cd99d", "enable_snat": true, "external_fixed_ips": [{"subnet_id": "ba2ddac5-5eaf-409a-a9c1-fdafd04d21d9", "ip_address": "10.0.200.100"}]} | False | False | +--------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+ root@sc-ctrl01:~# neutron router-delete TenantB-Router Router 9a5054d7-35a4-441f-a0fb-d5bf7070edc7 still has ports (HTTP 409) (Request-ID: req-282fe122-4cab-4595-9f63-825ad81f13b9)
路由接着外网和私网的子网。
所以先删路由上的网关
root@sc-ctrl01:~# neutron router-gateway-clear TenantB-Router Removed gateway from router TenantB-Router
再删路由上的接口,删除某个路由的某个接口
root@sc-ctrl01:~# neutron router-interface-delete TenantB-Router TenantB-Net-SubNet Removed interface from router TenantB-Router. root@sc-ctrl01:~#
port是关联路由和子网的。所以清掉路由上的接口,那port就没有了。
root@sc-ctrl01:~# neutron router-delete TenantB-Router Deleted router: TenantB-Router
接着删子网
root@sc-ctrl01:~# neutron subnet-delete TenantB-Net-SubNet Deleted subnet: TenantB-Net-SubNet
最后网络就可以删掉了
root@sc-ctrl01:~# neutron net-delete TenantB-Net Deleted network: TenantB-Net
如果觉得本文对您有帮助~可以
微信支持一下: