本文整理汇总了Python中utils.is_rhel6函数的典型用法代码示例。如果您正苦于以下问题:Python is_rhel6函数的具体用法?Python is_rhel6怎么用?Python is_rhel6使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_rhel6函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: cluster_localnode
def cluster_localnode(argv):
if len(argv) != 2:
usage.cluster()
exit(1)
elif argv[0] == "add":
node = argv[1]
if not utils.is_rhel6():
success = utils.addNodeToCorosync(node)
else:
success = utils.addNodeToClusterConf(node)
if success:
print "%s: successfully added!" % node
else:
utils.err("unable to add %s" % node)
elif argv[0] in ["remove","delete"]:
node = argv[1]
if not utils.is_rhel6():
success = utils.removeNodeFromCorosync(node)
else:
success = utils.removeNodeFromClusterConf(node)
if success:
print "%s: successfully removed!" % node
else:
utils.err("unable to remove %s" % node)
else:
usage.cluster()
exit(1)
开发者ID:deriamis,项目名称:pcs,代码行数:29,代码来源:cluster.py
示例2: start_cluster
def start_cluster(argv):
if len(argv) > 0:
start_cluster_nodes(argv)
return
print "Starting Cluster..."
if utils.is_rhel6():
# Verify that CMAN_QUORUM_TIMEOUT is set, if not, then we set it to 0
retval, output = commands.getstatusoutput('source /etc/sysconfig/cman ; [ -z "$CMAN_QUORUM_TIMEOUT" ]')
if retval == 0:
with open("/etc/sysconfig/cman", "a") as cman_conf_file:
cman_conf_file.write("\nCMAN_QUORUM_TIMEOUT=0\n")
output, retval = utils.run(["service", "cman","start"])
if retval != 0:
print output
utils.err("unable to start cman")
else:
output, retval = utils.run(["service", "corosync","start"])
if retval != 0:
print output
utils.err("unable to start corosync")
output, retval = utils.run(["service", "pacemaker", "start"])
if retval != 0:
print output
utils.err("unable to start pacemaker")
开发者ID:deriamis,项目名称:pcs,代码行数:26,代码来源:cluster.py
示例3: full_status
def full_status():
if "--full" in utils.pcs_options:
(output, retval) = utils.run(["crm_mon", "-1", "-r", "-R", "-A", "-f"])
else:
(output, retval) = utils.run(["crm_mon", "-1", "-r"])
if (retval != 0):
utils.err("cluster is not currently running on this node")
if not utils.usefile or "--corosync_conf" in utils.pcs_options:
cluster_name = utils.getClusterName()
print "Cluster name: %s" % cluster_name
if utils.stonithCheck():
print("WARNING: no stonith devices and stonith-enabled is not false")
if utils.corosyncPacemakerNodeCheck():
print("WARNING: corosync and pacemaker node names do not match (IPs used in setup?)")
print output
if not utils.usefile:
if not utils.is_rhel6():
print "PCSD Status:"
cluster.cluster_gui_status([],True)
print ""
utils.serviceStatus(" ")
开发者ID:disco-stu,项目名称:pcs,代码行数:27,代码来源:status.py
示例4: cluster_destroy
def cluster_destroy(argv):
if "--all" in utils.pcs_options:
threads = {}
for node in utils.getNodesFromCorosyncConf():
threads[node] = DestroyClusterThread(node)
threads[node].start()
for thread in threads.values():
thread.join()
else:
print "Shutting down pacemaker/corosync services..."
print os.system("service pacemaker stop")
print os.system("service corosync stop")
print "Killing any remaining services..."
os.system("killall -q -9 corosync aisexec heartbeat pacemakerd ccm stonithd ha_logd lrmd crmd pengine attrd pingd mgmtd cib fenced dlm_controld gfs_controld")
utils.disableServices()
print "Removing all cluster configuration files..."
if utils.is_rhel6():
os.system("rm /etc/cluster/cluster.conf")
else:
os.system("rm /etc/corosync/corosync.conf")
state_files = ["cib.xml*", "cib-*", "core.*", "hostcache", "cts.*",
"pe*.bz2","cib.*"]
for name in state_files:
os.system("find /var/lib -name '"+name+"' -exec rm -f \{\} \;")
开发者ID:naemono,项目名称:pcs,代码行数:26,代码来源:cluster.py
示例5: stop_cluster
def stop_cluster(argv):
if len(argv) > 0:
failure = False
errors = ""
for node in argv:
(retval, err) = utils.stopCluster(node)
if retval != 0:
failure = True
errors = errors + err+"\n"
if failure:
utils.err("unable to stop all nodes\n" + errors.rstrip())
return
print "Stopping Cluster..."
output, retval = utils.run(["service", "pacemaker","stop"])
if retval != 0:
print output,
utils.err("unable to stop pacemaker")
if utils.is_rhel6():
output, retval = utils.run(["service", "cman","stop"])
if retval != 0:
print output,
utils.err("unable to stop cman")
else:
output, retval = utils.run(["service", "corosync","stop"])
if retval != 0:
print output,
utils.err("unable to stop corosync")
开发者ID:naemono,项目名称:pcs,代码行数:28,代码来源:cluster.py
示例6: start_cluster
def start_cluster(argv):
if len(argv) > 0:
failure = False
errors = ""
for node in argv:
(retval, err) = utils.startCluster(node)
if retval != 0:
failure = True
errors = errors + err+"\n"
if failure:
utils.err("unable to start all nodes\n" + errors.rstrip())
return
print "Starting Cluster..."
if utils.is_rhel6():
# Verify that CMAN_QUORUM_TIMEOUT is set, if not, then we set it to 0
retval, output = commands.getstatusoutput('source /etc/sysconfig/cman ; [ -z "$CMAN_QUORUM_TIMEOUT" ]')
if retval == 0:
with open("/etc/sysconfig/cman", "a") as cman_conf_file:
cman_conf_file.write("\nCMAN_QUORUM_TIMEOUT=0\n")
output, retval = utils.run(["service", "cman","start"])
if retval != 0:
print output
utils.err("unable to start cman")
else:
output, retval = utils.run(["service", "corosync","start"])
if retval != 0:
print output
utils.err("unable to start corosync")
output, retval = utils.run(["service", "pacemaker", "start"])
if retval != 0:
print output
utils.err("unable to start pacemaker")
开发者ID:naemono,项目名称:pcs,代码行数:34,代码来源:cluster.py
示例7: corosync_setup
def corosync_setup(argv,returnConfig=False):
fedora_config = not utils.is_rhel6()
if len(argv) < 2:
usage.cluster()
exit(1)
if not returnConfig and "--start" in utils.pcs_options and not "--local" in utils.pcs_options and fedora_config:
sync_start(argv)
return
elif not returnConfig and not "--local" in utils.pcs_options and fedora_config:
sync(argv)
return
else:
nodes = argv[1:]
cluster_name = argv[0]
# Verify that all nodes are resolvable otherwise problems may occur
for node in nodes:
try:
socket.gethostbyname(node)
except socket.error:
print "Warning: Unable to resolve hostname: %s" % node
if fedora_config == True:
f = open(COROSYNC_CONFIG_FEDORA_TEMPLATE, 'r')
corosync_config = f.read()
f.close()
i = 1
new_nodes_section = ""
for node in nodes:
new_nodes_section += " node {\n"
new_nodes_section += " ring0_addr: %s\n" % (node)
new_nodes_section += " nodeid: %d\n" % (i)
new_nodes_section += " }\n"
i = i+1
corosync_config = corosync_config.replace("@@nodes", new_nodes_section)
corosync_config = corosync_config.replace("@@cluster_name",cluster_name)
if returnConfig:
return corosync_config
utils.setCorosyncConf(corosync_config)
else:
output, retval = utils.run(["/usr/sbin/ccs", "-i", "-f", "/etc/cluster/cluster.conf", "--createcluster", cluster_name])
if retval != 0:
print output
print "Error creating cluster:", cluster_name
sys.exit(1)
for node in nodes:
output, retval = utils.run(["/usr/sbin/ccs", "-f", "/etc/cluster/cluster.conf", "--addnode", node])
if retval != 0:
print output
print "Error adding node:", node
sys.exit(1)
if "--start" in utils.pcs_options:
start_cluster([])
开发者ID:lyon667,项目名称:pcs,代码行数:58,代码来源:cluster.py
示例8: config_restore_remote
def config_restore_remote(infile_name, infile_obj):
extracted = {
"version.txt": "",
"corosync.conf": "",
"cluster.conf": "",
}
try:
tarball = tarfile.open(infile_name, "r|*", infile_obj)
while True:
tar_member_info = tarball.next()
if tar_member_info is None:
break
if tar_member_info.name in extracted:
tar_member = tarball.extractfile(tar_member_info)
extracted[tar_member_info.name] = tar_member.read()
tar_member.close()
tarball.close()
except (tarfile.TarError, EnvironmentError) as e:
utils.err("unable to read the tarball: %s" % e)
config_backup_check_version(extracted["version.txt"])
node_list = utils.getNodesFromCorosyncConf(
extracted["cluster.conf" if utils.is_rhel6() else "corosync.conf"]
)
if not node_list:
utils.err("no nodes found in the tarball")
for node in node_list:
try:
retval, output = utils.checkStatus(node)
if retval != 0:
utils.err("unable to determine status of the node %s" % node)
status = json.loads(output)
if status["corosync"] or status["pacemaker"] or status["cman"]:
utils.err(
"Cluster is currently running on node %s. You need to stop "
"the cluster in order to restore the configuration."
% node
)
except (ValueError, NameError):
utils.err("unable to determine status of the node %s" % node)
if infile_obj:
infile_obj.seek(0)
tarball_data = infile_obj.read()
else:
with open(infile_name, "r") as tarball:
tarball_data = tarball.read()
error_list = []
for node in node_list:
retval, error = utils.restoreConfig(node, tarball_data)
if retval != 0:
error_list.append(error)
if error_list:
utils.err("unable to restore all nodes\n" + "\n".join(error_list))
开发者ID:disco-stu,项目名称:pcs,代码行数:57,代码来源:config.py
示例9: config_backup_path_list
def config_backup_path_list(with_uid_gid=False, force_rhel6=None):
rhel6 = utils.is_rhel6() if force_rhel6 is None else force_rhel6
root_attrs = {
"mtime": int(time.time()),
"mode": 0644,
"uname": "root",
"gname": "root",
"uid": 0,
"gid": 0,
}
开发者ID:disco-stu,项目名称:pcs,代码行数:10,代码来源:config.py
示例10: testIPV6
def testIPV6(self):
if utils.is_rhel6():
print "WARNING: not testing IPV6 due to RHEL6"
return
o,r = pcs("cluster setup --force --local --corosync_conf=corosync.conf.tmp --name cnam rh7-1 rh7-2 --ipv6")
ac(o,"")
assert r == 0
with open("corosync.conf.tmp") as f:
data = f.read()
ac(data,'totem {\nversion: 2\nsecauth: off\ncluster_name: cnam\ntransport: udpu\nip_version: ipv6\n}\n\nnodelist {\n node {\n ring0_addr: rh7-1\n nodeid: 1\n }\n node {\n ring0_addr: rh7-2\n nodeid: 2\n }\n}\n\nquorum {\nprovider: corosync_votequorum\ntwo_node: 1\n}\n\nlogging {\nto_syslog: yes\n}\n')
开发者ID:vincepii,项目名称:pcs,代码行数:10,代码来源:test_cluster.py
示例11: config_backup_path_list
def config_backup_path_list(with_uid_gid=False, force_rhel6=None):
rhel6 = utils.is_rhel6() if force_rhel6 is None else force_rhel6
corosync_attrs = {
"mtime": int(time.time()),
"mode": 0o644,
"uname": "root",
"gname": "root",
"uid": 0,
"gid": 0,
}
cib_attrs = {
"mtime": int(time.time()),
"mode": 0o600,
"uname": settings.pacemaker_uname,
"gname": settings.pacemaker_gname,
}
if with_uid_gid:
try:
cib_attrs["uid"] = pwd.getpwnam(cib_attrs["uname"]).pw_uid
except KeyError:
utils.err(
"Unable to determine uid of user '%s'" % cib_attrs["uname"]
)
try:
cib_attrs["gid"] = grp.getgrnam(cib_attrs["gname"]).gr_gid
except KeyError:
utils.err(
"Unable to determine gid of group '%s'" % cib_attrs["gname"]
)
file_list = {
"cib.xml": {
"path": os.path.join(settings.cib_dir, "cib.xml"),
"required": True,
"attrs": dict(cib_attrs),
},
}
if rhel6:
file_list["cluster.conf"] = {
"path": settings.cluster_conf_file,
"required": True,
"attrs": dict(corosync_attrs),
}
else:
file_list["corosync.conf"] = {
"path": settings.corosync_conf_file,
"required": True,
"attrs": dict(corosync_attrs),
}
file_list["uidgid.d"] = {
"path": settings.corosync_uidgid_dir.rstrip("/"),
"required": False,
"attrs": dict(corosync_attrs),
}
return file_list
开发者ID:tradej,项目名称:pcs,代码行数:55,代码来源:config.py
示例12: cluster_uidgid
def cluster_uidgid(argv, silent_list = False):
if utils.is_rhel6():
cluster_uidgid_rhel6(argv, silent_list)
return
if len(argv) == 0:
found = False
uid_gid_files = os.listdir(settings.corosync_uidgid_dir)
for ug_file in uid_gid_files:
uid_gid_dict = utils.read_uid_gid_file(ug_file)
if "uid" in uid_gid_dict or "gid" in uid_gid_dict:
line = "UID/GID: uid="
if "uid" in uid_gid_dict:
line += uid_gid_dict["uid"]
line += " gid="
if "gid" in uid_gid_dict:
line += uid_gid_dict["gid"]
print line
found = True
if not found and not silent_list:
print "No uidgids configured in cluster.conf"
return
command = argv.pop(0)
uid=""
gid=""
if (command == "add" or command == "rm") and len(argv) > 0:
for arg in argv:
if arg.find('=') == -1:
utils.err("uidgid options must be of the form uid=<uid> gid=<gid>")
(k,v) = arg.split('=',1)
if k != "uid" and k != "gid":
utils.err("%s is not a valid key, you must use uid or gid" %k)
if k == "uid":
uid = v
if k == "gid":
gid = v
if uid == "" and gid == "":
utils.err("you must set either uid or gid")
if command == "add":
utils.write_uid_gid_file(uid,gid)
elif command == "rm":
retval = utils.remove_uid_gid_file(uid,gid)
if retval == False:
utils.err("no uidgid files with uid=%s and gid=%s found" % (uid,gid))
else:
usage.cluster(["uidgid"])
exit(1)
开发者ID:deriamis,项目名称:pcs,代码行数:54,代码来源:cluster.py
示例13: testTotemOptions
def testTotemOptions(self):
if utils.is_rhel6():
print "WARNING: Not testing totem options due to RHEL6"
return
o,r = pcs("cluster setup --force --local --corosync_conf=corosync.conf.tmp --name test99 rh7-1 rh7-2 --token 20000 --join 20001 --consensus 20002 --miss_count_const 20003 --fail_recv_const 20004")
ac(o,"")
assert r == 0
with open("corosync.conf.tmp") as f:
data = f.read()
ac(data,'totem {\nversion: 2\nsecauth: off\ncluster_name: test99\ntransport: udpu\ntoken: 20000\njoin: 20001\nconsensus: 20002\nmiss_count_const: 20003\nfail_recv_const: 20004\n}\n\nnodelist {\n node {\n ring0_addr: rh7-1\n nodeid: 1\n }\n node {\n ring0_addr: rh7-2\n nodeid: 2\n }\n}\n\nquorum {\nprovider: corosync_votequorum\ntwo_node: 1\n}\n\nlogging {\nto_syslog: yes\n}\n')
开发者ID:vincepii,项目名称:pcs,代码行数:11,代码来源:test_cluster.py
示例14: test_stonith_create_provides_unfencing_rhel6
def test_stonith_create_provides_unfencing_rhel6(self):
if not utils.is_rhel6():
return
output, returnVal = pcs(
temp_cib,
"stonith create f1 fence_mpath key=abc"
)
ac(output, "")
self.assertEqual(0, returnVal)
output, returnVal = pcs(
temp_cib,
"stonith create f2 fence_mpath key=abc meta provides=unfencing"
)
ac(output, "")
self.assertEqual(0, returnVal)
output, returnVal = pcs(
temp_cib,
"stonith create f3 fence_mpath key=abc meta provides=something"
)
ac(output, "")
self.assertEqual(0, returnVal)
output, returnVal = pcs(
temp_cib,
"stonith create f4 fence_xvm meta provides=something"
)
ac(output, "")
self.assertEqual(0, returnVal)
output, returnVal = pcs(temp_cib, "stonith show --full")
ac(output, """\
Resource: f1 (class=stonith type=fence_mpath)
Attributes: key=abc
Meta Attrs: provides=unfencing
Operations: monitor interval=60s (f1-monitor-interval-60s)
Resource: f2 (class=stonith type=fence_mpath)
Attributes: key=abc
Meta Attrs: provides=unfencing
Operations: monitor interval=60s (f2-monitor-interval-60s)
Resource: f3 (class=stonith type=fence_mpath)
Attributes: key=abc
Meta Attrs: provides=unfencing
Operations: monitor interval=60s (f3-monitor-interval-60s)
Resource: f4 (class=stonith type=fence_xvm)
Meta Attrs: provides=something
Operations: monitor interval=60s (f4-monitor-interval-60s)
""")
self.assertEqual(0, returnVal)
开发者ID:akanouras,项目名称:pcs,代码行数:51,代码来源:test_stonith.py
示例15: cluster_gui_status
def cluster_gui_status(argv,dont_exit = False):
bad_nodes = False
if len(argv) == 0:
nodes = utils.getNodesFromCorosyncConf()
if len(nodes) == 0:
if utils.is_rhel6():
utils.err("no nodes found in cluster.conf")
else:
utils.err("no nodes found in corosync.conf")
bad_nodes = check_nodes(nodes, " ")
else:
bad_nodes = check_nodes(argv, " ")
if bad_nodes and not dont_exit:
sys.exit(1)
开发者ID:deriamis,项目名称:pcs,代码行数:14,代码来源:cluster.py
示例16: testCreation
def testCreation(self):
if utils.is_rhel6():
return
output, returnVal = pcs(temp_cib, "cluster")
assert returnVal == 1
assert output.startswith("\nUsage: pcs cluster [commands]...")
output, returnVal = pcs(temp_cib, "cluster setup --local --corosync_conf=corosync.conf.tmp cname rh7-1 rh7-2")
assert returnVal == 1
assert output.startswith("Error: A cluster name (--name <name>) is required to setup a cluster\n")
# Setup a 2 node cluster and make sure the two node config is set, then add a
# node and make sure that it's unset, then remove a node and make sure it's
# set again
output, returnVal = pcs(temp_cib, "cluster setup --local --corosync_conf=corosync.conf.tmp --name cname rh7-1 rh7-2")
assert output == ""
assert returnVal == 0
with open("corosync.conf.tmp") as f:
data = f.read()
assert data == 'totem {\nversion: 2\nsecauth: off\ncluster_name: cname\ntransport: udpu\n}\n\nnodelist {\n node {\n ring0_addr: rh7-1\n nodeid: 1\n }\n node {\n ring0_addr: rh7-2\n nodeid: 2\n }\n}\n\nquorum {\nprovider: corosync_votequorum\ntwo_node: 1\n}\n\nlogging {\nto_syslog: yes\n}\n',[data]
output, returnVal = pcs(temp_cib, "cluster localnode add --corosync_conf=corosync.conf.tmp rh7-3")
assert returnVal == 0
assert output == "rh7-3: successfully added!\n",output
with open("corosync.conf.tmp") as f:
data = f.read()
assert data == 'totem {\nversion: 2\nsecauth: off\ncluster_name: cname\ntransport: udpu\n}\n\nnodelist {\n node {\n ring0_addr: rh7-1\n nodeid: 1\n }\n node {\n ring0_addr: rh7-2\n nodeid: 2\n }\n node {\n ring0_addr: rh7-3\n nodeid: 3\n }\n}\n\nquorum {\nprovider: corosync_votequorum\n}\n\nlogging {\nto_syslog: yes\n}\n',[data]
output, returnVal = pcs(temp_cib, "cluster localnode remove --corosync_conf=corosync.conf.tmp rh7-3")
assert returnVal == 0
assert output == "rh7-3: successfully removed!\n",output
with open("corosync.conf.tmp") as f:
data = f.read()
assert data == 'totem {\nversion: 2\nsecauth: off\ncluster_name: cname\ntransport: udpu\n}\n\nnodelist {\n node {\n ring0_addr: rh7-1\n nodeid: 1\n }\n node {\n ring0_addr: rh7-2\n nodeid: 2\n }\n}\n\nquorum {\nprovider: corosync_votequorum\ntwo_node: 1\n}\n\nlogging {\nto_syslog: yes\n}\n',[data]
output, returnVal = pcs(temp_cib, "cluster setup --local --corosync_conf=corosync.conf2.tmp --name cname rh7-1 rh7-2 rh7-3")
assert returnVal == 0
assert output == ""
with open("corosync.conf2.tmp") as f:
data = f.read()
assert data == 'totem {\nversion: 2\nsecauth: off\ncluster_name: cname\ntransport: udpu\n}\n\nnodelist {\n node {\n ring0_addr: rh7-1\n nodeid: 1\n }\n node {\n ring0_addr: rh7-2\n nodeid: 2\n }\n node {\n ring0_addr: rh7-3\n nodeid: 3\n }\n}\n\nquorum {\nprovider: corosync_votequorum\n\n}\n\nlogging {\nto_syslog: yes\n}\n',[data]
开发者ID:naemono,项目名称:pcs,代码行数:46,代码来源:test_cluster.py
示例17: cluster_get_corosync_conf
def cluster_get_corosync_conf(argv):
if utils.is_rhel6():
utils.err("corosync.conf is not supported on RHEL6")
if len(argv) > 1:
usage.cluster()
exit(1)
if len(argv) == 0:
print utils.getCorosyncConf()
return
node = argv[0]
retval, output = utils.getCorosyncConfig(node)
if retval != 0:
utils.err(output)
else:
print output
开发者ID:deriamis,项目名称:pcs,代码行数:18,代码来源:cluster.py
示例18: full_status
def full_status():
(output, retval) = utils.run(["crm_mon", "-1", "-r"])
if (retval != 0):
utils.err("cluster is not currently running on this node")
cluster_name = utils.getClusterName()
print "Cluster name: %s" % cluster_name
if utils.stonithCheck():
print("WARNING: no stonith devices and stonith-enabled is not false")
print output
print ""
if not utils.is_rhel6():
print "PCSD Status:"
cluster.cluster_gui_status([],True)
print ""
utils.serviceStatus(" ")
开发者ID:CaseCommonsDevOps,项目名称:pcs,代码行数:19,代码来源:status.py
示例19: stop_cluster
def stop_cluster(argv):
if len(argv) > 0:
stop_cluster_nodes(argv)
return
print "Stopping Cluster..."
output, retval = utils.run(["service", "pacemaker","stop"])
if retval != 0:
print output,
utils.err("unable to stop pacemaker")
if utils.is_rhel6():
output, retval = utils.run(["service", "cman","stop"])
if retval != 0:
print output,
utils.err("unable to stop cman")
else:
output, retval = utils.run(["service", "corosync","stop"])
if retval != 0:
print output,
utils.err("unable to stop corosync")
开发者ID:deriamis,项目名称:pcs,代码行数:20,代码来源:cluster.py
示例20: start_cluster
def start_cluster(argv):
if len(argv) > 0:
for node in argv:
utils.startCluster(node)
return
print "Starting Cluster..."
if utils.is_rhel6():
output, retval = utils.run(["service", "cman","start"])
if retval != 0:
print output
utils.err("unable to start cman")
else:
output, retval = utils.run(["service", "corosync","start"])
if retval != 0:
print output
utils.err("unable to start corosync")
output, retval = utils.run(["service", "pacemaker", "start"])
if retval != 0:
print output
utils.err("unable to start pacemaker")
开发者ID:adrianlzt,项目名称:pcs,代码行数:21,代码来源:cluster.py
注:本文中的utils.is_rhel6函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论