# # ---------------------------------------------------------- """ This module implements the technique to interact via ssh to the test-object. The class has to be constructed by the tool-Handling because of keyword "ssh" in the configuration, then it will be called with the interface / abstract-class cli_abstract """ import os import utils.cli_abstract import basic import paramiko class CliFcts(utils.cli_abstract.CliFcts): def execCmd(self, cmds): """ :param cmds: :return: """ ssh = paramiko.SSHClient() ssh.load_system_host_keys(os.path.expanduser('~/.ssh/known_hosts')) if self.conn["password"]: ssh.connect(self.conn["host"], username=self.conn["user"], password=self.conn["password"]) else: ssh.connect(self.conn["host"], username=self.conn["user"]) shell = ssh.invoke_shell() for cmd in cmds: stdin, stdout, stderr = ssh.exec_command(cmd + "\n") self.sysout = stdout.read() stdin.close() stderr.close() stdout.close() ssh.close()