本文整理汇总了Python中glusto.core.Glusto.rpyc_get_connection方法的典型用法代码示例。如果您正苦于以下问题:Python Glusto.rpyc_get_connection方法的具体用法?Python Glusto.rpyc_get_connection怎么用?Python Glusto.rpyc_get_connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glusto.core.Glusto
的用法示例。
在下文中一共展示了Glusto.rpyc_get_connection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_connection
# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import rpyc_get_connection [as 别名]
def test_connection(self):
"""Testing rpyc connection"""
print "Running: %s - %s" % (self.id(), self.shortDescription())
g.rpyc_get_connection(self.masternode)
pingable = g.rpyc_ping_connection(self.masternode)
self.assertTrue(pingable, "Connection did not ping.")
示例2: test_local_module_on_remote
# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import rpyc_get_connection [as 别名]
def test_local_module_on_remote(self):
"""Testing local module definition on remote system"""
connection = g.rpyc_get_connection(self.masternode)
import supporting_files.rpyc.local_module
r = g.rpyc_define_module(connection,
supporting_files.rpyc.local_module)
# test global variable
self.assertEqual(r.myvariable, 'yada yada yada')
# test class attribute
self.assertEqual(r.myclass.myclassattribute, 'yada yada yada')
# test static method
output = r.myclass.static_method()
self.assertIn('static:', output)
# test class method
output = r.myclass.class_method()
self.assertIn('class:', output)
# test instance method
x = r.myclass()
output = x.instance_method()
self.assertIn('instance:', output)
示例3: _node_reboot
# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import rpyc_get_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"
)
示例4: enable_pvc_resize
# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import rpyc_get_connection [as 别名]
def enable_pvc_resize(master_node):
'''
This function edits the /etc/origin/master/master-config.yaml
file - to enable pv_resize feature
and restarts atomic-openshift service on master node
Args:
master_node (str): hostname of masternode on which
want to edit the
master-config.yaml file
Returns:
bool: True if successful,
otherwise raise Exception
'''
version = get_openshift_version()
if version < "3.9":
msg = ("pv resize is not available in openshift "
"version %s " % version)
g.log.error(msg)
raise NotSupportedException(msg)
try:
conn = g.rpyc_get_connection(master_node, user="root")
if conn is None:
err_msg = ("Failed to get rpyc connection of node %s"
% master_node)
g.log.error(err_msg)
raise ExecutionError(err_msg)
with conn.builtin.open(MASTER_CONFIG_FILEPATH, 'r') as f:
data = yaml.load(f)
dict_add = data['admissionConfig']['pluginConfig']
if "PersistentVolumeClaimResize" in dict_add:
g.log.info("master-config.yaml file is already edited")
return True
dict_add['PersistentVolumeClaimResize'] = {
'configuration': {
'apiVersion': 'v1',
'disable': 'false',
'kind': 'DefaultAdmissionConfig'}}
data['admissionConfig']['pluginConfig'] = dict_add
kube_config = data['kubernetesMasterConfig']
for key in ('apiServerArguments', 'controllerArguments'):
kube_config[key] = (
kube_config.get(key)
if isinstance(kube_config.get(key), dict) else {})
value = ['ExpandPersistentVolumes=true']
kube_config[key]['feature-gates'] = value
with conn.builtin.open(MASTER_CONFIG_FILEPATH, 'w+') as f:
yaml.dump(data, f, default_flow_style=False)
except Exception as err:
raise ExecutionError("failed to edit master-config.yaml file "
"%s on %s" % (err, master_node))
finally:
g.rpyc_close_connection(master_node, user="root")
g.log.info("successfully edited master-config.yaml file "
"%s" % master_node)
if version == "3.9":
cmd = ("systemctl restart atomic-openshift-master-api "
"atomic-openshift-master-controllers")
else:
cmd = ("/usr/local/bin/master-restart api && "
"/usr/local/bin/master-restart controllers")
ret, out, err = g.run(master_node, cmd, "root")
if ret != 0:
err_msg = "Failed to execute cmd %s on %s\nout: %s\nerr: %s" % (
cmd, master_node, out, err)
g.log.error(err_msg)
raise ExecutionError(err_msg)
# Wait for API service to be ready after the restart
for w in waiter.Waiter(timeout=120, interval=1):
try:
cmd_run("oc get nodes", master_node)
return True
except AssertionError:
continue
err_msg = "Exceeded 120s timeout waiting for OCP API to start responding."
g.log.error(err_msg)
raise ExecutionError(err_msg)
示例5: test_remote_call
# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import rpyc_get_connection [as 别名]
def test_remote_call(self):
rpyc_conn = g.rpyc_get_connection(self.masternode)
platform = rpyc_conn.modules.sys.platform
self.assertEqual(platform, 'linux2')