self._remote_sshkey = ""
self._ssh_keyauth = False
self._ssh_passauth = False
+ self._ssh_conne = None
self._command_result_cache = {}
''' set parameters '''
self._command_result_cache[cmdline] = result
return result
- def _exec_cmd_on_ssh(self, cmdline):
- sshc = ssh.SSHClient()
- sshc.load_system_host_keys()
+ def connect_ssh(self):
+ self._ssh_conn = ssh.SSHClient()
+ self._ssh_conn.load_system_host_keys()
if self._ssh_keyauth == True:
- sshc.connect(self._ssh_hostname, username=self._ssh_username,
+ self._ssh_conn.connect(self._ssh_hostname, username=self._ssh_username,
port=self._ssh_hostport, key_filename=self._remote_sshkey)
elif self._ssh_passauth == True:
- sshc.connect(self._ssh_hostname, username=self._ssh_username,
+ self._ssh_conn.connect(self._ssh_hostname, username=self._ssh_username,
port=self._ssh_hostport, password=self._remote_password)
else:
print "SSH connections failed"
sys.exit(1)
- stdin, stdout, stderr = sshc.exec_command(cmdline)
+ def _exec_cmd_on_ssh(self, cmdline):
+ stdin, stdout, stderr = self._ssh_conn.exec_command(cmdline)
result = stdout.read().splitlines()
return result
col = Collector(opts, util, formatter)
if opts.remote_sshkey is not None:
col.set_remote_sshkey(opts.remote_sshkey)
+ col.connect_ssh()
if opts.remote_password is not None:
col.set_remote_password(opts.remote_password)
+ col.connect_ssh()
col.run()
linkpairs = col.get_linkpairs()