From: Salvatore Orlando Date: Sat, 9 Mar 2013 00:30:39 +0000 (+0100) Subject: NVP plugin: return 409 if wrong router interface info on remove X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=4cf7deb940ea02042e6d95ca48cb250230969e4c;p=openstack-build%2Fneutron-build.git NVP plugin: return 409 if wrong router interface info on remove Bug 1152167 Raise an exception causing a 409 error to be returned if port_id or subnet_id specified in request body do not exist before further processing the operation (which will cause a 500 error to be returned to the user) Change-Id: I347dd86da87ce5b1e57e139e4c21d4533a456cbc --- diff --git a/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py b/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py index 5c66047a8..349e9f276 100644 --- a/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py +++ b/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py @@ -1764,6 +1764,10 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2, port = self._get_port(context, port_id) if port.get('fixed_ips'): subnet_id = port['fixed_ips'][0]['subnet_id'] + if not (port['device_owner'] == l3_db.DEVICE_OWNER_ROUTER_INTF and + port['device_id'] == router_id): + raise l3.RouterInterfaceNotFound(router_id=router_id, + port_id=port_id) elif 'subnet_id' in interface_info: subnet_id = interface_info['subnet_id'] subnet = self._get_subnet(context, subnet_id) @@ -1776,6 +1780,9 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2, if p['fixed_ips'][0]['subnet_id'] == subnet_id: port_id = p['id'] break + else: + raise l3.RouterInterfaceNotFoundForSubnet(router_id=router_id, + subnet_id=subnet_id) results = nvplib.query_lswitch_lports( cluster, '*', relations="LogicalPortAttachment", filters={'tag': port_id, 'tag_scope': 'q_port_id'})