From: Roman Podolyaka Date: Wed, 8 May 2013 15:34:51 +0000 (+0300) Subject: Fix usage of SQLAlchemy Query.first() method X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6d26dd57680ddcdfc3c31fbe2d7190e0f6d28d0d;p=openstack-build%2Fneutron-build.git Fix usage of SQLAlchemy Query.first() method Query.first() doesn't raise the NoResultFound exception if no result is found but rather returns None, so wrapping of Query.first() call into a try/except NoResultFound block is useless. Fixes bug 1177842. Change-Id: I0bd0e6d8299734b485dd1a1ac36bf6c295fd8932 --- diff --git a/quantum/plugins/nicira/nicira_qos_db.py b/quantum/plugins/nicira/nicira_qos_db.py index a251a3fe2..f719db4a5 100644 --- a/quantum/plugins/nicira/nicira_qos_db.py +++ b/quantum/plugins/nicira/nicira_qos_db.py @@ -132,16 +132,10 @@ class NVPQoSDbMixin(ext_qos.QueuePluginBase): def _delete_network_queue_mapping(self, context, network_id): query = self._model_query(context, NetworkQueueMapping) - try: - with context.session.begin(subtransactions=True): - binding = query.filter_by(network_id=network_id).first() - if binding: - context.session.delete(binding) - except exc.NoResultFound: - # return since this can happen if we are updating a port that - # did not already have a queue on it. There is no need to check - # if there is one before deleting if we return here. - return + with context.session.begin(subtransactions=True): + binding = query.filter_by(network_id=network_id).first() + if binding: + context.session.delete(binding) def _extend_port_qos_queue(self, context, port): if self._check_view_auth(context, {'qos_queue': None},