Exemplo n.º 1
0
def get_pmdu_power_meter (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_powermeter.get_rack_power_limit_policy, {}),
        (controls.manage_powermeter.get_rack_power_throttle_status, {}),
        (controls.manage_powermeter.get_rack_power_reading, {}),
        (controls.manage_powermeter.get_rack_pru_fw_version, {})
    ]
    result = execute_get_request_queries (query)
    
    if ("Feed1PowerStatus" in result):
        if (result["Feed1PowerStatus"] == "Healthy"):
            result["Feed1PowerStatus"] = ""
    if ("Feed2PowerStatus" in result):
        if (result["Feed2PowerStatus"] == "Healthy"):
            result["Feed2PowerStatus"] = ""
    if ("IsDcThrottleEnabled" in result):
        result["IsDcThrottleEnabled"] = enums.Boolean (result["IsDcThrottleEnabled"],
            convert = True)
    if ("IsDcThrottleActive" in result):
        result["IsDcThrottleActive"] = enums.Boolean (result["IsDcThrottleActive"], convert = True)
    if ("IsAlertEnabled" in result):
        result["IsAlertEnabled"] = enums.Boolean (result["IsAlertEnabled"], convert = True)
    if ("IsAlertActive" in result):
        result["IsAlertActive"] = enums.Boolean (result["IsAlertActive"], convert = True)
    
    view_helper.update_and_replace_status_information (result, patch)
    return view_helper.return_redfish_resource ("pmdu_power_meter", values = result)
Exemplo n.º 2
0
def get_rack_inventory ():
    view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state)
    
    query = [
        (controls.bladeinfo_lib.manager_inventory, {"mode" : "pmdu"})
    ]
    
    result = execute_get_request_queries (query)
    
    parsed = [None] * len (result)
    if (result[completion_code.cc_key] == completion_code.success):
        for i, item in result.items ():
            try:
                idx = int (i) - 1
                if ("Port_Present" in item):
                    item["Port_Present"] = enums.Boolean (item["Port_Present"], convert = True)
                    
                if ("Port_State" in item):
                    item["Port_State"] = enums.PowerState (item["Port_State"], convert = True)
                            
                parsed[idx] = item
                del result[i]
                
            except ValueError:
                pass
            
    parsed = filter (None, parsed)
    if (parsed):
        result["list"] = parsed
        
    return view_helper.return_redfish_resource ("rack_inventory", values = result)
Exemplo n.º 3
0
def apply_power_throttle(policy=None,
                         dcpolicy=None,
                         force_set=False,
                         args=dict()):
    """
    Apply system power throttle settings.  The settings will only be applied if all arguments have
    been received, or if the force_set flag has been set.  If forcing, any missing arguments will be
    queried from the system.  If no parameters have been saved or the parameters have previously
    been applied, forcing is a noop.
    
    :param policy: The enable/disable flag for power alert throttling.
    :param dcpolicy: The enable/disable flag for datacenter alert throttling.
    :param force_set: Flag to indicate the available parameters should be applied.
    :param args: The set of previously received parameters.
    
    :return Result information for the configuration request.
    """

    result = {}

    if (policy is not None):
        args["policy"] = policy
    if (dcpolicy is not None):
        args["dcpolicy"] = dcpolicy

    done = args.get("done", False)
    if ((not done) and force_set and (("policy" not in args) !=
                                      ("dcpolicy" not in args))):
        current = controls.manage_powermeter.get_rack_power_throttle_status()
        if (current[completion_code.cc_key] != completion_code.success):
            return current

        args["policy"] = args.get(
            "policy",
            int(enums.Boolean(current["IsAlertEnabled"], convert=True)))
        args["dcpolicy"] = args.get(
            "dcpolicy",
            int(enums.Boolean(current["IsDcThrottleEnabled"], convert=True)))

    if ((not done) and ("policy" in args) and ("dcpolicy" in args)):
        result = controls.manage_powermeter.set_rack_power_throttle(**args)
        args["done"] = True

    return result
Exemplo n.º 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)
Exemplo n.º 5
0
def get_all_power_control_status (port_type, count):
    """
    Get the status for all power control ports of a single type.
    
    :param port_type: The port type to query.
    :param count: The number of ports.
    
    :return A dictionary with the operation result.
    """
    
    status = [dict () for _ in range (0, count)]
    result = {}
    if (port_type == "relay"):
        for i in range (0, count):
            state = controls.manage_powerport.powerport_get_port_status (i + 1, port_type)
            if (state[completion_code.cc_key] == completion_code.success):
                status[i].update (state)
                if ("Relay" in status[i]):
                    status[i]["Relay"] = enums.PowerState (status[i]["Relay"], convert = True)
                else:
                    view_helper.append_response_information (result, state)
    else:
        start = 24 if (port_type == "rack") else 0
        end = 24 + count if (port_type == "rack") else count
        
        present = controls.manage_powerport.powerport_get_all_port_presence (raw = True,
            ports = range (start, end))
        if (present[completion_code.cc_key] == completion_code.success):
            for i in range (0, count):
                status[i]["Port Presence"] = enums.Boolean (present[i + 1], convert = True)
        else:
            view_helper.append_response_information (result, present)
            
        state = controls.manage_powerport.powerport_get_all_port_status (raw = True)
        if (state[completion_code.cc_key] == completion_code.success):
            for i in range (0, count):
                status[i]["Port State"] = enums.PowerState (state[i + 1], convert = True)
                
            if (port_type == "rack"):
                for i, j in enumerate (range (count + 1, (count * 2) + 1)):
                    status[i]["Boot Strap"] = enums.BootStrapping (state[j], convert = True)
        else:
            view_helper.append_response_information (result, state)
            
    result[port_type + "_ports"] = status
    return result
Exemplo n.º 6
0
def get_system_power (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.manage_ocspower.get_server_power_limit, {"serverid" : system}),
        (controls.manage_ocspower.get_server_power_reading, {"serverid" : system}),
        (controls.manage_ocspower.get_server_default_power_limit, {"serverid" : system}),
        (controls.manage_ocspower.get_server_psu_alert, {"serverid" : system}),
        (controls.manage_ocspower.get_server_psu_status, {"serverid" : system}),
        (controls.manage_ocspower.get_server_psu_fw_version, {"serverid" : system}),
        (controls.manage_ocspower.get_server_psu_bootloader_version, {"serverid" : system})
    ]
    
    result = execute_get_request_queries (query, {"ID" : system})
    
    for key in ["StaticLimit", "PowerReadingWatts", "MinPowerReadingWatts", "MaxPowerReadingWatts",
        "AvgPowerReadingWatts", "SamplingPeriodSeconds", "PowerLimit", "ThrottleDuration", "LimitDelay"]:
        if (key in result):
            result[key] = parameters.remove_non_numeric (str(result[key]))
    
    for key in ["Alert_Enabled", "AutoProchot", "BladeProchot", "Balancing", "External_Power",
        "Pre_charge_Circuit", "Discharge", "Charge", "Charging", "Discharging", "Initialized"]:
        if (key in result):
            result[key] = enums.Boolean (result[key], convert = True)
            
    for key in ["Pin", "Vin", "Pout"]:
        if (key in result):
            result[key] = result[key][:-1]
    
    if ("StaticState" in result):
        result["StaticState"] = enums.State (result["StaticState"], convert = True)
    if ("SamplingPeriodSeconds" in result):
        result["SamplingPeriodSeconds"] = int (result["SamplingPeriodSeconds"]) / 60
    if ("AlertAction" in result):
        result["AlertAction"] = enums.AlertAction (result["AlertAction"], convert = True)
    if ("Faults" in result):
        if (not result["Faults"]):
            result["Health"] = "OK"
        else:
            result["Health"] = "Warning"

    view_helper.update_and_replace_status_information (result, patch)
    return view_helper.return_redfish_resource ("system_power", values = result)
Exemplo n.º 7
0
def get_pdu_control (port, patch = dict ()):
    if (not patch):
        view_helper.run_pre_check (pre_check.pre_check_function_call,
            command_name_enum.get_rm_state)
    
    port = int (port)
    query = [
        (controls.manage_powerport.powerport_get_port_presence, {"port_type" : "pdu",
            "port_id" : port}),
        (controls.manage_powerport.powerport_get_port_status, {"port_type" : "pdu",
            "port_id" : port})
    ]
    result = execute_get_request_queries (query, init_values = {"ID" : port})
    
    if ("Port_Presence" in result):
        result["Port_Presence"] = enums.Boolean (result["Port_Presence"], convert = True)
    if ("Port_State" in result):
        result["Port_State"] = enums.PowerState (result["Port_State"], convert = True)
    
    view_helper.update_and_replace_status_information (result, patch)
    return view_helper.return_redfish_resource ("power_control_pdu", values = result)
Exemplo n.º 8
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)
Exemplo n.º 9
0
def get_system_fpga (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)
    
    result = controls.manage_fpga.get_fpga_i2c_version (system)
    if ((not patch) and
        (result.get (completion_code.cc_key, completion_code.failure) != completion_code.success)):
        view_helper.raise_status_response (500, view_helper.create_response_with_status (result))
        
    query = [
        (controls.manage_fpga.get_fpga_bypass_mode, {"serverid" : system}),
        (controls.manage_fpga.get_fpga_health, {"serverid" : system}),
        (controls.manage_fpga.get_fpga_assetinfo, {"serverid" : system}),
        (controls.manage_fpga.get_fpga_temp, {"serverid" : system})
    ]
    
    result["ID"] = system
    result = view_helper.remove_key_leading_number(execute_get_request_queries (query, result))
    
    for link in ["PCIe_HIP_0_Up", "PCIe_HIP_1_Up", "_40G_Link_0_Up", "_40G_Link_1_Up"]:
        if (link in result):
            result[link] = enums.LinkState (result[link], convert = True)
            
    for act in ["_40G_Link_0_Tx_Activity", "_40G_Link_1_Tx_Activity", "_40G_Link_0_Rx_Activity",
        "_40G_Link_1_Rx_Activity"]:
        if (act in result):
            result[act] = enums.Boolean (result[act], convert = True)
            
    if ("Bypass_Mode" in result):
        result["Bypass_Mode"] = enums.BypassMode (result["Bypass_Mode"], convert = True)
    if ("User_Logic_Network" in result):
        result["User_Logic_Network"] = enums.UserLogic (result["User_Logic_Network"],
            convert = True)

    view_helper.update_and_replace_status_information (result, patch)
    return view_helper.return_redfish_resource ("system_fpga", values = result)
Exemplo n.º 10
0
def get_rack_manager (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_rack_manager.show_rack_manager_hostname, {}),
        (controls.manage_fwversion.get_ocsfwversion, {}),
        (controls.manage_rack_manager.manager_tftp_server_status, {}),
        (controls.manage_rack_manager.manager_nfs_server_status, {}),
        (controls.manage_rack_manager.get_rack_manager_ntp_status, {}),
        (controls.manage_rack_manager.get_rack_manager_itp_status, {}),
        (controls.manage_rack_manager.get_rack_manager_ntp_server, {}),
        (controls.manage_rack_manager.get_manager_throttle_local_bypass, {}),
        (controls.manage_rack_manager.get_manager_throttle_output_enable, {}),
        (controls.manage_rack_manager.show_rack_manager_time, {"edm" : True}),
        (controls.manage_rack_manager.get_rm_uptime, {})
    ]
    if (pre_check.get_mode () == rm_mode_enum.rowmanager):
        query.append ((controls.manage_rack_manager.get_row_throttle_bypass, {}))
        query.append ((controls.manage_rack_manager.get_row_throttle_output_enable, {}))
    
    result = execute_get_request_queries (query)
    
    for key in ["TFTPStatus", "NFSStatus", "NTPState", "ITPState"]:
        if (key in result):
            result[key] = enums.ServiceStatus (result[key], convert = True)
        
    for key in ["TFTPService", "NFSService", "NTPService", "ITPService", "Local_Bypass",
        "Row_Bypass", "Local_Enable", "Row_Enable"]:
        if (key in result):
            result[key] = enums.Boolean (result[key], convert = True)
            
    view_helper.update_and_replace_status_information (result, patch)
        
    return view_helper.return_redfish_resource ("rack_manager", values = result)