Exemplo n.º 1
0
def set_bmc_fan(param1, param2, param3):

    output = []
    error = ["error", "Error", "ERROR"]
    err = 0

    platform = btools.get_project()
    if platform == "newport":
        cmd = "/usr/local/bin/set_fan_speed.sh %s" % (param3)
    else:
        cmd = "/usr/local/bin/set_fan_speed.sh %s %s %s" % (param3, param2,
                                                            param1)

    data = Popen(cmd, \
                      shell=True, stdout=PIPE).stdout.read()

    # if error while data collection
    if any(x in data for x in error):
        err = 1

    output.append(err)
    result = {
        "Information": {
            "Description": output
        },
        "Actions": [],
        "Resources": [],
    }

    return result
Exemplo n.º 2
0
def get_bmc_tmp(param1):

    l = []
    output = []
    err = 0
    err_status = "exit status"
    platform = btools.get_project()

    arg = ['btools.py', '--TMP', 'sh']

    # ignore the input of project name field
    print "Auto detection, ignore %s" % str(param1)

    with Capturing() as screen_op:
        btools.main(arg)
    data = str(screen_op)

    # if error while data collection
    if err_status in data:
        err = find_err_status(data)

    for t in data.split():
        try:
            l.append(float(t))
        except ValueError:
            pass

    output.append(err)

    if platform == "mavericks" or platform == "mavericks-p0c":
        for i in range(0, 9):
            output.append(int(l[2 * i + 1] * 10))

        #Max device temperature
        output.append(int(l[19] * 10))

    if platform == "montara" or platform == "newport":
        for i in range(0, 5):
            output.append(int(l[2 * i + 1] * 10))

        #Max device temperature
        output.append(int(l[11] * 10))

    result = {
        "Information": {
            "Description": output
        },
        "Actions": [],
        "Resources": [],
    }

    return result
Exemplo n.º 3
0
def get_bmc_ucd():

    l = []
    output = []
    err = 0
    err_status = "exit status"
    platform = btools.get_project()
    valid_range = 12

    arg = ['btools.py', '--UCD', 'sh', 'v']

    if platform == "mavericks-p0c" or platform == "newport":
        valid_range = 16
    if platform == "mavericks":
        valid_range = 15
    if platform == "montara":
        valid_range = 12

    with Capturing() as screen_op:
        btools.main(arg)

    data = str(screen_op)

    # if error while data collection
    if err_status in data:
        err = find_err_status(data)

    t = re.findall('\d+\.\d+', data)
    for i in range(0, valid_range):
        try:
            l.append(float(t[i]))
        except ValueError:
            pass

    output.append(err)

    for i in range(0, valid_range):
        output.append(int(l[i] * 1000))

    result = {
        "Information": {
            "Description": output
        },
        "Actions": [],
        "Resources": [],
    }

    return result