def force_new_boot_profile(module): # check whether 'Automatic BiosParameter Backup' is set scci_map = [ # Param, SCCI Name, SCCI Code, value [ "bios_backup_enabled", "ConfPermanentBiosConfigStorageEnabled", 0x1CC0, None ], ["bios_config_active", "ConfPermanentBiosConfigActive", 0x2721, None], ] datadict = dict() datadict['bios_backup_enabled'] = None datadict['bios_config_active'] = None body = scci_body_start for elem in scci_map: body += add_scci_command("GET", scci_map, elem[1], 0, '') body += scci_body_end # send command list to scripting interface status, data, msg = irmc_scci_post(module, body) if status < 100: module.fail_json(msg=msg, status=status, exception=data) elif status not in (200, 202, 204, 404): module.fail_json(msg=msg, status=status) # evaluate results list datadict, scciresult, sccicontext = get_scciresultlist( data.content, datadict, scci_map) if scciresult != 0: module.fail_json(msg=sccicontext, status=status) # we only need to generate a new profile if 'Automatic BiosParameter Backup' is not set and active if datadict['bios_backup_enabled'] == "0" or datadict[ 'bios_config_active'] == "0": # Delete current Boot Profile Data (if it exists) status, sysdata, msg = irmc_redfish_delete( module, "rest/v1/Oem/eLCM/ProfileManagement/BiosBootOrder") if status < 100: module.fail_json(msg=msg, status=status, exception=sysdata) elif status not in (200, 202, 204, 404): module.fail_json(msg=msg, status=status) # Generate new Boot Profile Data url = "/rest/v1/Oem/eLCM/ProfileManagement/get?PARAM_PATH=Server/SystemConfig/BiosConfig/BiosBootOrder" status, sysdata, msg = irmc_redfish_post(module, url, "") if status < 100: module.fail_json(msg=msg, status=status, exception=sysdata) elif status not in (200, 202, 204): module.fail_json(msg=msg, status=status) # check that current session is terminated status, data, msg = waitForSessionToFinish( module, get_irmc_json(sysdata.json(), ["Session", "Id"])) if status > 30 and status < 100: module.fail_json(msg=msg, status=status, exception=data) elif status not in (200, 202, 204): module.fail_json(msg=msg, log=data, status=status)
def irmc_user(module): # initialize result result['changed'] = False result['status'] = 0 if module.check_mode: result['msg'] = "module was not run" module.exit_json(**result) userdata, setparam_count = setup_datadict(module) preliminary_parameter_check(module, setparam_count) # determine user ID (free or otherwise) userdata['id'] = determine_userid(module) # set up command list if module.params['command'] == "get": body = setup_user_commandlist(userdata, "GET", param_scci_map, userdata['id']) elif module.params['command'] == "change": body = setup_user_commandlist(userdata, "SET", param_scci_map, userdata['id']) elif module.params['command'] == "create": userdata = set_default(userdata) body = setup_user_commandlist(userdata, "CREATE", param_scci_map, userdata['id']) elif module.params['command'] == "delete": body = scci_body_start body += add_scci_command("DELETE", param_scci_map, "ConfBMCAcctUserName", userdata['id'], "") body += add_scci_command("DELETE", param_scci_map, "ConfBMCAcctUserDescription", userdata['id'], "") body += scci_body_end # send command list to scripting interface status, data, msg = irmc_scci_post(module, body) if status < 100: module.fail_json(msg=msg, status=status, exception=data) elif status not in (200, 202, 204): module.fail_json(msg=msg, status=status) # evaluate result list userdata, scciresult, sccicontext = get_scciresultlist( data.content, userdata, param_scci_map) if scciresult != 0: module.fail_json(msg=sccicontext, status=scciresult) userdata['name'] = module.params['name'] if module.params['command'] == "get": result['user'] = setup_resultdata(userdata) else: result['changed'] = True module.exit_json(**result)
def irmc_certificate(module): # initialize result result['changed'] = False result['status'] = 0 if module.check_mode: result['msg'] = "module was not run" module.exit_json(**result) certdata, setparam_count = setup_datadict(module, False) # parameter check if module.params['command'] == "set": check_parameters(module, certdata, setparam_count) certdata, status, msg = read_keyfile(certdata, 'private_key_path') if status != 0: module.fail_json(msg=msg, status=status) certdata, status, msg = read_keyfile(certdata, 'ssl_cert_path') if status != 0: module.fail_json(msg=msg, status=status) certdata, status, msg = read_keyfile(certdata, 'ssl_ca_cert_path') if status != 0: module.fail_json(msg=msg, status=status) if module.params['command'] == "set": body = setup_commandlist(certdata, "SET", param_scci_map) else: body = setup_commandlist(certdata, "GET", param_scci_map) # send command list to scripting interface status, data, msg = irmc_scci_post(module, body) if status < 100: module.fail_json(msg=msg, status=status, exception=data) elif status not in (200, 202, 204): module.fail_json(msg=msg, status=status) # evaluate results list certdata, scciresult, sccicontext = get_scciresultlist( data.content, certdata, param_scci_map) if scciresult != 0: module.fail_json(msg=sccicontext, status=scciresult) if module.params['command'] == "get": result['certificates'] = setup_resultdata(certdata) else: result['changed'] = True module.exit_json(**result)
def irmc_ntp(module): result = dict(changed=False, status=0) if module.check_mode: result['msg'] = "module was not run" module.exit_json(**result) module.params['time_zone'] = None module.params['mmb_time_sync'] = None ntpdata, setparam_count = setup_datadict(module) # preliminary parameter checks if module.params['command'] == "set": if setparam_count < 0: result[ 'msg'] = "Command 'set' requires at least one parameter to be changed!" result['status'] = 10 module.fail_json(**result) # set up command list if module.params['command'] == "get": body = setup_commandlist(ntpdata, "GET", param_scci_map) else: body = setup_commandlist(ntpdata, "SET", param_scci_map) # send command list to scripting interface status, data, msg = irmc_scci_post(module, body) if status < 100: module.fail_json(msg=msg, status=status, exception=data) elif status not in (200, 202, 204): module.fail_json(msg=msg, status=status) # evalaute result list ntpdata, scciresult, sccicontext = get_scciresultlist( data.content, ntpdata, param_scci_map) if scciresult != 0: module.fail_json(msg=sccicontext, status=scciresult) if module.params['command'] == "get": result['time_settings'] = setup_resultdata(ntpdata) else: result['changed'] = True module.exit_json(**result)
def irmc_ldap(module): result = dict( changed=False, status=0 ) if module.check_mode: result['msg'] = "module was not run" module.exit_json(**result) ldapdata, setparam_count = setup_datadict(module) # preliminary parameter check if module.params['command'] == "set" and setparam_count == 0: result['msg'] = "Command 'set' requires at least one parameter to be set!" result['status'] = 10 module.fail_json(**result) if module.params['command'] == "set": body = setup_commandlist(ldapdata, "SET", param_scci_map) else: body = setup_commandlist(ldapdata, "GET", param_scci_map) # send command list to scripting interface status, data, msg = irmc_scci_post(module, body) if status < 100: module.fail_json(msg=msg, status=status, exception=data) elif status not in (200, 202, 204): module.fail_json(msg=msg, status=status) # evaluate results list ldapdata, scciresult, sccicontext = get_scciresultlist(data.content, ldapdata, param_scci_map) if scciresult != 0: module.fail_json(msg=sccicontext, status=scciresult) if module.params['command'] == "get": result['ldap'] = setup_resultdata(ldapdata) else: result['changed'] = True module.exit_json(**result)