예제 #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
파일: cmd_status.py 프로젝트: icclab/crmsh
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
파일: cmd_status.py 프로젝트: jonnary/crmsh
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)