示例#1
0
def test_add_sudo():
    tmpuser = config.core.user
    try:
        config.core.user = '******'
        assert utils.add_sudo('ls').startswith('sudo')
        config.core.user = ''
        assert utils.add_sudo('ls') == 'ls'
    finally:
        config.core.user = tmpuser
示例#2
0
 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
示例#3
0
文件: ra.py 项目: ingted/clusterLab
 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
示例#4
0
def crm_mon(opts=''):
    """
    Run 'crm_mon -1'
    opts: Additional options to pass to crm_mon
    returns: rc, stdout
    """
    has_crm_mon()
    status_cmd = "%s -1 %s" % (crm_mon_prog, opts)
    return utils.get_stdout(utils.add_sudo(status_cmd))
示例#5
0
def crm_mon(opts=''):
    """
    Run 'crm_mon -1'
    opts: Additional options to pass to crm_mon
    returns: rc, stdout
    """
    has_crm_mon()
    status_cmd = "%s -1 %s" % (crm_mon_prog, opts)
    return utils.get_stdout(utils.add_sudo(status_cmd))
示例#6
0
def cibdump2tmp():
    cmd = add_sudo(cib_dump)
    if options.regression_tests:
        print ".EXT", cmd
    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
    try:
        tmpf = str2tmp(''.join(p.stdout))
        p.wait()
    except IOError, msg:
        common_err(msg)
        return None
示例#7
0
def cibdump2tmp():
    cmd = add_sudo(cib_dump)
    if options.regression_tests:
        print ".EXT", cmd
    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
    try:
        tmpf = str2tmp(''.join(p.stdout))
        p.wait()
    except IOError, msg:
        common_err(msg)
        return None
示例#8
0
文件: xmlutil.py 项目: icclab/crmsh
def sudocall(cmd):
    cmd = add_sudo(cmd)
    if options.regression_tests:
        print ".EXT", cmd
    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    try:
        outp, errp = p.communicate()
        p.wait()
        return p.returncode, outp, errp
    except IOError, msg:
        common_err("running %s: %s" % (cmd, msg))
        return None, None, None
示例#9
0
def sudocall(cmd):
    cmd = add_sudo(cmd)
    if options.regression_tests:
        print ".EXT", cmd
    p = subprocess.Popen(cmd,
                         shell=True,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    try:
        outp, errp = p.communicate()
        p.wait()
        return p.returncode, outp, errp
    except IOError, msg:
        common_err("running %s: %s" % (cmd, msg))
        return None, None, None
示例#10
0
def cibdump2elem(section=None):
    if section:
        cmd = "%s -o %s" % (cib_dump, section)
    else:
        cmd = cib_dump
    cmd = add_sudo(cmd)
    if options.regression_tests:
        print ".EXT", cmd
    p = subprocess.Popen(
        cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    try:
        (outp, err_outp) = p.communicate()
        p.wait()
        rc = p.returncode
    except IOError, msg:
        common_err("running %s: %s" % (cmd, msg))
        return None
示例#11
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))
示例#12
0
def cibdump2elem(section=None):
    if section:
        cmd = "%s -o %s" % (cib_dump, section)
    else:
        cmd = cib_dump
    cmd = add_sudo(cmd)
    if options.regression_tests:
        print ".EXT", cmd
    p = subprocess.Popen(cmd,
                         shell=True,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    try:
        (outp, err_outp) = p.communicate()
        p.wait()
        rc = p.returncode
    except IOError, msg:
        common_err("running %s: %s" % (cmd, msg))
        return None
示例#13
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:
        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))
示例#14
0
文件: ui_cib.py 项目: lge/crmsh
 def do_diff(self, context):
     "usage: diff"
     rc, s = utils.get_stdout(utils.add_sudo("%s -d" % self.extcmd_stdout))
     utils.page_string(s)
示例#15
0
 def do_diff(self, context):
     "usage: diff"
     rc, s = utils.get_stdout(utils.add_sudo("%s -d" % self.extcmd_stdout))
     utils.page_string(s)