Skip to content

Commit 47cfa6d

Browse files
Noppesktbyers
andauthored
Nokia isam (#3725)
* nokia isam driver * error fix * nokia isam cleanup improvement * nokia isam check_config_mode improvement --------- Co-authored-by: Kirk Byers <[email protected]>
1 parent 75f3360 commit 47cfa6d

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

netmiko/nokia/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@
55
)
66

77
from netmiko.nokia.nokia_srl import NokiaSrlSSH
8+
from netmiko.nokia.nokia_isam import NokiaIsamSSH
89

9-
__all__ = ["NokiaSrosSSH", "NokiaSrosFileTransfer", "NokiaSrosTelnet", "NokiaSrlSSH"]
10+
__all__ = [
11+
"NokiaSrosSSH",
12+
"NokiaSrosFileTransfer",
13+
"NokiaSrosTelnet",
14+
"NokiaSrlSSH",
15+
"NokiaIsamSSH",
16+
]

netmiko/nokia/nokia_isam.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import time
2+
import re
3+
from typing import Any
4+
5+
from netmiko.base_connection import BaseConnection
6+
from netmiko.no_enable import NoEnable
7+
8+
9+
class NokiaIsamSSH(BaseConnection, NoEnable):
10+
11+
def session_preparation(self) -> None:
12+
self._test_channel_read()
13+
self.set_base_prompt()
14+
commands = [
15+
"environment inhibit-alarms",
16+
"environment screen-length 0",
17+
]
18+
for command in commands:
19+
self.disable_paging(command=command, cmd_verify=True, pattern=r"#")
20+
time.sleep(0.3 * self.global_delay_factor)
21+
self.clear_buffer()
22+
23+
def set_base_prompt(self, *args: Any, **kwargs: Any) -> str:
24+
"""Remove the > when navigating into the different config level."""
25+
cur_base_prompt = super().set_base_prompt(*args, **kwargs)
26+
match = re.search(r"\*?(.*?)(>.*)*#", cur_base_prompt)
27+
if match:
28+
# strip off >... from base_prompt; strip off leading *
29+
self.base_prompt: str = match.group(1)
30+
31+
return self.base_prompt
32+
33+
def cleanup(self, command: str = "logout") -> None:
34+
"""Gracefully exit the SSH session."""
35+
try:
36+
if self.check_config_mode():
37+
self.exit_config_mode()
38+
except Exception:
39+
pass
40+
# Always try to send final command
41+
if self.session_log:
42+
self.session_log.fin = True
43+
self.write_channel(command + self.RETURN)
44+
45+
def check_config_mode(
46+
self,
47+
check_string: str = ">configure",
48+
pattern: str = "#",
49+
force_regex: bool = False,
50+
) -> bool:
51+
"""Use equivalent enable method."""
52+
return super().check_config_mode(
53+
check_string=check_string, pattern=pattern, force_regex=force_regex
54+
)
55+
56+
def config_mode(
57+
self, config_command: str = "configure", pattern: str = "", re_flags: int = 0
58+
) -> str:
59+
return super().config_mode(
60+
config_command=config_command, pattern=pattern, re_flags=re_flags
61+
)
62+
63+
def exit_config_mode(self, exit_config: str = "exit", pattern: str = "") -> str:
64+
return super().exit_config_mode(exit_config=exit_config)
65+
66+
def save_config(
67+
self, cmd: str = "admin save", confirm: bool = False, confirm_response: str = ""
68+
) -> str:
69+
return self._send_command_str(
70+
command_string=cmd,
71+
strip_prompt=False,
72+
strip_command=False,
73+
)

netmiko/ssh_dispatcher.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
from netmiko.mrv import MrvOptiswitchSSH
126126
from netmiko.netapp import NetAppcDotSSH
127127
from netmiko.nokia import (
128+
NokiaIsamSSH,
128129
NokiaSrosSSH,
129130
NokiaSrosFileTransfer,
130131
NokiaSrosTelnet,
@@ -304,6 +305,7 @@
304305
"netapp_cdot": NetAppcDotSSH,
305306
"netgear_prosafe": NetgearProSafeSSH,
306307
"netscaler": NetscalerSSH,
308+
"nokia_isam": NokiaIsamSSH,
307309
"nokia_sros": NokiaSrosSSH,
308310
"nokia_srl": NokiaSrlSSH,
309311
"oneaccess_oneos": OneaccessOneOSSSH,

0 commit comments

Comments
 (0)