Merge "ovs: raise RuntimeError in _get_dp if id is None"
This commit is contained in:
commit
26b744740e
|
@ -42,10 +42,12 @@ class OVSAgentBridge(ofswitch.OpenFlowSwitchMixin,
|
|||
"""
|
||||
while True:
|
||||
if self._cached_dpid is None:
|
||||
dpid_str = self.get_datapath_id()
|
||||
dpid = self.get_datapath_id()
|
||||
LOG.info("Bridge %(br_name)s has datapath-ID %(dpid)s",
|
||||
{"br_name": self.br_name, "dpid": dpid_str})
|
||||
self._cached_dpid = int(dpid_str, 16)
|
||||
{"br_name": self.br_name, "dpid": dpid})
|
||||
if dpid is None:
|
||||
raise RuntimeError("Unknown datapath id.")
|
||||
self._cached_dpid = int(dpid, 16)
|
||||
try:
|
||||
dp = self._get_dp_by_dpid(self._cached_dpid)
|
||||
return dp, dp.ofproto, dp.ofproto_parser
|
||||
|
|
|
@ -49,3 +49,8 @@ class OVSAgentBridgeTestCase(ovs_test_base.OVSRyuTestBase):
|
|||
# make sure that in case of any misconfiguration when no datapath is
|
||||
# found a proper exception, not a TypeError is raised
|
||||
self.assertRaises(RuntimeError, br._get_dp)
|
||||
|
||||
def test__get_dp_when_get_datapath_id_returns_None(self):
|
||||
br = self.br_int_cls('br-int')
|
||||
with mock.patch.object(br, 'get_datapath_id', return_value=None):
|
||||
self.assertRaises(RuntimeError, br._get_dp)
|
||||
|
|
Loading…
Reference in New Issue