Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion annet/annlib/netdev/devdb/data/devdb.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,10 @@
"B4com.CS4100": "^[Bb]4com B4T-CS41.*",
"B4com.CS4132U": "^[Bb]4com B4T-CS4132U.*",
"B4com.CS4148Q": "^[Bb]4com B4T-CS4148Q.*",
"B4com.CS4164U": "^[Bb]4com B4T-CS4164U.*"
"B4com.CS4164U": "^[Bb]4com B4T-CS4164U.*",

"SNR": "^SNR",
"SNR.S5110G": "[-\\s]S5110G",
"SNR.S5210G": "[-\\s]S5210G",
"SNR.S5310G": "[-\\s]S5310G"
}
1 change: 1 addition & 0 deletions annet/vendors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
pc,
ribbon,
routeros,
snr,
)
from .registry import Registry, registry

Expand Down
41 changes: 41 additions & 0 deletions annet/vendors/library/snr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from annet.annlib.command import Command, CommandList
from annet.annlib.netdev.views.hardware import HardwareView
from annet.vendors.base import AbstractVendor
from annet.vendors.registry import registry
from annet.vendors.tabparser import SNRFormatter


@registry.register
class SNRVendor(AbstractVendor):
NAME = "snr"

def apply(self, hw: HardwareView, do_commit: bool, do_finalize: bool, path: str) -> tuple[CommandList, CommandList]:
before, after = CommandList(), CommandList()

before.add_cmd(Command("conf t"))
after.add_cmd(Command("exit"))
if do_finalize:
after.add_cmd(Command("copy running-config startup-config", timeout=40))

return before, after

def match(self) -> list[str]:
return ["SNR"]

@property
def reverse(self) -> str:
return "no"

@property
def hardware(self) -> HardwareView:
return HardwareView("SNR")

def svi_name(self, num: int) -> str:
return f"vlan{num}"

def make_formatter(self, **kwargs) -> SNRFormatter:
return SNRFormatter(**kwargs)

@property
def exit(self) -> str:
return "exit"
8 changes: 8 additions & 0 deletions annet/vendors/tabparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,14 @@ def cmd_paths(self, patch, _prev=""):
return commands


class SNRFormatter(BlockExitFormatter):
def __init__(self, indent=" "):
super().__init__("exit", indent)

def split(self, text):
return self.split_remove_spaces(text)


# ====


Expand Down
Loading