From 7fbdf77706c112382cd4e90c00c23420b5540f78 Mon Sep 17 00:00:00 2001 From: Thomas Morin Date: Tue, 28 Mar 2017 08:46:38 -0500 Subject: [PATCH] raise Exception instead of LOG.error on cookie/mask inconsistency Follow up to a comment by kevinbenton on Idd0531cedda87224531cb8fb6a912ccd0f1554d5 . The rationale is that one should never call delete a flow with cookie=ANY_COOKIE and give a cookie_mask at the same time. Change-Id: I20a03cb04f1bd3eb7a851e5458e2c662cfa3b132 --- neutron/agent/common/ovs_lib.py | 4 ++-- .../drivers/openvswitch/agent/openflow/native/ofswitch.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/neutron/agent/common/ovs_lib.py b/neutron/agent/common/ovs_lib.py index 249a8ba64e1..7ebdceff838 100644 --- a/neutron/agent/common/ovs_lib.py +++ b/neutron/agent/common/ovs_lib.py @@ -345,8 +345,8 @@ class OVSBridge(BaseOVS): # cookie to match flows whatever their cookie is kw.pop('cookie') if kw.get('cookie_mask'): # non-zero cookie mask - LOG.error(_LE("cookie=COOKIE_ANY but cookie_mask set " - "to %s"), kw.get('cookie_mask')) + raise Exception("cookie=COOKIE_ANY but cookie_mask " + "set to %s" % kw.get('cookie_mask')) elif 'cookie' in kw: # a cookie was specified, use it kw['cookie'] = check_cookie_mask(kw['cookie']) diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py index 1531ae3bd2a..9465612e25f 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py @@ -23,7 +23,7 @@ from oslo_utils import timeutils import ryu.app.ofctl.api as ofctl_api import ryu.exception as ryu_exc -from neutron._i18n import _, _LW, _LE +from neutron._i18n import _, _LW from neutron.agent.common import ovs_lib LOG = logging.getLogger(__name__) @@ -112,8 +112,8 @@ class OpenFlowSwitchMixin(object): if cookie == ovs_lib.COOKIE_ANY: cookie = 0 if cookie_mask != 0: - LOG.error(_LE("cookie=COOKIE_ANY but cookie_mask set to %s"), - cookie_mask) + raise Exception("cookie=COOKIE_ANY but cookie_mask set to %s" % + cookie_mask) elif cookie == COOKIE_DEFAULT: cookie = self._default_cookie cookie_mask = ovs_lib.UINT64_BITMASK