def execute(self): r = [] s = self.cli("show bfd session extensive") for bs in find_indented(s): match = self.rx_session.search(bs) if match: r += [{ # "local_address": IPParameter(), "remote_address": match.group("remote_address"), "local_interface": match.group("local_interface"), "local_discriminator": int(match.group("local_discriminator")), "remote_discriminator": int(match.group("remote_discriminator")), "state": match.group("state").upper(), "clients": [ self.client_map[c] for c in match.group("client").split() ], # Transmit interval, microseconds "tx_interval": float(match.group("transmit")) * 1000000, "multiplier": int(match.group("multiplier")), # Detection time, microseconds "detect_time": float(match.group("detect_time")) * 1000000, }] return r
def test_find_indented(config, expected): assert find_indented(config) == expected