def get_system_log (system): system = int (system) view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_blade_state, device_id = system) result = {"ID" : system} return view_helper.return_redfish_resource ("system_log", values = result)
def get_system_bios_config (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.bladebios_lib.get_server_bios_config, {"serverid" : system}) ] result = execute_get_request_queries (query, {"ID" : system}) configs = [] if ("AvailableConfigName" in result): configs.append ({"Config_Name" : result["AvailableConfigName"]}) else: config_list = result.get ("AvailableConfigurations", {}) if (config_list): i = 1 while i in config_list: configs.append (config_list[i]) i += 1 result["AvailableConfigs"] = configs view_helper.update_and_replace_status_information (result, patch) return view_helper.return_redfish_resource ("system_bios_cfg", values = result)
def get_system_thermal (system): system = int (system) view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_blade_state, device_id = system) query_temp = [ (controls.server_health.show_temperature_health, {"serverid" : system}) ] query_fan = [ (controls.server_health.show_fan_health, {"serverid" : system}) ] result_temp = execute_get_request_queries (query_temp) result_fan = execute_get_request_queries (query_fan) temps = parse_sensor_list (sensors = result_temp, convert_reading = True, convert_number = True, sensor_type = "Sensor") fans = parse_sensor_list (sensors = result_fan, convert_reading = True, convert_number = False, sensor_type = "Fan") result = {} view_helper.append_response_information (result, result_temp) view_helper.append_response_information (result, result_fan) if (temps): result["temps"] = temps if (fans): result["fans"] = fans result["ID"] = system return view_helper.return_redfish_resource ("system_thermal", values = result)
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)
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)
def patch_pmdu_power_meter(): view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_rm_state) throttle_args = {} actions = { "DatacenterThrottleEnabled": (apply_power_throttle, parameter_parser("dcpolicy", int, enums.Boolean), { "args": throttle_args }), "AlertEnabled": (apply_power_throttle, parameter_parser("policy", int, enums.Boolean), { "args": throttle_args }), "AlertLimitWatts": (controls.manage_powermeter.set_rack_power_limit_policy, parameter_parser("powerlimit", float), {}) } result = validate_patch_request_and_execute(actions, "pmdu_power_meter") throttle = apply_power_throttle(force_set=True, args=throttle_args) view_helper.append_response_information(result, throttle) return get_handler.get_pmdu_power_meter(patch=result)
def post_system_reset(system): system = int(system) view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_blade_state, device_id=system) validation = { "ResetType": parameter_parser( "type", str, ResetType, { "valid": [ ResetType.ON, ResetType.GRACEFUL_SHUTDOWN, ResetType.GRACEFUL_RESTART ] }) } params = validate_action_parameters(validation) if (params["type"] == ResetType.ON): result = controls.bladepowerstate_lib.set_server_on(system) elif (params["type"] == ResetType.GRACEFUL_SHUTDOWN): result = controls.bladepowerstate_lib.set_server_off(system) else: result = controls.bladepowerstate_lib.set_server_active_power_cycle( system) return check_action_result(result)
def post_system_remotemedia_unmount(system): system = int(system) view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_blade_state, device_id=system) result = controls.manage_rmedia.umount_rmedia(system) return check_action_result(result)
def post_system_power_deactivate_limit(system): system = int(system) view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_blade_config, device_id=system) result = controls.manage_ocspower.set_server_power_limit_off(system) return check_action_result(result)
def post_system_manager_clear_log(system): system = int(system) view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_blade_state, device_id=system) result = controls.bladelog_lib.clear_server_log(system, raw_output=False) return check_action_result(result)
def post_system_phase_clear_faults(system, phase): system = int(system) view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_blade_state, device_id=system) result = controls.manage_ocspower.clear_server_psu_faults(system, phase) return check_action_result(result)
def post_rack_manager_fw_update(): view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_rm_config) validation = {"File": parameter_parser("filename", str)} params = validate_action_parameters(validation) result = controls.manage_rack_manager.set_rack_manager_fwupdate(**params) return check_action_result(result)
def get_rack_manager_tftp (): view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state) query = [ (controls.manage_rack_manager.manager_tftp_server_listfiles, {}) ] result = execute_get_request_queries (query) return view_helper.return_redfish_resource ("rack_manager_tftp", values = result)
def get_rack_manager_thermal (): view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state) query = [ (controls.manage_rack_manager.get_sensor_objects, {}) ] result = execute_get_request_queries (query) return view_helper.return_redfish_resource ("rack_manager_thermal", values = result)
def get_accounts (): view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state) query = [ (controls.manage_user.user_list_all, {}) ] result = execute_get_request_queries (query) return view_helper.return_redfish_resource ("accounts", values = result)
def get_switch_chassis (): 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) return view_helper.return_redfish_resource ("switch_chassis", values = result)
def get_rack_manager_ethernets (): view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state) query = [ (controls.manage_network.display_cli_interfaces, {}) ] result = execute_get_request_queries (query) return view_helper.return_redfish_resource ("rack_manager_ethernets", values = result)
def get_rack_chassis (): view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state) query = [ (controls.manage_rack_manager.read_fru, {"boardtype" : "rm_mb"}) ] result = execute_get_request_queries (query) return view_helper.return_redfish_resource ("rack_chassis", values = result)
def post_switch_fw_update(): view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_rm_config) validation = {"File": parameter_parser("fw_file", str)} params = validate_action_parameters(validation) switch = models.switch_manager.getswitch(load_config.switch_ip, load_config.switch_uart) result = switch.do_upgrade(**params) return check_action_result(result)
def post_system_remotemedia_mount(system): system = int(system) view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_blade_state, device_id=system) validation = {"ImageName": parameter_parser("imagename", str)} params = validate_action_parameters(validation) result = controls.manage_rmedia.mount_rmedia(system, **params) return check_action_result(result)
def post_rack_manager_tftp_get(): view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_rm_config) validation = { "Server": parameter_parser("server", str, IPAddress), "File": parameter_parser("file", str), } params = validate_action_parameters(validation) result = controls.manage_rack_manager.manager_tftp_client_get(**params) return check_action_result(result)
def post_accounts(): view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_rm_config) validation = { "UserName": parameter_parser("username", str), "Password": parameter_parser("pwd", str), "RoleId": parameter_parser("role", str, RoleId) } params = validate_action_parameters(validation) result = controls.manage_user.user_create_new(**params) return check_action_result(result, success_code=201)
def get_system_log_entries (system): system = int (system) view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_blade_state, device_id = system) query = [ (controls.bladelog_lib.read_server_log, {"serverid": system, "raw_output": False}) ] result = execute_get_request_queries (query) result["EntryID"] = system return view_helper.return_redfish_resource ("system_log_entries", values = result)
def patch_rack_manager_chassis(): view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_rm_state) actions = { "IndicatorLED": (controls.manage_rack_manager.set_rack_manager_attention_led, parameter_parser("setting", int, enums.IndicatorLED), {}), } result = validate_patch_request_and_execute(actions, "rack_manager_chassis") return get_handler.get_rack_manager_chassis(patch=result)
def get_switch_thermal (): 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 ("TemperatureSensorState" in result): result["TemperatureSensorState"] = str (enums.Health ( str(result["TemperatureSensorState"]), convert = True)) return view_helper.return_redfish_resource ("switch_thermal", values = result)
def get_session (session): view_helper.run_pre_check (pre_check.pre_check_function_call, command_name_enum.get_rm_state) query = [ (controls.manage_rack_manager.manager_session, {"sessionid": int(session)}) ] result = execute_get_request_queries (query, {"ID" : session}) for error in result.get (view_helper.response_status_key, []): if ("Invalid session id" in error.get (completion_code.desc, "")): raise HTTPError (status = 404) return view_helper.return_redfish_resource ("session", values = result)
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)
def get_rack_manager_log (): 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_log_status, {}) ] result = execute_get_request_queries (query) if ("TelemetryDaemonStatus" in result): result["TelemetryDaemonStatus"] = enums.State (result["TelemetryDaemonStatus"], convert = True) return view_helper.return_redfish_resource ("rack_manager_log", values = result)
def post_switch_reset(): view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_rm_state) validation = { "ResetType": parameter_parser("type", str, ResetType, {"valid": [ResetType.FORCE_RESTART]}) } validate_action_parameters(validation) switch = models.switch_manager.getswitch(load_config.switch_ip, load_config.switch_uart) result = switch.do_reset() return check_action_result(result)
def patch_system_chassis(system): system = int(system) view_helper.run_pre_check(pre_check.pre_check_function_call, command_name_enum.set_blade_state, device_id=system) actions = { "IndicatorLED": (controls.bladepowerstate_lib.set_server_attention_led, parameter_parser("state", int, enums.IndicatorLED), { "serverid": system }) } result = validate_patch_request_and_execute(actions, "system_chassis") return get_handler.get_system_chassis(system, patch=result)