本文整理汇总了Python中msg.common_info函数的典型用法代码示例。如果您正苦于以下问题:Python common_info函数的具体用法?Python common_info怎么用?Python common_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_transition
def do_transition(self, context, *args):
"""usage: transition [<number>|<index>|<file>] [nograph] [v...] [scores] [actions] [utilization]
transition showdot [<number>|<index>|<file>]
transition log [<number>|<index>|<file>]
transition save [<number>|<index>|<file> [name]]"""
self._init_source()
argl = list(args)
subcmd = "show"
if argl and argl[0] in ("showdot", "log", "save"):
subcmd = argl[0]
del argl[0]
if subcmd == "show":
opt_l = utils.fetch_opts(argl, ptest_options)
if argl:
f = self._get_pe_input(argl[0])
del argl[0]
else:
f = self._get_pe_byidx(-1)
if (subcmd == "save" and len(argl) > 1) or \
(subcmd in ("show", "showdot", "log") and argl):
syntax_err(args, context="transition")
return False
if not f:
return False
if subcmd == "show":
common_info("running ptest with %s" % f)
rc = self._show_pe(f, opt_l)
elif subcmd == "showdot":
rc = self._display_dot(f)
elif subcmd == "save":
rc = self._pe2shadow(f, argl)
else:
rc = crm_report.show_transition_log(f, True)
return rc
示例2: ask
def ask(msg):
"""
Ask for user confirmation.
If core.force is true, always return true.
If not interactive and core.force is false, always return false.
"""
if config.core.force:
common_info("%s [YES]" % (msg))
return True
if not can_ask():
return False
msg += ' '
if msg.endswith('? '):
msg = msg[:-2] + ' (y/n)? '
while True:
try:
ans = raw_input(msg)
except EOFError:
ans = 'n'
if ans:
ans = ans[0].lower()
if ans in 'yn':
return ans == 'y'
示例3: save
def save(self, dest=None):
'''
Save the modified status section to a file/shadow. If the
file exists, then it must be a cib file and the status
section is replaced with our status section. If the file
doesn't exist, then our section and some (?) configuration
is saved.
'''
if not self.modified:
common_info("apparently you didn't modify status")
return False
if (not dest and self.origin == "live") or dest == "live":
common_warn("cannot save status to the cluster")
return False
cib = self.cib
if dest:
dest_path = cib_path(dest)
if os.path.isfile(dest_path):
cib = self._load_cib(dest)
if cib is None:
common_err("%s exists, but no cib inside" % dest)
return False
else:
dest_path = cib_path(self.origin)
if cib != self.cib:
status = cib.find("status")
xmlutil.rmnode(status)
cib.append(self.status_node)
xml = etree.tostring(cib)
try:
f = open(dest_path, "w")
except IOError, msg:
common_err(msg)
return False
示例4: _pe2shadow
def _pe2shadow(self, f, argl):
try:
name = argl[0]
except:
name = os.path.basename(f).replace(".bz2", "")
common_info("transition %s saved to shadow %s" % (f, name))
return xmlutil.pe2shadow(f, name)
示例5: _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
示例6: do_trace
def do_trace(self, context, rsc_id, op, interval=None):
'usage: trace <rsc> <op> [<interval>]'
rsc = self._get_trace_rsc(rsc_id)
if not rsc:
return False
if not interval:
interval = op == "monitor" and "non-0" or "0"
if op == "probe":
op = "monitor"
op_node = xmlutil.find_operation(rsc.node, op, interval)
if op_node is None and utils.crm_msec(interval) != 0:
common_err("not allowed to create non-0 interval operation %s" % op)
return False
if op_node is None:
head_pl = ["op", []]
head_pl[1].append(["name", op])
head_pl[1].append(["interval", interval])
head_pl[1].append([vars.trace_ra_attr, "1"])
cli_list = []
cli_list.append(head_pl)
if not rsc.add_operation(cli_list):
return False
else:
op_node = rsc.set_op_attr(op_node, vars.trace_ra_attr, "1")
if not cib_factory.commit():
return False
if op == "monitor" and utils.crm_msec(interval) != 0:
common_warn("please CLEANUP the RA trace directory %s regularly!" %
config.path.heartbeat_dir)
else:
common_info("restart %s to get the trace" % rsc_id)
return True
示例7: show_dot_graph
def show_dot_graph(dotfile, keep_file=False, desc="transition graph"):
cmd = "%s %s" % (config.core.dotty, dotfile)
if not keep_file:
cmd = "(%s; rm -f %s)" % (cmd, dotfile)
if options.regression_tests:
print ".EXT", cmd
subprocess.Popen(cmd, shell=True, bufsize=0, stdin=None, stdout=None, stderr=None, close_fds=True)
common_info("starting %s to show %s" % (config.core.dotty, desc))
示例8: do_restart
def do_restart(self, context, rsc):
"usage: restart <rsc>"
common_info("ordering %s to stop" % rsc)
if not self._commit_meta_attr(context, rsc, "target-role", "Stopped"):
return False
if not utils.wait4dc("stop", not options.batch):
return False
common_info("ordering %s to start" % rsc)
return self._commit_meta_attr(context, rsc, "target-role", "Started")
示例9: do_refresh
def do_refresh(self, context, force=''):
"usage: refresh"
if options.history != "live":
common_info("nothing to refresh if source isn't live")
return False
if force:
if force != "force" and force != "--force":
context.fatal_error("Expected 'force' or '--force' (was '%s')" % (force))
force = True
return crm_report.refresh_source(force)
示例10: do_restart
def do_restart(self, context, rsc):
"usage: restart <rsc>"
if not utils.is_name_sane(rsc):
return False
common_info("ordering %s to stop" % rsc)
if not self.do_stop(context, rsc):
return False
if not utils.wait4dc("stop", not options.batch):
return False
common_info("ordering %s to start" % rsc)
return self.do_start(context, rsc)
示例11: do_trace
def do_trace(self, context, rsc_id, op=None, interval=None):
'usage: trace <rsc> [<op>] [<interval>]'
rsc = self._get_trace_rsc(rsc_id)
if not rsc:
return False
if op == "probe":
op = "monitor"
if op is None:
self._trace_resource(context, rsc_id, rsc)
elif interval is None:
self._trace_op(context, rsc_id, rsc, op)
else:
self._trace_op_interval(context, rsc_id, rsc, op, interval)
if not cib_factory.commit():
return False
if op is not None:
common_info("Trace for %s:%s is written to %s/trace_ra/" %
(rsc_id, op, config.path.heartbeat_dir))
else:
common_info("Trace for %s is written to %s/trace_ra/" %
(rsc_id, config.path.heartbeat_dir))
if op is not None and op != "monitor":
common_info("Trace set, restart %s to trace the %s operation" % (rsc_id, op))
else:
common_info("Trace set, restart %s to trace non-monitor operations" % (rsc_id))
return True
示例12: 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
示例13: run_ptest
def run_ptest(graph_s, nograph, scores, utilization, actions, verbosity):
'''
Pipe graph_s thru ptest(8). Show graph using dotty if requested.
'''
actions_filter = "grep LogActions: | grep -vw Leave"
ptest = "2>&1 %s -x -" % config.core.ptest
if re.search("simulate", ptest) and \
not re.search("-[RS]", ptest):
ptest = "%s -S" % ptest
if verbosity:
if actions:
verbosity = 'v' * max(3, len(verbosity))
ptest = "%s -%s" % (ptest, verbosity.upper())
if scores:
ptest = "%s -s" % ptest
if utilization:
ptest = "%s -U" % ptest
if config.core.dotty and not nograph:
fd, dotfile = mkstemp()
ptest = "%s -D %s" % (ptest, dotfile)
else:
dotfile = None
# ptest prints to stderr
if actions:
ptest = "%s | %s" % (ptest, actions_filter)
if options.regression_tests:
ptest = ">/dev/null %s" % ptest
common_debug("invoke: %s" % ptest)
rc, s = get_stdout(ptest, input_s=graph_s)
if rc != 0:
common_debug("%s exited with %d" % (ptest, rc))
if actions and rc == 1:
common_warn("No actions found.")
else:
common_warn("Simulation was unsuccessful (RC=%d)." % (rc))
if dotfile:
if os.path.getsize(dotfile) > 0:
show_dot_graph(dotfile)
else:
common_warn("ptest produced empty dot file")
else:
if not nograph:
common_info("install graphviz to see a transition graph")
if s:
page_string(s)
return True
示例14: _xdg_file
def _xdg_file(name, xdg_name, chk_fun, directory):
from msg import common_warn, common_info, common_debug
if not name:
return name
if not os.path.isdir(directory):
os.makedirs(directory, 0700)
new = os.path.join(directory, xdg_name)
if directory == CONFIG_HOME and chk_fun(new) and chk_fun(name):
common_warn("both %s and %s exist, please cleanup" % (name, new))
return name
if chk_fun(name):
if directory == CONFIG_HOME:
common_info("moving %s to %s" % (name, new))
else:
common_debug("moving %s to %s" % (name, new))
os.rename(name, new)
return new
示例15: check_locker
def check_locker(dir):
if not os.path.isdir(os.path.join(dir, _LOCKDIR)):
return
s = file2str(os.path.join(dir, _LOCKDIR, _PIDF))
pid = convert2ints(s)
if not isinstance(pid, int):
common_warn("history: removing malformed lock")
rmdir_r(os.path.join(dir, _LOCKDIR))
return
try:
os.kill(pid, 0)
except OSError, (errno, strerror):
if errno == os.errno.ESRCH:
common_info("history: removing stale lock")
rmdir_r(os.path.join(dir, _LOCKDIR))
else:
common_err("%s: %s" % (_LOCKDIR, strerror))