Esempio n. 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
Esempio n. 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
Esempio n. 3
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
Esempio n. 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))
Esempio n. 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))
Esempio n. 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
Esempio n. 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
Esempio n. 8
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
Esempio n. 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
Esempio n. 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
Esempio n. 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))
Esempio n. 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
Esempio n. 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))
Esempio n. 14
0
File: ui_cib.py Progetto: 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)
Esempio n. 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)