xe_cli.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:nfvOrchestrator 作者: uestcNFVproject 项目源码 文件源码
def ssh_execute_cli(cli, sff_locator):
    """ """
    remoteConnectionSetup = paramiko.SSHClient()
    remoteConnectionSetup.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    remoteConnectionSetup.connect(sff_locator,
                                  username='cisco', password='cisco',
                                  allow_agent=False, look_for_keys=False)
    # invoke the shell so can send multiple commands
    sshChannel = remoteConnectionSetup.invoke_shell()

    # make sure in enable mode so we can configure the router
    is_enabled = sshChannel.recv(1000)
    if "#" not in is_enabled:
        enable_router(sshChannel)

    # execute the necessary commands to configure the router
    send_command_and_wait_for_execution(sshChannel, "conf t\n", "#", False)
    send_command_and_wait_for_execution(sshChannel, cli + '\n', "#", False)
    remoteConnectionSetup.close()  # close the connection
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号