Fix mishandling of BirdErrors in BirdSocketTopologyProvider

styling
LEdoian 1 year ago
parent 2cb43bbc9f
commit 61b058bcfc

@ -454,8 +454,8 @@ class ProcessTopologyProvider(TopologyProvider):
class BirdMultipleInstancesError(BirdError):
"""BIRD has multiple known OSPF's running.
This exception is intended to be created from existing BirdError. (We do
not re-raise, because we know what has happened.)"""
This exception is intended to be created from existing BirdError. (We stil
re-raise, so the error message is sane.)"""
def __init__(self, orig_exc: BirdError, protocols: list[str]):
for attr in ['code', 'start', 'end', 'text']:
val = getattr(orig_exc, attr)
@ -493,9 +493,9 @@ class BirdSocketTopologyProvider(TopologyProvider):
try:
response = sock.request(request)
except BirdError as e:
if e.text == 'There are multiple OSPF protocols running':
if e.text == 'There are multiple OSPF protocols running\n':
protocols = self.find_runing_ospf(sock)
raise BirdMultipleInstancesError(e, protocols)
raise BirdMultipleInstancesError(e, protocols) from e
raise
parser = OspfFileTopologyParser(version=self.version, area=self.area)
return parser.parse(response.text, freeze=self.freeze)
@ -507,7 +507,7 @@ class BirdSocketTopologyProvider(TopologyProvider):
assert len(resp.codes) == 3
assert resp.codes[0] == ((1,1), '2002')
assert resp.codes[1][1] == '1002'
lines = resp.splitlines()
lines = resp.text.splitlines()
header = lines[0]
fields = header.split()
assert fields[0] == 'Name'

Loading…
Cancel
Save