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 post_accounts (): 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 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 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 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 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 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)