]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
NVP plugin: return 409 if wrong router interface info on remove
authorSalvatore Orlando <salv.orlando@gmail.com>
Sat, 9 Mar 2013 00:30:39 +0000 (01:30 +0100)
committerSalvatore Orlando <salv.orlando@gmail.com>
Sat, 9 Mar 2013 00:30:39 +0000 (01:30 +0100)
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

quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py

index 5c66047a88088cd7b8563c773566258a79e37f82..349e9f2766b8e8527094ba1e50af289a63023e99 100644 (file)
@@ -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'})