Skip to main content

a forked version of netmiko_multihop

Project description

netmiko_multihop is an out of tree netmiko monkeypatch which adds multihop capability. Currently following platforms are supported as intermediate hop:

  • linux

  • cisco_nxos

  • cisco_ios

Other platforms can be added easily if required.

Installation

Install the netmiko_multihop package by running:

pip3 install netmiko-multihop

Usage

import  netmiko_multihop
from netmiko import ConnectHandler


jumphost1 = {
    'device_type': 'linux',
    'ip': <ip_jumphost1>,
    'username': <ssh_username_jumphost1>,
    'password': <ssh_password_jumphost1>,
    'port': 22,
}

jumphost2 = {
    'device_type': 'linux',
    'ip': <ip_jumphost2>,
    'username': <ssh_username_jumphost2>,
    'password': <ssh_password_jumphost2>,
    'port': 22,
}

target1 = {
    'device_type': 'cisco_nxos',
    'ip': <ip_target1>,
    'username': <ssh_username_target1>,,
    'password': <ssh_password_target1>,
    'port': 22,
}

target2 = {
    'device_type': 'cisco_ios',
    'ip': <ip_target2>,
    'username': <ssh_username_target2>,
    'password': <ssh_password_target2>,
    'port': 22,
}

# If the next hop is reachable via vrf on the current hop, add the vrf parameter to the destination configuration.
# Eg.: Target1 is reachable via vrf mgmt from target2.
#      You want to jump from target1 to target2.
#      Add the parameter vrf='mgmt' to target2 configuration before you jump from target1 to target2.

ssh = ConnectHandler(**jumphost1)
# now we are on jumphost1
# this is where the magic starts. as jump_to returns the object instance we can jump multiple hops at once

ssh.jump_to(**jumphost2).jump_to(**target1)
# now we are on target1
print(ssh.send_command("show inventory"))
# lets get back a single jump
ssh.jump_back()
# now we are on jumphost2
ssh.jump_to(**target2)
# now we are on target2
print(ssh.send_command("show inventory"))
ssh.jump_back()

Patch

# in some cases network device may have a warning banner following the login banner, and need user input (yes or a simple enter) to continue. # This patch pads in an “enter” command in the channel when “continue:” or “#” is detected during jump_to() process.

Contribute

License

This project is licensed under the Apache License Version 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netmiko_mhrt-1.0.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netmiko_mhrt-1.0.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file netmiko_mhrt-1.0.1.tar.gz.

File metadata

  • Download URL: netmiko_mhrt-1.0.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for netmiko_mhrt-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4398bde6b1a5b3c75c1ceb2bde815284d72d683295460ef9abc64bcc56cabe6f
MD5 8deb690e3b8a1319d5e01a1571969ad1
BLAKE2b-256 7254c51ed00b73ce58d4b18d30ae2142f20804855d1cdcbf9b7206913285a265

See more details on using hashes here.

File details

Details for the file netmiko_mhrt-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: netmiko_mhrt-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for netmiko_mhrt-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 62b030ab24f2a7e9cf7b0d7df56e1cd40976703e64c6225704f116d3c0067863
MD5 e1b8cb44f50f5544d5c5b0b7b9870189
BLAKE2b-256 4590036e6aa76cfadff13641adce8afb7664df49b20ca62f214c283483074f1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page