napalm_netgear/netgear_smart.py:130 and napalm_tplink_jetstream/tplink_jetstream.py:103 are identical.
napalm_openwrt/openwrt.py:98 is the same without enable().
napalm_linux/linux.py:285 is the same plus stty and package-manager detection.
is_alive()
Identical in netgear_smart.py:159, openwrt.py:127 and tplink_jetstream.py:131.
The same check on self._device instead of self.device in linux.py:322 and napalm_procurve/procurve.py:221; procurve adds a REST branch.
_send_command() has the same shape in netgear_smart.py:172, tplink_jetstream.py:149 and procurve.py:353: a single command or a list, then the fallback, with socket errors mapped to ConnectionClosedException.
The inner _do_send closure is identical in all three.
What differs is the error markers: "Invalid"/"Error", "% Invalid"/"Error", and "Invalid input"/"% Invalid"/"Error".
The expect string is rebuilt inline each time, although it equals each driver's own _exec_prompt().
Exit status._split_status, which splits a command's output from its echo <marker>$?, exists in napalm_linux/linux.py:98 and napalm_openwrt/system_mixin.py:29.
linux strips terminal codes and removes only the last marker.
openwrt removes every marker and keeps terminal codes.
One implementation belongs next to _send_command.
Also:netgear_smart.py:148 raises a German message ("Verbindungsaufbau fehlgeschlagen …"), and the message text belongs in English.
Proposal
A NetmikoSessionMixin in napalm_device_types/netmiko_session.py with concrete open, close, is_alive and _send_command.
Hooks: _CLI_ERROR_MARKERS, _command_prompt() (None for a shell without expect string), _ENABLE_ON_OPEN, _after_open().
One name for the session attribute.
napalm>=4 already brings netmiko, so this adds no dependency.
Prio P3: five copies of the transport layer; a fix in one (for example a timeout) does not reach the others.
From the NetOrk function index (NetOrk/netork#670); every location was checked against the current code. Paths are relative to each driver repo.
Five drivers carry the same netmiko session code.
**`open()`**
- `napalm_netgear/netgear_smart.py`:130 and `napalm_tplink_jetstream/tplink_jetstream.py`:103 are identical.
- `napalm_openwrt/openwrt.py`:98 is the same without `enable()`.
- `napalm_linux/linux.py`:285 is the same plus `stty` and package-manager detection.
**`is_alive()`**
- Identical in `netgear_smart.py`:159, `openwrt.py`:127 and `tplink_jetstream.py`:131.
- The same check on `self._device` instead of `self.device` in `linux.py`:322 and `napalm_procurve/procurve.py`:221; procurve adds a REST branch.
**`_send_command()`** has the same shape in `netgear_smart.py`:172, `tplink_jetstream.py`:149 and `procurve.py`:353: a single command or a list, then the fallback, with socket errors mapped to `ConnectionClosedException`.
- The inner `_do_send` closure is identical in all three.
- What differs is the error markers: "Invalid"/"Error", "% Invalid"/"Error", and "Invalid input"/"% Invalid"/"Error".
- The expect string is rebuilt inline each time, although it equals each driver's own `_exec_prompt()`.
**Exit status.** `_split_status`, which splits a command's output from its `echo <marker>$?`, exists in `napalm_linux/linux.py`:98 and `napalm_openwrt/system_mixin.py`:29.
- linux strips terminal codes and removes only the last marker.
- openwrt removes every marker and keeps terminal codes.
One implementation belongs next to `_send_command`.
**Also:** `netgear_smart.py`:148 raises a German message ("Verbindungsaufbau fehlgeschlagen …"), and the message text belongs in English.
**Proposal**
- A `NetmikoSessionMixin` in `napalm_device_types/netmiko_session.py` with concrete `open`, `close`, `is_alive` and `_send_command`.
- Hooks: `_CLI_ERROR_MARKERS`, `_command_prompt()` (None for a shell without expect string), `_ENABLE_ON_OPEN`, `_after_open()`.
- One name for the session attribute.
- napalm>=4 already brings netmiko, so this adds no dependency.
This is the base NAPALM/napalm-device-types#9 builds on.
Prio P3: five copies of the transport layer; a fix in one (for example a timeout) does not reach the others.
From the NetOrk function index (NetOrk/netork#670); every location was checked against the current code. Paths are relative to each driver repo.
Re-homed by docs/STRUCTURE.md (NAPALM/napalm-device-types#37, NetOrk/netork#1105): napalm-device-types stays free of transport code, so a shared netmiko session does not go here. If it is worth sharing, it belongs in a CLI-driver helper package; otherwise it stays in the drivers.
Re-homed by `docs/STRUCTURE.md` (NAPALM/napalm-device-types#37, NetOrk/netork#1105): napalm-device-types stays free of transport code, so a shared netmiko session does not go here. If it is worth sharing, it belongs in a CLI-driver helper package; otherwise it stays in the drivers.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Five drivers carry the same netmiko session code.
open()napalm_netgear/netgear_smart.py:130 andnapalm_tplink_jetstream/tplink_jetstream.py:103 are identical.napalm_openwrt/openwrt.py:98 is the same withoutenable().napalm_linux/linux.py:285 is the same plussttyand package-manager detection.is_alive()netgear_smart.py:159,openwrt.py:127 andtplink_jetstream.py:131.self._deviceinstead ofself.deviceinlinux.py:322 andnapalm_procurve/procurve.py:221; procurve adds a REST branch._send_command()has the same shape innetgear_smart.py:172,tplink_jetstream.py:149 andprocurve.py:353: a single command or a list, then the fallback, with socket errors mapped toConnectionClosedException._do_sendclosure is identical in all three._exec_prompt().Exit status.
_split_status, which splits a command's output from itsecho <marker>$?, exists innapalm_linux/linux.py:98 andnapalm_openwrt/system_mixin.py:29.One implementation belongs next to
_send_command.Also:
netgear_smart.py:148 raises a German message ("Verbindungsaufbau fehlgeschlagen …"), and the message text belongs in English.Proposal
NetmikoSessionMixininnapalm_device_types/netmiko_session.pywith concreteopen,close,is_aliveand_send_command._CLI_ERROR_MARKERS,_command_prompt()(None for a shell without expect string),_ENABLE_ON_OPEN,_after_open().This is the base NAPALM/napalm-device-types#9 builds on.
Prio P3: five copies of the transport layer; a fix in one (for example a timeout) does not reach the others.
From the NetOrk function index (NetOrk/netork#670); every location was checked against the current code. Paths are relative to each driver repo.
Re-homed by
docs/STRUCTURE.md(NAPALM/napalm-device-types#37, NetOrk/netork#1105): napalm-device-types stays free of transport code, so a shared netmiko session does not go here. If it is worth sharing, it belongs in a CLI-driver helper package; otherwise it stays in the drivers.