Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

3 years ago
#
# ----------------------------------------------------------
"""
"""
import os
3 years ago
import basic
3 years ago
import paramiko
def getRemoteClass(comp):
3 years ago
job = basic.program.Job.getInstance()
3 years ago
verify = job.getDebugLevel("config_tool")
if job.conf.confs.get("tools").get("remotetyp") == "ssh":
return SshCmd(comp)
class RemoteCmd:
def __init__(self):
self.rc = 0
self.sysout = ""
pass
class SshCmd(RemoteCmd):
def __init__(self, comp):
self.conn = comp
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()