summaryrefslogtreecommitdiff
path: root/src/op_mode/neighbor.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-03-03 11:30:27 -0600
committerJohn Estabrook <jestabro@vyos.io>2023-03-05 19:38:07 -0600
commit1e72e1c68a708518526b8e090f5d6482671cbd57 (patch)
treeb1b040241ad157ba8cc165b42d47cf8d00fa5fc7 /src/op_mode/neighbor.py
parentae2db32a13d78c5014c7b770f2de28949a13a6c3 (diff)
downloadvyos-1x-1e72e1c68a708518526b8e090f5d6482671cbd57.tar.gz
vyos-1x-1e72e1c68a708518526b8e090f5d6482671cbd57.zip
op-mode: T5051: use typing.Literal in op-mode scripts
Diffstat (limited to 'src/op_mode/neighbor.py')
-rwxr-xr-xsrc/op_mode/neighbor.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/op_mode/neighbor.py b/src/op_mode/neighbor.py
index 264dbdc72..b329ea280 100755
--- a/src/op_mode/neighbor.py
+++ b/src/op_mode/neighbor.py
@@ -32,6 +32,9 @@ import typing
import vyos.opmode
+ArgFamily = typing.Literal['inet', 'inet6']
+ArgState = typing.Literal['reachable', 'stale', 'failed', 'permanent']
+
def interface_exists(interface):
import os
return os.path.exists(f'/sys/class/net/{interface}')
@@ -88,7 +91,8 @@ def format_neighbors(neighs, interface=None):
headers = ["Address", "Interface", "Link layer address", "State"]
return tabulate(neighs, headers)
-def show(raw: bool, family: str, interface: typing.Optional[str], state: typing.Optional[str]):
+def show(raw: bool, family: ArgFamily, interface: typing.Optional[str],
+ state: typing.Optional[ArgState]):
""" Display neighbor table contents """
data = get_raw_data(family, interface, state=state)
@@ -97,7 +101,7 @@ 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]):
+def reset(family: ArgFamily, interface: typing.Optional[str], address: typing.Optional[str]):
from vyos.util import run
if address and interface: