本文整理汇总了Python中glusto.core.Glusto类的典型用法代码示例。如果您正苦于以下问题:Python Glusto类的具体用法?Python Glusto怎么用?Python Glusto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Glusto类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cmd_run
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: setUpClass
def setUpClass(cls):
"""unittest standard setUpClass method
Runs before all test_ methods in the class
"""
print "Setting Up Class: %s" % cls.__name__
config = g.load_configs(["../examples/systems.yml",
"../examples/glusto.yml"])
g.update_config(config)
cls.hosts = g.config['nodes']
cls.primary_host = g.config['nodes'][0]
cls.client = g.config["clients"][0]
cls.test_string = 'Go for the Glusto!'
示例3: test_local_module_on_remote
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)
示例4: setUpClass
def setUpClass(cls):
"""unittest standard setUpClass method
Runs before all test_ methods in the class
"""
print "Setting Up Class: %s" % cls.__name__
# Setting class attributes for use across all test methods
cls.yaml_file = '/tmp/testconfig.yml'
cls.ini_file = '/tmp/testconfig.ini'
cls.ini_ordered_file = '/tmp/testconfig_ordered.ini'
cls.config = {}
cls.config['defaults'] = {}
cls.config['defaults']['this'] = 'yada1'
cls.config['defaults']['that'] = 'yada2'
cls.config['globals'] = {}
cls.config['globals']['the_other'] = 'yada3'
# to test ini substitution
cls.config['defaults']['this_and_that'] = '%(this)s and %(that)s'
g.show_config(cls.config)
cls.order = ['defaults', 'globals']
# cleanup files if they exist
'''
示例5: test_connection
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.")
示例6: setUpClass
def setUpClass(cls):
"""unittest standard setUpClass method
Runs before all test_ methods in the class
"""
print "Setting Up Class: %s" % cls.__name__
config = g.load_configs(["../examples/systems.yml",
"../examples/glusto.yml"])
g.update_config(config)
示例7: setUp
def setUp(self):
"""unittest standard setUp method
Runs before each test_ method
"""
print "Setting Up: %s" % self.id()
config = g.load_configs(["../examples/systems.yml",
"../examples/glusto.yml"])
g.update_config(config)
self.masternode = g.config["nodes"][0]
self.client = g.config["clients"][0]
示例8: handle_configs
def handle_configs(config_list):
"""Load default and user-specified configuration files"""
# load default config
g.log.info("Loading default configuration files.")
g.load_config_defaults()
# load user specified configs (can also override defaults)
if (config_list):
g.log.info("Loading user specified configuration files.")
config_files = config_list.split()
config = g.load_configs(config_files)
g.update_config(config)
示例9: setUp
def setUp(self):
"""unittest standard setUp method
Runs before each test_ method
"""
print "Setting Up: %s" % self.id()
# render the template
g.render_template(self.template_file,
self.template_vars,
self.output_file,
self.search_path)
# read the resulting config file built from template
self.output_config = g.load_config(self.output_file)
g.show_config(self.output_config)
示例10: validate_multipath_pod
def validate_multipath_pod(hostname, podname, hacount, mpath=""):
'''
This function validates multipath for given app-pod
Args:
hostname (str): ocp master node name
podname (str): app-pod name for which we need to validate
multipath. ex : nginx1
hacount (int): multipath count or HA count. ex: 3
Returns:
bool: True if successful,
otherwise False
'''
cmd = "oc get pods -o wide | grep %s | awk '{print $7}'" % podname
ret, out, err = g.run(hostname, cmd, "root")
if ret != 0 or out == "":
g.log.error("failed to exectute cmd %s on %s, err %s"
% (cmd, hostname, out))
return False
pod_nodename = out.strip()
active_node_count = 1
enable_node_count = hacount - 1
cmd = "multipath -ll %s | grep 'status=active' | wc -l" % mpath
ret, out, err = g.run(pod_nodename, cmd, "root")
if ret != 0 or out == "":
g.log.error("failed to exectute cmd %s on %s, err %s"
% (cmd, pod_nodename, out))
return False
active_count = int(out.strip())
if active_node_count != active_count:
g.log.error("active node count on %s for %s is %s and not 1"
% (pod_nodename, podname, active_count))
return False
cmd = "multipath -ll %s | grep 'status=enabled' | wc -l" % mpath
ret, out, err = g.run(pod_nodename, cmd, "root")
if ret != 0 or out == "":
g.log.error("failed to exectute cmd %s on %s, err %s"
% (cmd, pod_nodename, out))
return False
enable_count = int(out.strip())
if enable_node_count != enable_count:
g.log.error("passive node count on %s for %s is %s "
"and not %s" % (
pod_nodename, podname, enable_count,
enable_node_count))
return False
g.log.info("validation of multipath for %s is successfull"
% podname)
return True
示例11: test_stress_stderr
def test_stress_stderr(self):
"""Send load of text output to stderr"""
command = '''ls -Rail /etc > /tmp/railetc
for i in $(seq 1 1000)
do
cat /tmp/railetc >&2
done
echo "Complete" >&2
'''
g.disable_log_levels('INFO')
rcode, rout, rerr = g.run(self.primary_host, command)
g.reset_log_levels()
self.assertEqual(rcode, 0, 'stressing stderr failed')
self.assertEqual(rout, '', 'sdtout has content.')
self.assertNotEqual(rerr, '', 'stderr has no content.')
示例12: test_ini
def test_ini(self):
"""Testing ini config file(s)"""
print "Running: %s - %s" % (self.id(), self.shortDescription())
g.store_config(self.config, self.ini_file)
self.assertTrue(os.path.exists(self.ini_file))
# read the config file
config = g.load_config(self.ini_file)
g.show_config(config)
self.assertEqual(config['defaults']['this'], 'yada1')
self.assertEqual(config['defaults']['that'], 'yada2')
self.assertEqual(config['defaults']['this_and_that'],
'yada1 and yada2')
self.assertEqual(config['globals']['the_other'], 'yada3')
示例13: test_yaml
def test_yaml(self):
"""Testing yaml config file"""
print "Running: %s - %s" % (self.id(), self.shortDescription())
# write the config file
g.store_config(self.config, self.yaml_file)
# TODO: does unittest have a file exists assert?
self.assertTrue(os.path.exists(self.yaml_file))
# read the config file
config = g.load_config(self.yaml_file)
g.show_config(config)
self.assertEqual(config['defaults']['this'], 'yada1')
self.assertEqual(config['defaults']['that'], 'yada2')
self.assertEqual(config['globals']['the_other'], 'yada3')
示例14: test_stderr
def test_stderr(self):
"""Testing output to stderr"""
print "Running: %s - %s" % (self.id(), self.shortDescription())
rcode, rout, rerr = g.run(self.masternode, "uname -a >&2")
self.assertEqual(rcode, 0)
self.assertFalse(rout)
self.assertTrue(rerr)
示例15: test_dynamic_provisioning_glusterfile_glusterpod_failure
def test_dynamic_provisioning_glusterfile_glusterpod_failure(self):
"""Create glusterblock PVC when gluster pod is down."""
# Check that we work with containerized Gluster
if not self.is_containerized_gluster():
self.skipTest("Only containerized Gluster clusters are supported.")
mount_path = "/mnt"
datafile_path = '%s/fake_file_for_%s' % (mount_path, self.id())
# Create secret and storage class
self.create_storage_class()
# Create PVC
pvc_name = self.create_and_wait_for_pvc()
# Create app POD with attached volume
pod_name = oc_create_tiny_pod_with_volume(
self.node, pvc_name, "test-pvc-mount-on-app-pod",
mount_path=mount_path)
self.addCleanup(
wait_for_resource_absence, self.node, 'pod', pod_name)
self.addCleanup(oc_delete, self.node, 'pod', pod_name)
# Wait for app POD be up and running
wait_for_pod_be_ready(
self.node, pod_name, timeout=60, wait_step=2)
# Run IO in background
io_cmd = "oc rsh %s dd if=/dev/urandom of=%s bs=1000K count=900" % (
pod_name, datafile_path)
async_io = g.run_async(self.node, io_cmd, "root")
# Pick up one of the hosts which stores PV brick (4+ nodes case)
gluster_pod_data = get_gluster_pod_names_by_pvc_name(
self.node, pvc_name)[0]
# Delete glusterfs POD from chosen host and wait for spawn of new one
oc_delete(self.node, 'pod', gluster_pod_data["pod_name"])
cmd = ("oc get pods -o wide | grep glusterfs | grep %s | "
"grep -v Terminating | awk '{print $1}'") % (
gluster_pod_data["host_name"])
for w in Waiter(600, 15):
out = self.cmd_run(cmd)
new_gluster_pod_name = out.strip().split("\n")[0].strip()
if not new_gluster_pod_name:
continue
else:
break
if w.expired:
error_msg = "exceeded timeout, new gluster pod not created"
g.log.error(error_msg)
raise ExecutionError(error_msg)
new_gluster_pod_name = out.strip().split("\n")[0].strip()
g.log.info("new gluster pod name is %s" % new_gluster_pod_name)
wait_for_pod_be_ready(self.node, new_gluster_pod_name)
# Check that async IO was not interrupted
ret, out, err = async_io.async_communicate()
self.assertEqual(ret, 0, "IO %s failed on %s" % (io_cmd, self.node))