本文整理匯總了Python中glusto.core.Glusto.ssh_close_connection方法的典型用法代碼示例。如果您正苦於以下問題:Python Glusto.ssh_close_connection方法的具體用法?Python Glusto.ssh_close_connection怎麽用?Python Glusto.ssh_close_connection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類glusto.core.Glusto
的用法示例。
在下文中一共展示了Glusto.ssh_close_connection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: cmd_run
# 需要導入模塊: from glusto.core import Glusto [as 別名]
# 或者: from glusto.core.Glusto import ssh_close_connection [as 別名]
def cmd_run(cmd, hostname, raise_on_error=True):
"""Glusto's command runner wrapper.
Args:
cmd (str): Shell command to run on the specified hostname.
hostname (str): hostname where Glusto should run specified command.
raise_on_error (bool): defines whether we should raise exception
in case command execution failed.
Returns:
str: Stripped shell command's stdout value if not None.
"""
ret, out, err = g.run(hostname, cmd, "root")
if ("no ssh connection" in err.lower() or
"tls handshake timeout" in err.lower()):
g.ssh_close_connection(hostname)
ret, out, err = g.run(hostname, cmd, "root")
msg = ("Failed to execute command '%s' on '%s' node. Got non-zero "
"return code '%s'. Err: %s" % (cmd, hostname, ret, err))
if int(ret) != 0:
g.log.error(msg)
if raise_on_error:
assert int(ret) == 0, msg
out = out.strip() if out else out
return out
示例2: _node_reboot
# 需要導入模塊: from glusto.core import Glusto [as 別名]
# 或者: from glusto.core.Glusto import ssh_close_connection [as 別名]
def _node_reboot(self):
storage_hostname = (g.config["gluster_servers"]
[self.gluster_servers[0]]["storage"])
cmd = "sleep 3; /sbin/shutdown -r now 'Reboot triggered by Glusto'"
ret, out, err = g.run(storage_hostname, cmd)
self.addCleanup(self._wait_for_gluster_pod_to_be_ready)
if ret != 255:
err_msg = "failed to reboot host %s error: %s" % (
storage_hostname, err)
g.log.error(err_msg)
raise AssertionError(err_msg)
try:
g.ssh_close_connection(storage_hostname)
except Exception as e:
g.log.error("failed to close connection with host %s"
" with error: %s" % (storage_hostname, e))
raise
# added sleep as node will restart after 3 sec
time.sleep(3)
for w in Waiter(timeout=600, interval=10):
try:
if g.rpyc_get_connection(storage_hostname, user="root"):
g.rpyc_close_connection(storage_hostname, user="root")
break
except Exception as err:
g.log.info("exception while getting connection: '%s'" % err)
if w.expired:
error_msg = ("exceeded timeout 600 sec, node '%s' is "
"not reachable" % storage_hostname)
g.log.error(error_msg)
raise ExecutionError(error_msg)
# wait for the gluster pod to be in 'Running' state
self._wait_for_gluster_pod_to_be_ready()
# glusterd and gluster-blockd service should be up and running
service_names = ("glusterd", "gluster-blockd", "tcmu-runner")
for gluster_pod in self.gluster_pod_list:
for service in service_names:
g.log.info("gluster_pod - '%s' : gluster_service '%s'" % (
gluster_pod, service))
check_service_status_on_pod(
self.oc_node, gluster_pod, service, "running"
)