首页 文章

使用python配置Juniper交换机(paramiko)

提问于
浏览
-1

我正在尝试将配置推送到多个juniper设备 . 但作为测试,我进入配置模式并更改配置 .

client1 = paramiko.SSHClient()

client1.set_missing_host_key_policy(paramiko.AutoAddPolicy())

client1.connect(IP, username=username, password=password)

configure = client1.invoke_shell()

configure.send('configure')

configure.send('set interfaces ge-0/0/10 description "test"')

configure.send('show | compare')

print configure.recv(1000)

client1.close()

我期待输出如下:

[edit interfaces ge-0/0/10]
-   description "Internet Simulation Interface connect to QFX ge-0/0/21";
+   description test;

但实际输出是这样的:

JUNOS 12.3X50-D35 built 2013-10-22 07:02:18 UTC


2 回答

  • 0

    您正在获取 Juniper CLI 的第一行,尝试在以下位置编码更高的接收字节:

    print configure.recv(1000)
    

    尝试:

    print configure.recv(4096)
    

    让我知道 .

  • 0

    我建议您使用Junos Eznc,来自juniper的junos设备库 . Junos-Eznc GitHub

相关问题