예제 #1
0
def get_temp():
    temp_result = []
    sensors = rest_sensors.get_sensors()
    result = sensors["Information"]
    i = 0
    for temp_sensor in result:
        i += 1
        for info in temp_sensor.keys():
            if ("Temp" in info):
                temp_data = {}
                temp_data["TemperatureSensorID"] = i
                temp_data["Name"] = info
                components = info.split(' ')
                str = " "
                position = str.join(components[:-1])
                temp_data["Position"] = position
                temperature = temp_sensor[info].split(" ")[0]
                temp_data["Temperature"] = temperature
                if (float(temperature) > 0):
                    temp_data["OperationalStatus"] = "UP"
                else:
                    temp_data["OperationalStatus"] = "DOWM"
                temp_result.append(temp_data)

    fresult = {"TemperatureState": temp_result}

    return fresult
예제 #2
0
def get_fan():
    fan_result = []
    sensors = rest_sensors.get_sensors()
    result = sensors["Information"]
    i = 0
    for fan_sensor in result:
        i += 1
        for info, rpms in fan_sensor.items():
            if ("Fan" in info):
                fan_data = {}
                id = info.split("Fan ")[1].split(" ")[0]
                position = info.split(':')[0].split()[2]
                if (" RPM" in rpms):
                    speed = rpms.split(" RPM")[0]
                    speed = int(speed)
                    if (speed > 0):
                        fan_data["OperationalState"] = "UP"
                        fan_data["Status"] = "Present"
                    else:
                        fan_data["OperationalState"] = "DOWN"
                        fan_data["Status"] = "Absent"


#                    print("Id: %s, Position: %s, Speed %d" % (id, position, speed))

                fan_data["FanID"] = id
                fan_data["Position"] = position
                fan_data["OperationalSpeed"] = speed
                fan_result.append(fan_data)

    fresult = {"FanState": fan_result}

    return fresult
예제 #3
0
파일: rest.py 프로젝트: HengWang/openbmc
def rest_sensors_hdl():
    return rest_sensors.get_sensors()
예제 #4
0
 def helper_rest_sensors_hdl(self, request):
     return web.json_response(rest_sensors.get_sensors(),
                              dumps=dumps_bytestr)
예제 #5
0
def rest_sensors_hdl():
    return rest_sensors.get_sensors()
예제 #6
0
 async def rest_sensors_hdl(self, request):
     return web.json_response(rest_sensors.get_sensors())