コード例 #1
0
def get_switch_power ():
    view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state)
    
    query = [
        (models.switch_manager.getswitch (load_config.switch_ip, "").getswitch_info, {})
    ]
    
    result = execute_get_request_queries (query)
    
    if ("MainPowerState" in result):
        result["MainPowerState"] = str (enums.Health (
            str(result["MainPowerState"]), convert = True))

    if ("RedundantPowerState" in result):    
        result["RedundantPowerState"] = str (enums.Health (
            str(result["RedundantPowerState"]), convert = True))
        
    return view_helper.return_redfish_resource ("switch_power", values = result)
コード例 #2
0
def get_rack_manager_power ():
    view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state)
    
    query = [
        (controls.manage_ocspower.get_rack_manager_power_reading, {}),
        (controls.manage_ocspower.get_rack_manager_input_voltage, {}),
        (controls.manage_ocspower.get_rack_manager_hsc_status, {}),
        (controls.manage_ocspower.get_rack_manager_psu_status, {})
    ]
    result = execute_get_request_queries (query)
    
    if ("HSC_Status" in result):
        if (result["HSC_Status"] == "Healthy"):
            result["HSC_Status"] = ""
            result["Health"] = enums.Health ("OK")
        else:
            result["Health"] = enums.Health ("Warning")
    
    return view_helper.return_redfish_resource ("rack_manager_power", values = result)
コード例 #3
0
ファイル: get_handler.py プロジェクト: DanielWeiTW/bluefish
def parse_sensor_list(sensors, convert_reading, convert_number, sensor_type):
    """
    Parse the dictionary list of sensor data and convert it into an array used by the REST template.
    
    :param sensors: The dictionary list of sensor data to parse.  As the sensor data is parsed, the
    information will be removed from this dictionary.
    :param convert_reading: A flag indicating if the sensor reading should be converted to a numeber
    or if the raw string should be retained.
    :param convert_number: A flag indicating if the sensor number string should be converted to an
    integer or if the raw string should be retained.
    :param sensor_type: The type of sensor information being parsed.
    
    :return An array containing the parsed sensor data.
    """

    status_key = sensor_type + "_Status"
    number_key = sensor_type + "_Number"
    reading_key = sensor_type + "_Reading"

    parsed = [None] * len(sensors)
    for i, sensor in sensors.items():
        try:
            idx = int(i) - 1
            status = sensor.pop(status_key, None)
            if (status and (status != "ns")):
                sensor["Health"] = enums.Health(status, convert=True)

            if (convert_number and (number_key in sensor)):
                sensor[number_key] = int(sensor[number_key][:-1], 16)

            if (reading_key in sensor):
                reading = sensor[reading_key]
                if (reading == "Disabled"):
                    sensor["State"] = enums.State("Disabled")
                    del sensor[reading_key]
                else:
                    sensor["State"] = enums.State("Enabled")
                    if ((not reading) or (reading == "No Reading")):
                        del sensor[reading_key]
                    elif (convert_reading):
                        reading = view_helper.extract_number(reading)
                        if (reading):
                            sensor[reading_key] = reading
                        else:
                            del sensor[reading_key]

            parsed[idx] = sensor
            del sensors[i]

        except ValueError:
            pass

    return filter(None, parsed)
コード例 #4
0
def get_system (system, patch = dict ()):
    system = int (system)
    if (not patch):
        view_helper.run_pre_check (pre_check.pre_check_function_call,
            command_name_enum.get_blade_state, device_id = system)
    
    query = [
        (controls.bladeinfo_lib.system_info_call, {"bladeId" : system}),
        (controls.bladepowerstate_lib.get_server_default_powerstate, {"serverid" : system}),
        (controls.bladetpmphypresence_lib.get_tpm_physical_presence, {"serverid" : system}),
        (controls.bladenextboot_lib.get_nextboot, {"serverid" : system})
    ]
    
    result = view_helper.flatten_nested_objects (
        execute_get_request_queries (query, {"ID" : system}))
    
    for health in ["Server_Status_HealthRollUp", "Server_Status_Health",
        "Server_ProcessorSummary_Status_HealthRollUp", "Server_ProcessorSummary_Status_Health",
        "Server_MemorySummary_Status_HealthRollUp", "Server_MemorySummary_Status_Health"]:
        if (health in result):
            result[health] = enums.Health (result[health], convert = True)
            
    for state in ["Server_Status_State", "Server_ProcessorSummary_Status_State",
        "Server_MemorySummary_Status_State"]:
        if (state in result):
            result[state] = enums.State (result[state], convert = True)
            
    for state in ["Sever_PowerState", "Default_Power_State"]:
        if (state in result):
            result[state] = enums.PowerState (result[state], convert = True)
    
    if ("BootSourceOverrideTarget" in result):
        result["BootSourceOverrideTarget"] = enums.BootSourceOverrideTarget (
            result["BootSourceOverrideTarget"], convert = True)
    if ("BootSourceOverrideMode" in result):
        result["bootSourceOverrideMode"] = enums.BootSourceOverrideMode (
            result["BootSourceOverrideMode"], convert = True)
    if ("PhysicalPresence" in result):
        result["PhysicalPresence"] = enums.Boolean (result["PhysicalPresence"], convert = True)
        
    if (result.get ("BootSourceOverrideTarget", "") == enums.BootSourceOverrideTarget.NONE):
        result["BootSourceOverrideEnabled"] = enums.BootSourceOverrideEnabled (
            enums.BootSourceOverrideEnabled.DISABLED)
    else:
        if ("BootSourceOverrideEnabled" in result):
            result["BootSourceOverrideEnabled"] = enums.BootSourceOverrideEnabled (
                result["BootSourceOverrideEnabled"], convert = True)
    
    view_helper.update_and_replace_status_information (result, patch)
    return view_helper.return_redfish_resource ("system", values = result)
コード例 #5
0
def get_rack_manager_log_entries ():
    view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state)

    query = [
        (controls.manage_rack_manager.get_rack_manager_log, 
            {"filename": telemetry_log_path, "raw": False})
    ]
    
    result = execute_get_request_queries (query)
    
    if (("members" in result) and (completion_code.cc_key in result)):
        for value in result["members"].itervalues ():
            value["Severity"] = enums.Health (value["Severity"], convert = True)

    return view_helper.return_redfish_resource ("rack_manager_log_entries", values = result)
コード例 #6
0
def get_rack_manager_log_entry (entry):   
    view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state)
    
    query = [
        (controls.manage_rack_manager.get_rack_manager_log,
            {"filename": telemetry_log_path, "raw": False, "startid": entry,
                "endid": entry})
    ]
    
    result = execute_get_request_queries (query)
    result["Entry"] = entry 
        
    if (("members" in result) and (completion_code.cc_key in result)):
        if not result["members"] and result[completion_code.cc_key] == completion_code.success:
            raise HTTPError (status = 404)
        else:
            for value in result["members"].itervalues ():
                value["Severity"] = enums.Health (value["Severity"], convert = True)
    
    return view_helper.return_redfish_resource ("rack_manager_log_entry", values = result)
コード例 #7
0
def get_rack_manager_ethernet (eth, patch = dict ()):
    if (not patch):
        view_helper.run_pre_check (pre_check.pre_check_function_call,
            command_name_enum.get_rm_state)
    
    query = [
        (controls.manage_network.get_network_mac_address, {"if_name" : eth}),
        (controls.manage_network.get_network_ip_address, {"if_name" : eth}),
        (controls.manage_network.get_network_subnetmask, {"if_name" : eth}),
        (controls.manage_network.get_network_ip_address_origin, {"if_name" : eth}),
        (controls.manage_network.get_network_status, {"if_name" : eth})
    ]
    if (eth == "eth0"):
        query.append ((controls.manage_network.get_network_gateway, {}))
    else:
        query.append ((controls.manage_network.get_management_network, {}))
    
    result = execute_get_request_queries (query)
        
    if ("InterfaceStatus" in result):
        result["InterfaceState"] = enums.State (result["InterfaceStatus"], convert = True)
        result["InterfaceStatus"] = enums.Boolean (result["InterfaceStatus"], convert = True)
        
    if ("AddressOrigin" in result):
        result["AddressOrigin"] = enums.AddressOrigin (result["AddressOrigin"], convert = True)
        
    if ("Management_Network" in result):
        result["Management_Network"] = result["Management_Network"].netmask
        
    for key in ["IPAddress", "SubnetMask", "Gateway"]:
        if ((key in result) and (not result[key])):
            del result[key]
    
    result["Intf"] = eth
    result["Description"] = ("Datacenter" if (eth == "eth0") else "Management") + " Network Connection"
    result["InterfaceHealth"] = enums.Health ("OK")

    view_helper.update_and_replace_status_information (result, patch)
    return view_helper.return_redfish_resource ("rack_manager_ethernet", values = result)