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")
def requires(self): # see the configure ptest/simulate command has_ptest = utils.is_program('ptest') has_simulate = utils.is_program('crm_simulate') if not has_ptest: vars.simulate_programs["ptest"] = "crm_simulate" if not has_simulate: vars.simulate_programs["simulate"] = "ptest" if not (has_ptest or has_simulate): common_warn("neither ptest nor crm_simulate exist, check your installation") vars.simulate_programs["ptest"] = "" vars.simulate_programs["simulate"] = "" return True
def requires(self): if not cib_factory.initialize(): return False # see the configure ptest/simulate command has_ptest = utils.is_program('ptest') has_simulate = utils.is_program('crm_simulate') if not has_ptest: constants.simulate_programs["ptest"] = "crm_simulate" if not has_simulate: constants.simulate_programs["simulate"] = "ptest" if not (has_ptest or has_simulate): common_warn("neither ptest nor crm_simulate exist, check your installation") constants.simulate_programs["ptest"] = "" constants.simulate_programs["simulate"] = "" return True
def is_lrmd_accessible(self): if not (is_program(lrmadmin_prog) and is_process("lrmd")): return False cmd = add_sudo(">/dev/null 2>&1 %s -C" % lrmadmin_prog) if options.regression_tests: print ".EXT", cmd return subprocess.call(cmd, shell=True) == 0
def requires(self): if not cib_factory.initialize(): return False # see the configure ptest/simulate command has_ptest = utils.is_program('ptest') has_simulate = utils.is_program('crm_simulate') if not has_ptest: constants.simulate_programs["ptest"] = "crm_simulate" if not has_simulate: constants.simulate_programs["simulate"] = "ptest" if not (has_ptest or has_simulate): common_warn( "neither ptest nor crm_simulate exist, check your installation" ) constants.simulate_programs["ptest"] = "" constants.simulate_programs["simulate"] = "" return True
def is_lrmd_accessible(self): if not (is_program(lrmadmin_prog) and is_process("lrmd")): return False cmd = add_sudo(">/dev/null 2>&1 %s -C" % lrmadmin_prog) if options.regression_tests: print ".EXT", cmd return subprocess.call( cmd, shell=True) == 0
def prog_meta(prog): ''' Do external program metadata. ''' if is_program(prog): rc, l = stdout2list("%s metadata" % prog) if rc == 0: return l common_debug("%s metadata exited with code %d" % (prog, rc)) return []
def prog_meta(prog): ''' Do external program metadata. ''' prog = is_program(prog) if prog: rc, l = stdout2list("%s metadata" % prog) if rc == 0: return l common_debug("%s metadata exited with code %d" % (prog, rc)) return []
def prog_meta(prog): ''' Do external program metadata. ''' l = [] if is_program(prog): rc, l = stdout2list("%s metadata" % prog) if rc != 0: common_debug("%s metadata exited with code %d" % (prog, rc)) l = [] return l
def create_report(context, args): toolopts = [os.path.join(config.path.sharedir, 'hb_report'), 'hb_report', 'crm_report'] extcmd = None for tool in toolopts: if utils.is_program(tool): extcmd = tool break if not extcmd: context.fatal_error("No reporting tool found") cmd = [extcmd] + list(args) if options.regression_tests: print ".EXT", cmd return subprocess.call(cmd, shell=False, preexec_fn=lambda: signal(SIGPIPE, SIG_DFL))
def prog_meta(prog): ''' Do external program metadata. ''' if prog == "crmd" and os.path.isfile(os.path.join(config.path.crm_daemon_dir, 'crmd')): prog = os.path.join(config.path.crm_daemon_dir, 'crmd') rc, l = stdout2list("%s metadata" % prog) if rc == 0: return l common_debug("%s metadata exited with code %d" % (prog, rc)) elif is_program(prog): rc, l = stdout2list("%s metadata" % prog) if rc == 0: return l common_debug("%s metadata exited with code %d" % (prog, rc)) return []
def can_use_lrmadmin(): from distutils import version # after this glue release all users can get meta-data and # similar from lrmd minimum_glue = "1.0.10" rc, glue_ver = get_stdout("%s -v" % lrmadmin_prog, stderr_on=False) if not glue_ver: # lrmadmin probably not found return False v_min = version.LooseVersion(minimum_glue) v_this = version.LooseVersion(glue_ver) if v_this < v_min: return False if userdir.getuser() not in ("root", config.path.crm_daemon_user): return False if not (is_program(lrmadmin_prog) and is_process("lrmd")): return False return utils.ext_cmd(">/dev/null 2>&1 %s -C" % lrmadmin_prog) == 0
def crm_mon(opts=''): """ Run 'crm_mon -1' opts: Additional options to pass to crm_mon returns: rc, stdout """ global _crm_mon if _crm_mon is None: if not utils.is_program("crm_mon"): raise IOError("crm_mon not available, check your installation") _, out = utils.get_stdout("crm_mon --help") if "--pending" in out: _crm_mon = "crm_mon -1 -j" else: _crm_mon = "crm_mon -1" status_cmd = "%s %s" % (_crm_mon, opts) return utils.get_stdout(utils.add_sudo(status_cmd))
def create_report(context, args): toolopts = [ os.path.join(config.path.sharedir, 'hb_report'), 'hb_report', 'crm_report' ] extcmd = None for tool in toolopts: if utils.is_program(tool): extcmd = tool break if not extcmd: context.fatal_error("No reporting tool found") cmd = [extcmd] + list(args) if options.regression_tests: print ".EXT", cmd return subprocess.call(cmd, shell=False, preexec_fn=lambda: signal(SIGPIPE, SIG_DFL))
def crm_mon(opts=''): """ Run 'crm_mon -1' opts: Additional options to pass to crm_mon returns: rc, stdout """ global _crm_mon if _crm_mon is None: prog = utils.is_program("crm_mon") if not prog: raise IOError("crm_mon not available, check your installation") _, out = utils.get_stdout("%s --help" % (prog)) if "--pending" in out: _crm_mon = "%s -1 -j" % (prog) else: _crm_mon = "%s -1" % (prog) status_cmd = "%s %s" % (_crm_mon, opts) return utils.get_stdout(utils.add_sudo(status_cmd))
def requires(self): for program in ('crm_resource', 'crm_attribute'): if not utils.is_program(program): no_prog_err(program) return False return True
def check_tools(): return all( utils.is_program(p) for p in ['corosync-cfgtool', 'corosync-quorumtool', 'corosync-cmapctl'])
def requires(self): for p in ('cibadmin', 'crm_attribute'): if not utils.is_program(p): no_prog_err(p) return False return True
def requires(self): if not utils.is_program('crm_shadow'): no_prog_err('crm_shadow') return False return True
def check_tools(): return all(utils.is_program(p) for p in ['corosync-cfgtool', 'corosync-quorumtool', 'corosync-cmapctl'])
def has_crm_mon(): p = crm_mon_prog if not utils.is_program(p): raise IOError("%s not available, check your installation" % crm_mon_prog)