用于多跳功能的树外 netmiko monkeypatch
项目描述
netmiko_multihop 是一个树外 netmiko monkeypatch,它增加了多跳能力。目前支持以下平台作为中间跃点:
linux
cisco_nxos
cisco_ios
如果需要,可以轻松添加其他平台。
安装
通过运行安装 netmiko_multihop 包:
pip3 安装 netmiko-multihop
用法
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()
贡献
执照
该项目在 Apache 许可证版本 2.0 下获得许可
项目详情
关
netmiko_multihop -0.2.1-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c6d2b72048753b20d1e0a24155ab64392978b31ec38ec47a9a99b700d7c66c2d |
|
MD5 | 9252c72ba04d20901861b6b8c855266a |
|
布莱克2-256 | a3137b7557c6e44f4ef8b7ee46e0768d34460609549fdf0db6a68f684a01ce8f |