本文整理汇总了Python中utils.ext_cmd函数的典型用法代码示例。如果您正苦于以下问题:Python ext_cmd函数的具体用法?Python ext_cmd怎么用?Python ext_cmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ext_cmd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: del_node
def del_node(addr):
'''
Remove node from corosync
'''
f = open(conf()).read()
p = Parser(f)
nth = p.remove_section_where('nodelist.node', 'ring0_addr', addr)
if nth == -1:
return
if p.count('nodelist.node') <= 2:
p.set('quorum.two_node', '1')
f = open(conf(), 'w')
f.write(p.to_string())
f.close()
# check for running config
try:
nodes = utils.list_cluster_nodes()
except Exception:
nodes = []
if nodes:
utils.ext_cmd(["corosync-cmapctl", "-D", "nodelist.node.%s.nodeid" % (nth)],
shell=False)
utils.ext_cmd(["corosync-cmapctl", "-D", "nodelist.node.%s.ring0_addr" % (nth)],
shell=False)
开发者ID:lge,项目名称:crmsh,代码行数:27,代码来源:corosync.py
示例2: do_reprobe
def do_reprobe(self, context, *args):
'usage: reprobe [<node>]'
if len(args) == 1:
if not utils.is_name_sane(args[0]):
return False
return utils.ext_cmd(self.rsc_reprobe_node % args[0]) == 0
else:
return utils.ext_cmd(self.rsc_reprobe) == 0
开发者ID:icclab,项目名称:crmsh,代码行数:8,代码来源:ui_resource.py
示例3: do_scores
def do_scores(self, context):
"usage: scores"
if utils.is_program('crm_simulate'):
utils.ext_cmd('crm_simulate -sL')
elif utils.is_program('ptest'):
utils.ext_cmd('ptest -sL')
else:
context.fatal_error("Need crm_simulate or ptest in path to display scores")
开发者ID:icclab,项目名称:crmsh,代码行数:8,代码来源:ui_resource.py
示例4: do_status
def do_status(self, context, rsc=None):
"usage: status [<rsc>]"
if rsc:
if not utils.is_name_sane(rsc):
return False
return utils.ext_cmd(self.rsc_status % rsc) == 0
else:
return utils.ext_cmd(self.rsc_status_all) == 0
开发者ID:icclab,项目名称:crmsh,代码行数:8,代码来源:ui_resource.py
示例5: cleanup_resource
def cleanup_resource(rsc, node=''):
if not utils.is_name_sane(rsc) or not utils.is_name_sane(node):
return False
if not node:
rc = utils.ext_cmd(RscMgmt.rsc_cleanup_all % (rsc)) == 0
else:
rc = utils.ext_cmd(RscMgmt.rsc_cleanup % (rsc, node)) == 0
return rc
开发者ID:icclab,项目名称:crmsh,代码行数:8,代码来源:ui_resource.py
示例6: do_clearstate
def do_clearstate(self, context, node):
'usage: clearstate <node>'
if not utils.is_name_sane(node):
return False
if not config.core.force and \
not utils.ask("Do you really want to drop state for node %s?" % node):
return False
if utils.is_pcmk_118():
return utils.ext_cmd(self.node_clear_state_118 % node) == 0
else:
return utils.ext_cmd(self.node_clear_state % ("-M -c", node, node)) == 0 and \
utils.ext_cmd(self.node_clear_state % ("-R", node, node)) == 0
开发者ID:aomoriringo,项目名称:crmsh,代码行数:12,代码来源:ui_node.py
示例7: do_wait_for_startup
def do_wait_for_startup(self, context, timeout='10'):
"usage: wait_for_startup [<timeout>]"
import time
t0 = time.time()
timeout = float(timeout)
cmd = 'crm_mon -bD1 2&>1 >/dev/null'
ret = utils.ext_cmd(cmd)
while ret in (107, 64) and time.time() < t0 + timeout:
time.sleep(1)
ret = utils.ext_cmd(cmd)
if ret != 0:
context.fatal_error("Timed out waiting for cluster (rc = %s)" % (ret))
开发者ID:lge,项目名称:crmsh,代码行数:12,代码来源:ui_cluster.py
示例8: do_delete
def do_delete(self, context, node):
'usage: delete <node>'
if not utils.is_name_sane(node):
return False
if not xmlutil.is_our_node(node):
common_err("node %s not found in the CIB" % node)
return False
if not self._call_delnode(node):
return False
if utils.ext_cmd(self.node_delete % node) != 0 or \
utils.ext_cmd(self.node_delete_status % node) != 0:
common_err("%s removed from membership, but not from CIB!" % node)
return False
common_info("node %s deleted" % node)
return True
开发者ID:aomoriringo,项目名称:crmsh,代码行数:15,代码来源:ui_node.py
示例9: runop
def runop(self, op, nodes=None, local_only=False):
'''
Execute an operation.
'''
if not nodes or self.run_on_all(op):
nodes = self.nodes
self.last_op = op
self.set_rscenv(op)
real_op = (op == "probe" and "monitor" or op)
cmd = self.exec_cmd(real_op)
common_debug("running %s on %s" % (real_op, nodes))
for attr in self.rscenv.keys():
# shell doesn't allow "-" in var names
envvar = attr.replace("-", "_")
cmd = "%s=%s %s" % (envvar, quote(self.rscenv[attr]), cmd)
if local_only:
self.ec_l[this_node()] = ext_cmd(cmd)
else:
from crm_pssh import do_pssh_cmd
statuses = do_pssh_cmd(cmd, nodes, self.outdir, self.errdir, self.timeout)
for i in range(len(nodes)):
try:
self.ec_l[nodes[i]] = statuses[i]
except:
self.ec_l[nodes[i]] = self.undef
return
开发者ID:lge,项目名称:crmsh,代码行数:26,代码来源:rsctest.py
示例10: _use
def _use(self, name, withstatus):
# Choose a shadow cib for further changes. If the name
# provided is empty, then choose the live (cluster) cib.
# Don't allow ' in shadow names
if not name or name == "live":
if withstatus:
cib_status.load("live")
if constants.tmp_cib:
utils.ext_cmd("%s -D '%s' --force" % (self.extcmd, utils.get_cib_in_use()))
constants.tmp_cib = False
utils.clear_cib_in_use()
else:
utils.set_cib_in_use(name)
if withstatus:
cib_status.load("shadow:%s" % name)
return True
开发者ID:lge,项目名称:crmsh,代码行数:16,代码来源:ui_cib.py
示例11: do_new
def do_new(self, context, *args):
"usage: new [<shadow_cib>] [withstatus] [force] [empty]"
argl = list(args)
opt_l = utils.fetch_opts(argl, ["force", "--force", "withstatus", "empty"])
if len(argl) > 1:
context.fatal_error("Unexpected argument(s): " + ' '.join(argl))
name = None
if argl:
name = argl[0]
if not utils.is_filename_sane(name):
context.fatal_error("Bad filename: " + name)
if name in (constants.tmp_cib_prompt, constants.live_cib_prompt):
context.fatal_error("Shadow name '%s' is not allowed" % (name))
del argl[0]
constants.tmp_cib = False
else:
fd, fname = tmpfiles.create(dir=xmlutil.cib_shadow_dir(), prefix="shadow.crmsh_")
name = os.path.basename(fname).replace("shadow.", "")
constants.tmp_cib = True
if "empty" in opt_l:
new_cmd = "%s -e '%s'" % (self.extcmd, name)
else:
new_cmd = "%s -c '%s'" % (self.extcmd, name)
if constants.tmp_cib or config.core.force or "force" in opt_l or "--force" in opt_l:
new_cmd = "%s --force" % new_cmd
if utils.ext_cmd(new_cmd) == 0:
context.info("%s shadow CIB created" % name)
self.do_use(context, name)
if "withstatus" in opt_l:
cib_status.load("shadow:%s" % name)
开发者ID:lge,项目名称:crmsh,代码行数:32,代码来源:ui_cib.py
示例12: do_online
def do_online(self, context, node=None):
'usage: online [<node>]'
if not node:
node = utils.this_node()
if not utils.is_name_sane(node):
return False
return utils.ext_cmd(self.node_standby % (node, "off", "--lifetime='forever'")) == 0
开发者ID:aomoriringo,项目名称:crmsh,代码行数:7,代码来源:ui_node.py
示例13: do_ready
def do_ready(self, context, node=None):
'usage: ready [<node>]'
if not node:
node = utils.this_node()
if not utils.is_name_sane(node):
return False
return utils.ext_cmd(self.node_maint % (node, "off")) == 0
开发者ID:aomoriringo,项目名称:crmsh,代码行数:7,代码来源:ui_node.py
示例14: _call_delnode
def _call_delnode(self, node):
"Remove node (how depends on cluster stack)"
rc = True
if utils.cluster_stack() == "heartbeat":
cmd = (self.hb_delnode % node)
else:
ec, s = utils.get_stdout("%s -p" % self.crm_node)
if not s:
common_err('%s -p could not list any nodes (rc=%d)' %
(self.crm_node, ec))
rc = False
else:
partition_l = s.split()
if node in partition_l:
common_err("according to %s, node %s is still active" %
(self.crm_node, node))
rc = False
cmd = "%s --force -R %s" % (self.crm_node, node)
if not rc:
if config.core.force:
common_info('proceeding with node %s removal' % node)
else:
return False
ec = utils.ext_cmd(cmd)
if ec != 0:
common_warn('"%s" failed, rc=%d' % (cmd, ec))
return False
return True
开发者ID:aomoriringo,项目名称:crmsh,代码行数:28,代码来源:ui_node.py
示例15: do_demote
def do_demote(self, context, rsc):
"usage: demote <rsc>"
if not utils.is_name_sane(rsc):
return False
if not xmlutil.RscState().is_ms(rsc):
common_err("%s is not a master-slave resource" % rsc)
return False
return utils.ext_cmd(self.rsc_setrole % (rsc, "Slave")) == 0
开发者ID:icclab,项目名称:crmsh,代码行数:8,代码来源:ui_resource.py
示例16: add_node
def add_node(name):
'''
Add node to corosync.conf
'''
coronodes = None
nodes = None
coronodes = utils.list_corosync_nodes()
try:
nodes = utils.list_cluster_nodes()
except Exception:
nodes = []
ipaddr = get_ip(name)
if name in coronodes or (ipaddr and ipaddr in coronodes):
err_buf.warning("%s already in corosync.conf" % (name))
return
if name in nodes:
err_buf.warning("%s already in configuration" % (name))
return
f = open(conf()).read()
p = Parser(f)
node_addr = name
node_id = next_nodeid(p)
p.add('nodelist',
make_section('nodelist.node',
make_value('nodelist.node.ring0_addr', node_addr) +
make_value('nodelist.node.nodeid', str(node_id))))
num_nodes = p.count('nodelist.node')
if num_nodes > 2:
p.remove('quorum.two_node')
f = open(conf(), 'w')
f.write(p.to_string())
f.close()
# update running config (if any)
if nodes:
utils.ext_cmd(["corosync-cmapctl",
"-s", "nodelist.node.%s.nodeid" % (num_nodes - 1),
"u32", str(node_id)], shell=False)
utils.ext_cmd(["corosync-cmapctl",
"-s", "nodelist.node.%s.ring0_addr" % (num_nodes - 1),
"str", node_addr], shell=False)
开发者ID:lge,项目名称:crmsh,代码行数:46,代码来源:corosync.py
示例17: do_fence
def do_fence(self, context, node):
'usage: fence <node>'
if not utils.is_name_sane(node):
return False
if not config.core.force and \
not utils.ask("Do you really want to shoot %s?" % node):
return False
return utils.ext_cmd(self.node_fence % (node)) == 0
开发者ID:icclab,项目名称:crmsh,代码行数:8,代码来源:ui_node.py
示例18: do_reset
def do_reset(self, context, name):
"usage: reset <shadow_cib>"
if not utils.is_filename_sane(name):
context.fatal_error("Bad filename: " + name)
if utils.ext_cmd("%s -r '%s'" % (self.extcmd, name)) == 0:
context.info("copied live CIB to %s" % name)
else:
context.fatal_error("failed to copy live CIB to %s" % name)
开发者ID:lge,项目名称:crmsh,代码行数:8,代码来源:ui_cib.py
示例19: _dispatch_attr_cmd
def _dispatch_attr_cmd(cmd, attr_cmd, args):
if args[1] == 'set':
if len(args) != 4:
raise ValueError("Expected 4 arguments to 'set'")
if not utils.is_name_sane(args[0]) \
or not utils.is_name_sane(args[2]) \
or not utils.is_value_sane(args[3]):
raise ValueError("Argument failed sanity check")
return utils.ext_cmd(attr_cmd % (args[0], args[2], args[3])) == 0
elif args[1] in ('delete', 'show') or \
(cmd == "secret" and args[1] in ('stash', 'unstash', 'check')):
if len(args) != 3:
raise ValueError("Expected 3 arguments to " + args[1])
if not utils.is_name_sane(args[0]) \
or not utils.is_name_sane(args[2]):
raise ValueError("Argument failed sanity check")
return utils.ext_cmd(attr_cmd % (args[0], args[2])) == 0
raise ValueError("Unknown command " + repr(args[1]))
开发者ID:aomoriringo,项目名称:crmsh,代码行数:18,代码来源:ui_utils.py
示例20: _dispatch_attr_cmd
def _dispatch_attr_cmd(cmd, attr_cmd, rsc, subcmd, attr, value):
def sanity_check(arg):
if not utils.is_name_sane(arg):
raise ValueError("Expected valid name, got '%s'" % (arg))
if subcmd == 'set':
if value is None:
raise ValueError("Missing value argument to set")
sanity_check(rsc)
sanity_check(attr)
sanity_check(value)
return utils.ext_cmd(attr_cmd % (rsc, attr, value)) == 0
elif subcmd in ('delete', 'show') or \
(cmd == "secret" and subcmd in ('stash', 'unstash', 'check')):
if value is not None:
raise ValueError("Too many arguments to %s" % (subcmd))
sanity_check(rsc)
sanity_check(attr)
return utils.ext_cmd(attr_cmd % (rsc, attr)) == 0
raise ValueError("Unknown command " + repr(subcmd))
开发者ID:icclab,项目名称:crmsh,代码行数:19,代码来源:ui_utils.py
注:本文中的utils.ext_cmd函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论