Exemplo n.º 1
0
def ResultHandler(t, result):

    hours = 0
    minutes = 0
    seconds = 0

    lines = result[1].splitlines()
    for line in lines:
        if line[0:6] == "Uptime":
            # Parsing uptime output of p2p debug
            v = line[8:]
            hs = v.split('h')
            hours = re.search('(\\d+)', hs[0], re.IGNORECASE).group(1)
            ms = hs[1].split('m')
            minutes = re.search('(\\d+)', ms[0], re.IGNORECASE).group(1)
            ss = ms[1].split('s')
            seconds = re.search('(\\d+)', ss[0], re.IGNORECASE).group(1)

    status = 0
    if int(minutes) < 5 and int(hours) == 0:
        t.MarkAsSucceed()
    else:
        if result[1].find('INITIALIZING') > 0 or result[1].find('WAITING') > 0:
            t.MarkAsFailed()
            status = 1
        else:
            t.MarkAsSucceed()

    return r.Result(t.GetComponent(), t.GetName(), status)
Exemplo n.º 2
0
def ResultHandler(t, result):
    status = 0
    if result[0] != 0:
        t.MarkAsFailed()
        status = 1
    else:
        t.MarkAsSucceed()
    return r.Result(t.GetComponent(), t.GetName(), status)
Exemplo n.º 3
0
def ResultHandler(t, result):
    status = -1
    if 'running' in result[1]:
        t.MarkAsSucceed()
        status = 0
    else:
        t.MarkAsFailed()
        status = 1

    result = r.Result(t.GetComponent(), t.GetName(), status)
    # If you have additional data for results, you can use r.append(key, value) method
    # All extra fields will be added to payload field of resulting YAML
    return result