self._remote_sshkey = ""
self._ssh_keyauth = False
self._ssh_passauth = False
+ self._command_result_cache = {}
''' set parameters '''
[self._ssh_username, self._ssh_hostname,
self._ssh_hostport] = self._u.parse_remote_desc(remote_desc)
- def exec_cmd(self, cmdline):
+ def exec_cmd(self, cmdline, enable_cache=True):
+ if enable_cache:
+ if self._command_result_cache.has_key(cmdline):
+ return self._command_result_cache[cmdline]
+
args = shlex.split(cmdline)
if self._remote_desc is not None:
result = self._exec_cmd_on_ssh(cmdline)
else:
result = Popen(args, stdout=PIPE, stderr=PIPE).stdout.readlines()
+ self._command_result_cache[cmdline] = result
return result
-
+
def _exec_cmd_on_ssh(self, cmdline):
sshc = ssh.SSHClient()
sshc.load_system_host_keys()