]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove unnecessary checks for MultipleResultsFound
authorEugene Nikanorov <enikanorov@mirantis.com>
Wed, 29 May 2013 08:38:29 +0000 (12:38 +0400)
committerEugene Nikanorov <enikanorov@mirantis.com>
Wed, 29 May 2013 09:20:21 +0000 (13:20 +0400)
fixes bug 1185080

MultipleResultsFound exception is never thrown because model
queries are filtered by their primary key.

Change-Id: Id4a4ff84e134d3f1d177509193c4a14f830dfcc9

quantum/db/db_base_plugin_v2.py
quantum/db/l3_db.py
quantum/plugins/nec/db/nec_plugin_base.py

index f7283cd32a945d92c4d0f987f092dbe8cac07e7f..aa569698a877bb62e532429d5b5850fa9cea1a60 100644 (file)
@@ -169,9 +169,6 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
             network = self._get_by_id(context, models_v2.Network, id)
         except exc.NoResultFound:
             raise q_exc.NetworkNotFound(net_id=id)
-        except exc.MultipleResultsFound:
-            LOG.error(_('Multiple networks match for %s'), id)
-            raise q_exc.NetworkNotFound(net_id=id)
         return network
 
     def _get_subnet(self, context, id):
@@ -179,9 +176,6 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
             subnet = self._get_by_id(context, models_v2.Subnet, id)
         except exc.NoResultFound:
             raise q_exc.SubnetNotFound(subnet_id=id)
-        except exc.MultipleResultsFound:
-            LOG.error(_('Multiple subnets match for %s'), id)
-            raise q_exc.SubnetNotFound(subnet_id=id)
         return subnet
 
     def _get_port(self, context, id):
@@ -191,9 +185,6 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
             # NOTE(jkoelker) The PortNotFound exceptions requires net_id
             #                kwarg in order to set the message correctly
             raise q_exc.PortNotFound(port_id=id, net_id=None)
-        except exc.MultipleResultsFound:
-            LOG.error(_('Multiple ports match for %s'), id)
-            raise q_exc.PortNotFound(port_id=id)
         return port
 
     def _get_dns_by_subnet(self, context, subnet_id):
index 19a363622e344e2c05d4d9153b2f1a0aa7cbe776..cea8d2f8768016bbae1847724b94eeb96206db59 100644 (file)
@@ -121,9 +121,6 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
             router = self._get_by_id(context, Router, id)
         except exc.NoResultFound:
             raise l3.RouterNotFound(router_id=id)
-        except exc.MultipleResultsFound:
-            LOG.error(_('Multiple routers match for %s'), id)
-            raise l3.RouterNotFound(router_id=id)
         return router
 
     def _make_router_dict(self, router, fields=None,
@@ -472,9 +469,6 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
             floatingip = self._get_by_id(context, FloatingIP, id)
         except exc.NoResultFound:
             raise l3.FloatingIPNotFound(floatingip_id=id)
-        except exc.MultipleResultsFound:
-            LOG.error(_('Multiple floating ips match for %s'), id)
-            raise l3.FloatingIPNotFound(floatingip_id=id)
         return floatingip
 
     def _make_floatingip_dict(self, floatingip, fields=None):
index 56bdb575f1ef043484dac5e7ca93e855cee69bfe..fedf81c9f4c6c6232677d06f585b746664b3ade8 100644 (file)
@@ -56,9 +56,6 @@ class NECPluginV2Base(db_base_plugin_v2.QuantumDbPluginV2):
             packet_filter = self._get_by_id(context, nmodels.PacketFilter, id)
         except exc.NoResultFound:
             raise q_exc.PacketFilterNotFound(id=id)
-        except exc.MultipleResultsFound:
-            LOG.error(_('Multiple packet_filters match for %s'), id)
-            raise q_exc.PacketFilterNotFound(id=id)
         return packet_filter
 
     def get_packet_filter(self, context, id, fields=None):