switch_ons.py 文件源码

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

项目:taf 作者: taf3 项目源码 文件源码
def execute_ssh_command(self, command):
        """Executes command on switch.

        Args:
            command(str):  ssh command to execute

        """
        client = paramiko.SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        # Make connection and create shell.
        client.connect(self.ipaddr, self._sshtun_port, self.ssh_user, self.ssh_user_pass)
        shell = client.invoke_shell()

        # Execute command and get results.
        _, stdout, stderr = client.exec_command(command)
        data = self._read_command_output(stdout, stderr, 'both')

        # Close connection.
        shell.close()
        client.close()

        return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号