def get_cds_status(connection, cdsname):
     '''
     display CDS sync summary
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "dc")
     res_list = Expect.match(connection, re.compile(".*\n" + cdsname.replace(".", "\.") + "[\.\s]*\[([^\n]*)\].*" + cdsname.replace(".", "\.") + "\s*\r\n([^\n]*)\r\n", re.DOTALL), [1, 2], 60)
     connection.cli.exec_command("killall -s SIGINT rhui-manager")
     ret_list = []
     for val in [res_list[0]] + res_list[1].split("             "):
         val = Util.uncolorify(val.strip())
         ret_list.append(val)
     RHUIManager.quit(connection)
     return ret_list
 def get_repo_status(connection, reponame):
     '''
     display repo sync summary
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "dr")
     reponame_quoted = reponame.replace(".", "\.")
     res = Expect.match(connection, re.compile(".*" + reponame_quoted + "\s*\r\n([^\n]*)\r\n.*", re.DOTALL), [1], 60)[0]
     connection.cli.exec_command("killall -s SIGINT rhui-manager")
     res = Util.uncolorify(res)
     ret_list = res.split("             ")
     for i in range(len(ret_list)):
         ret_list[i] = ret_list[i].strip()
     RHUIManager.quit(connection)
     return ret_list
 def subscriptions_list(connection, what="registered", poolonly=False):
     '''
     list registered or available subscriptions, complete information or the pool ID only
     '''
     if what not in ["registered", "available"]:
         raise ValueError("Unsupported list: " + what)
     if poolonly:
         poolswitch = " --pool-only"
     else:
         poolswitch = ""
     _, stdout, _ = connection.exec_command(
         "rhui-manager subscriptions list --" + what + poolswitch)
     with stdout as output:
         sub_list = output.read().decode()
     # uncolorify to work around RHBZ#1577052
     return Util.uncolorify(sub_list).strip()
示例#4
0
def _get_repo_status(connection, reponame):
    '''
    display repo sync summary
    '''
    RHUIManager.screen(connection, "sync")
    Expect.enter(connection, "dr")
    res = Expect.match(
        connection,
        re.compile(r".*%s\s*\r\n([^\n]*)\r\n.*" % re.escape(reponame),
                   re.DOTALL), [1], 60)[0]
    connection.cli.exec_command("killall -s SIGINT rhui-manager")
    res = Util.uncolorify(res)
    ret_list = res.split("             ")
    for i, _ in enumerate(ret_list):
        ret_list[i] = ret_list[i].strip()

    Expect.enter(connection, CTRL_C)
    Expect.enter(connection, "q")
    return ret_list
    def get_repo_status(connection, reponame):
        '''
        display repo sync summary
        '''
        RHUIManager.screen(connection, "sync")
        Expect.enter(connection, "dr")
        reponame_quoted = Util.esc_parentheses(reponame)
        res = Expect.match(
            connection,
            re.compile(".*" + reponame_quoted + "\s*\r\n([^\n]*)\r\n.*",
                       re.DOTALL), [1], 60)[0]
        connection.cli.exec_command("killall -s SIGINT rhui-manager")
        res = Util.uncolorify(res)
        ret_list = res.split("             ")
        for i in range(len(ret_list)):
            ret_list[i] = ret_list[i].strip()

        Expect.enter(connection, '\x03')
        Expect.enter(connection, 'q')
        return ret_list
示例#6
0
def _ent_list(stdout):
    '''
    return a list of entitlements based on the given output (produced by cert upload/info)
    '''
    response = stdout.read().decode()
    lines = list(map(str.lstrip, str(response).splitlines()))
    # there should be a header in the output, with status
    try:
        status = Util.uncolorify(lines[2])
    except IndexError:
        raise RuntimeError("Unexpected output: %s" % response)
    if status == "Valid":
        # only pay attention to lines containing products
        # (which are non-empty lines below the header, without expriration and file name info)
        entitlements = [
            line for line in lines[3:]
            if line and not line.startswith("Expiration")
        ]
        return entitlements
    elif status == "Expired" or status == "No Red Hat entitlements found.":
        # return an empty list
        return []
    # if we're here, there's another problem with the entitlements/output
    raise RuntimeError("An error occurred: %s" % response)