From db5952f2bb09a3997b3bef1904497a068fff59ce Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 15 Jun 2022 09:48:20 -0400 Subject: T2719: add reset command to the neighbor script --- src/op_mode/neighbor.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/op_mode') diff --git a/src/op_mode/neighbor.py b/src/op_mode/neighbor.py index 1f686843d..13ea46b8f 100755 --- a/src/op_mode/neighbor.py +++ b/src/op_mode/neighbor.py @@ -92,12 +92,25 @@ def show(raw: bool, family: str, interface: typing.Optional[str], state: typing. else: return format_neighbors(data, interface) +def reset(family: str, interface: typing.Optional[str], address: typing.Optional[str]): + from vyos.util import run + + if address and interface: + raise ValueError("interface and address parameters are mutually exclusive") + elif address: + run(f"""ip --family {family} neighbor flush to {address}""") + elif interface: + run(f"""ip --family {family} neighbor flush dev {interface}""") + else: + # Flush an entire neighbor table + run(f"""ip --family {family} neighbor flush""") -if __name__ == '__main__': - from argparse import ArgumentParser +if __name__ == '__main__': try: - print(opmode.run(sys.modules[__name__])) + res = opmode.run(sys.modules[__name__]) + if res: + print(res) except ValueError as e: print(e) sys.exit(1) -- cgit v1.2.3