def ssh_ping(self, timeout=60, base_cmd='true'): """ Pings remote host via ssh. @param timeout: Time in seconds before giving up. Defaults to 60 seconds. @param base_cmd: The base command to run with the ssh ping. Defaults to true. @raise AutoservSSHTimeout: If the ssh ping times out. @raise AutoservSshPermissionDeniedError: If ssh ping fails due to permissions. @raise AutoservSshPingHostError: For other AutoservRunErrors. """ try: self.run(base_cmd, timeout=timeout, connect_timeout=timeout) except error.AutoservSSHTimeout: msg = "Host (ssh) verify timed out (timeout = %d)" % timeout raise error.AutoservSSHTimeout(msg) except error.AutoservSshPermissionDeniedError: #let AutoservSshPermissionDeniedError be visible to the callers raise except error.AutoservRunError, e: # convert the generic AutoservRunError into something more # specific for this context raise error.AutoservSshPingHostError(e.description + '\n' + repr(e.result_obj))
def ssh_ping(self, timeout=60): try: self.run("true", timeout=timeout, connect_timeout=timeout) except error.AutoservSSHTimeout: msg = "Host (ssh) verify timed out (timeout = %d)" % timeout raise error.AutoservSSHTimeout(msg) except error.AutoservSshPermissionDeniedError: #let AutoservSshPermissionDeniedError be visible to the callers raise except error.AutoservRunError, e: # convert the generic AutoservRunError into something more # specific for this context raise error.AutoservSshPingHostError(e.description + '\n' + repr(e.result_obj))