Merge "of_native: Use int for comparing datapath ID" into stable/pike

This commit is contained in:
Jenkins 2017-10-14 00:41:20 +00:00 committed by Gerrit Code Review
commit 8255dce02a
2 changed files with 10 additions and 9 deletions

View File

@ -55,17 +55,16 @@ class OVSAgentBridge(ofswitch.OpenFlowSwitchMixin,
# NOTE(yamamoto): Open vSwitch change its dpid on
# some events.
# REVISIT(yamamoto): Consider to set dpid statically.
old_dpid_str = format(self._cached_dpid, '0x')
new_dpid_str = self.get_datapath_id()
if new_dpid_str != old_dpid_str:
new_dpid = int(self.get_datapath_id(), 16)
if new_dpid != self._cached_dpid:
LOG.info("Bridge %(br_name)s changed its "
"datapath-ID from %(old)s to %(new)s", {
"datapath-ID from %(old)x to %(new)x", {
"br_name": self.br_name,
"old": old_dpid_str,
"new": new_dpid_str,
"old": self._cached_dpid,
"new": new_dpid,
})
ctx.reraise = False
self._cached_dpid = int(new_dpid_str, 16)
self._cached_dpid = new_dpid
def setup_controllers(self, conf):
controllers = [

View File

@ -18,18 +18,20 @@ import mock
from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent \
import ovs_test_base
DPID = "0003e9"
class OVSAgentBridgeTestCase(ovs_test_base.OVSRyuTestBase):
def test__get_dp(self):
mock.patch(
'neutron.agent.common.ovs_lib.OVSBridge.get_datapath_id',
return_value="3e9").start()
return_value=DPID).start()
mock.patch(
"neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native."
"ofswitch.OpenFlowSwitchMixin._get_dp_by_dpid",
side_effect=RuntimeError).start()
br = self.br_int_cls('br-int')
br._cached_dpid = int("3e9", 16)
br._cached_dpid = int(DPID, 16)
# make sure it correctly raises RuntimeError, not UnboundLocalError as
# in LP https://bugs.launchpad.net/neutron/+bug/1588042
self.assertRaises(RuntimeError, br._get_dp)