gpt4 book ai didi

python - 使用 PyEZ 在 Juniper 路由器中执行 vty 命令

转载 作者:太空狗 更新时间:2023-10-30 02:02:44 26 4
gpt4 key购买 nike

我有一个要求,在 Juniper 路由器外壳中运行的 python 脚本需要在 FPC 的 vty 控制台中执行一些命令。我不能使用 vty c,因为它可能无法在所有平台上正常工作。但是,我可以使用 vty fpc0 然后执行命令并从那里退出。

有没有办法使用PyEZ 执行vty 命令?如果是,请提供语法。

最佳答案

StartShell 类假设能够使用端口 22 与目标设备建立新的 SSH 连接。这可能并不总是一个好的假设。

使用 StartShell 的替代方法是使用与 request pfe execute 命令等效的 RPC。这是一个例子:

>>> resp = dev.rpc.request_pfe_execute(target='fpc0', command='show version')
>>> print resp.text

SENT: Ukern command: show version
GOT:
GOT:
GOT: Juniper Embedded Microkernel Version 15.1F4.15
GOT: Built by builder on 2015-12-23 18:11:49 UTC
GOT: Copyright (C) 1998-2015, Juniper Networks, Inc.
GOT: All rights reserved.
GOT:
GOT:
GOT: RMPC platform (1200Mhz QorIQ P2020 processor, 3584MB memory, 512KB flash)
GOT: Current time : Sep 2 15:35:42.409859
GOT: Elapsed time : 27+19:14:41
LOCAL: End of file

关于python - 使用 PyEZ 在 Juniper 路由器中执行 vty 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39223408/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com