def host_contactable(self, address):
try:
# TODO: Better way to check this?
result = self._ssh_address(
address,
"echo 'Checking if node is ready to receive commands.'",
expected_return_code=None
)
except socket.error:
logger.debug("Unknown socket error when checking %s" % address)
return False
except paramiko.AuthenticationException, e:
logger.debug("Auth error when checking %s: %s" % (address, e))
return False
except paramiko.SSHException, e:
logger.debug("General SSH error when checking %s: %s" % (address, e))
return False
except EOFError:
logger.debug("Connection unexpectedly killed while checking %s" % address)
return False
if not result.rc == 0:
# Wait, what? echo returned !0? How is that possible?
logger.debug("exit status %d from echo on %s: inconceivable!" % (result.rc, address))
return False
return True
remote_operations.py 文件源码
python
阅读 15
收藏 0
点赞 0
评论 0
评论列表
文章目录