def patch_bmc_ethernet (slot_id, eth): pre_check_slot_id(slot_id) if (eth == "eth1"): raise HTTPError (status = 405) requested = view_helper.get_json_request_data () if ("IPv4Addresses" in requested): address = requested["IPv4Addresses"] if (len (address) > 1): raise HTTPError (status = 400, body = "No more than one IP address may be specified.") ip_args = {} actions = { "IPv4Addresses/[0]/Address" : (apply_ip_address, parameter_parser ("address", str, IPAddress), {"args" : ip_args}), "IPv4Addresses/[0]/SubnetMask" : (apply_ip_address, parameter_parser ("mask", str, parameter_parser.validate_subnet_mask), {"args" : ip_args}), "IPv4Addresses/[0]/Gateway" : (apply_ip_address, parameter_parser ("gateway", str, IPAddress), {"args" : ip_args}), "IPv4Addresses/[0]/AddressOrigin" : (apply_ip_address, parameter_parser ("addr_type", str, enums.AddressOrigin), {"args" : ip_args}) } result = validate_patch_request_and_execute (actions, "bmc_ethernet") if (not result): set_data = apply_ip_address (save_args = False, args = ip_args) view_helper.append_response_information (result, set_data) return get_handler.get_rack_manager_ethernet (eth, patch = result)
def get_bmc_log_services(slot_id): pre_check_slot_id(slot_id) query = [(controls.manage_bmc.get_bmc_attention_led_status, {}), (controls.manage_bmc.get_bmc_slot_id, {})] result = execute_get_request_queries(query) return view_helper.return_redfish_resource("bmc_log_service", values=result)
def get_bmc_networkprotocol(slot_id, patch=dict()): pre_check_slot_id(slot_id) query = [(controls.manage_bmc.show_bmc_hostname, {}), (controls.manage_bmc.get_bmc_slot_id, {})] result = execute_get_request_queries(query) view_helper.update_and_replace_status_information(result, patch) return view_helper.return_redfish_resource("bmc_networkprotocol", values=result)
def patch_chassis(slot_id): pre_check_slot_id(slot_id) actions = { "IndicatorLED": (controls.manage_bmc.set_bmc_attention_led, parameter_parser("setting", int, enums.IndicatorLED), {}) } result = validate_patch_request_and_execute(actions, "chassis") return get_handler.get_chassis(slot_id, patch=result)
def get_bmc_log(slot_id): pre_check_slot_id(slot_id) query = [(controls.manage_bmc.get_bmc_attention_led_status, {}), (controls.manage_bmc.get_bmc_slot_id, {})] result = execute_get_request_queries(query) result["DateTime"] = datetime.datetime.fromtimestamp( time.time()).strftime('%Y-%m-%d %H:%M:%S') return view_helper.return_redfish_resource("bmc_log", values=result)
def get_bmc_log_entries(slot_id): pre_check_slot_id(slot_id) query = [(controls.manage_logentry.get_event_log_all, {}), (controls.manage_bmc.get_bmc_slot_id, {})] result = execute_get_request_queries(query) return view_helper.return_redfish_resource("bmc_log_entries", values=result)
def patch_bmc (slot_id): pre_check_slot_id(slot_id) actions = { "DateTime": (controls.manage_bmc.set_bmc_time, parameter_parser("datetime", str, validate_datetime), {}) } result = validate_patch_request_and_execute (actions, "bmc") return get_handler.get_bmc (slot_id, patch = result)
def post_bmc_warm_reset(slot_id): pre_check_slot_id(slot_id) result ={} validation = { "Action" : parameter_parser ("action", str) } params = validate_action_parameters(validation) result = controls.manage_bmc.set_bmc_warm_reset(**params) return check_action_result(result)
def get_chassis_power(slot_id): pre_check_slot_id(slot_id) query = [(controls.manage_bmc.get_bmc_slot_id, {}), (controls.chassis_system_power.get_chassis_power, {})] result = execute_get_request_queries(query) return view_helper.return_redfish_resource("chassis_power", values=result)
def get_bmc(slot_id, patch=dict()): pre_check_slot_id(slot_id) query = [(controls.manage_fwversion.get_ocsfwversion, {}), (controls.manage_bmc.show_bmc_time, { "edm": True }), (controls.manage_bmc.get_bmc_slot_id, {})] result = execute_get_request_queries(query) view_helper.update_and_replace_status_information(result, patch) return view_helper.return_redfish_resource("bmc", values=result)
def post_bmc_fw_update_state(slot_id): pre_check_slot_id(slot_id) result = {} validation = { "Action" : parameter_parser ("action", str) } params = validate_action_parameters(validation) result = controls.manage_bmc.get_bmc_fwupdate_state(**params) if result[completion_code.cc_key] == completion_code.failure: return check_action_result(result) return view_helper.return_redfish_resource ("bmc_fw_update_state", values = result)
def post_chassis_storage_enclosure_disk_power_off(slot_id, se_id, disk_id): pre_check_slot_id(slot_id) if(not(1 <= int(se_id) and int(se_id) <= 4)): raise HTTPError (status = 404) if(not(1 <= int(disk_id) and int(disk_id) <= 22)): raise HTTPError (status = 404) result = controls.storage_enclosure.set_expander_drive_power(int(se_id), int(disk_id), 0) return check_action_result (result)
def get_chassis(slot_id, patch=dict()): pre_check_slot_id(slot_id) query = [(controls.manage_bmc.get_bmc_slot_id, {}), (controls.manage_bmc.get_bmc_attention_led_status, {}), (controls.chassis_system.get_chassis_power_state, {}), (controls.chassis_system.get_chassis_fru, {})] result = execute_get_request_queries(query) view_helper.update_and_replace_status_information(result, patch) return view_helper.return_redfish_resource("chassis", values=result)
def get_bmc_log_entry(slot_id, entry): pre_check_slot_id(slot_id) query = [(controls.manage_logentry.get_event_log, { "log_id": entry }), (controls.manage_bmc.get_bmc_slot_id, {})] result = execute_get_request_queries(query) if "Id" not in result: raise HTTPError(status=404) return view_helper.return_redfish_resource("bmc_log_entry", values=result)
def patch_account (account): pre_check_slot_id(slot_id) view_helper.verify_account_name (account) actions = { "Password" : (controls.manage_user.user_update_password, parameter_parser ("pwd", str), {"username" : account}), "RoleId" : (controls.manage_user.user_update_role, parameter_parser ("role", str, enums.RoleId), {"username" : account}) } result = validate_patch_request_and_execute (actions, "account") return get_handler.get_account (account, patch = result)
def get_chassis_storage_enclosure_thermal(slot_id, se_id): pre_check_slot_id(slot_id) if (not (1 <= int(se_id) and int(se_id) <= 4)): raise HTTPError(status=404) query = [(controls.storage_enclosure.get_storage_enclosure_thermal, { "expander_id": int(se_id) })] result = execute_get_request_queries(query) return view_helper.return_redfish_resource( "chassis_storage_enclosure_thermal", values=result)
def post_bmc_master_write_read(slot_id): pre_check_slot_id(slot_id) result = {} validation = { "Bus" : parameter_parser ("bus", str), "SlaveAddress": parameter_parser("slaveaddress", str), "ReadCount": parameter_parser("readcount", str), "WriteData": parameter_parser("writedata", str) } params = validate_action_parameters(validation) result = controls.manage_bmc.bmc_i2c_master_write_read(**params) if result[completion_code.cc_key] == completion_code.failure: return check_action_result(result) return view_helper.return_redfish_resource ("bmc_master_write_read", values = result)
def get_chassis_storage_enclosure(slot_id, se_id, patch=dict()): pre_check_slot_id(slot_id) if (not (1 <= int(se_id) and int(se_id) <= 4)): raise HTTPError(status=404) query = [(controls.manage_bmc.get_bmc_slot_id, {}), (controls.storage_enclosure.get_id_led_state, { "expander_id": int(se_id) }), (controls.storage_enclosure.get_expander_power, { "expander_id": int(se_id) }), (controls.storage_enclosure.get_expander_fru, { "expander_id": int(se_id) })] result = execute_get_request_queries(query) return view_helper.return_redfish_resource("chassis_storage_enclosure", values=result)
def get_bmc_ethernet(slot_id, eth, patch=dict()): pre_check_slot_id(slot_id) 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_gateway, {}), (controls.manage_network.get_network_status, { "if_name": eth }), (controls.manage_bmc.get_bmc_slot_id, {})] result = execute_get_request_queries(query) if ("InterfaceStatus" in result): result["InterfaceStatus"] = str( enums.State(str(result["InterfaceStatus"]), convert=True)) result["Intf"] = eth result["Description"] = ("Datacenter" if (eth == "eth0") else "Management") + " Network Connection" view_helper.update_and_replace_status_information(result, patch) return view_helper.return_redfish_resource("bmc_ethernet", values=result)
def get_bmc_serialinterface(slot_id): pre_check_slot_id(slot_id) query = [(controls.manage_bmc.get_bmc_slot_id, {})] result = execute_get_request_queries(query) return view_helper.return_redfish_resource("bmc_serialinterface", values=result)
def post_bmc_clear_log (slot_id): pre_check_slot_id(slot_id) result = controls.manage_logentry.clear_event_log() return check_action_result (result)
def get_chassis_thermal_redundancy(slot_id, sensor_id): pre_check_slot_id(slot_id) query = [(controls.manage_bmc.get_bmc_slot_id, {})] result = execute_get_request_queries(query) return view_helper.return_redfish_resource("chassis_thermal_redundancy", values=result)
def get_bmc_ethernets(slot_id): pre_check_slot_id(slot_id) query = [(controls.manage_network.display_cli_interfaces, {}), (controls.manage_bmc.get_bmc_slot_id, {})] result = execute_get_request_queries(query) return view_helper.return_redfish_resource("bmc_ethernets", values=result)