def get_all_nodes_health(): """ This function will use the proliantutils library module "get_host_health_data" to derive the health status of the following components 'BIOS, Fans, Temperature Sensors, Battery, Processor, Memory, Network, Storage. If the health status of all component is ok then overall health of the physical node is returned as "OK" """ try: result = get_all_nodes() final = {} for key, value in result.items(): dict_object = {} if type(value) == type(dict()): v = list(value.values()) ilo_client = client.IloClient(v[1], v[2], v[3]) dict_object = ilo_client.get_host_health_data() q = JSONParser(dict_object) bios = q.dict_query( "GET_EMBEDDED_HEALTH_DATA/HEALTH_AT_A_GLANCE/BIOS_HARDWARE/STATUS" ) fans = q.dict_query( "GET_EMBEDDED_HEALTH_DATA/HEALTH_AT_A_GLANCE/FANS/STATUS") temperature = q.dict_query( "GET_EMBEDDED_HEALTH_DATA/HEALTH_AT_A_GLANCE/TEMPERATURE/STATUS" ) battery = q.dict_query( "GET_EMBEDDED_HEALTH_DATA/HEALTH_AT_A_GLANCE/BATTERY/STATUS" ) processor = q.dict_query( "GET_EMBEDDED_HEALTH_DATA/HEALTH_AT_A_GLANCE/PROCESSOR/STATUS" ) memory = q.dict_query( "GET_EMBEDDED_HEALTH_DATA/HEALTH_AT_A_GLANCE/MEMORY/STATUS" ) network = q.dict_query( "GET_EMBEDDED_HEALTH_DATA/HEALTH_AT_A_GLANCE/NETWORK/STATUS" ) storage = q.dict_query( "GET_EMBEDDED_HEALTH_DATA/HEALTH_AT_A_GLANCE/STORAGE/STATUS" ) total_health = [bios, fans, temperature, battery, processor,\ memory, network, storage] result1 = len(set(total_health)) == 1 if result1: final[v[0]] = "OK" else: final[v[0]] = "Degraded" except: print("Unexpected error:", sys.exc_info()[0]) raise return (final)
def get_all_node_security_status(): """ This function will use the proliantutils library module "get_current_bios_settings" to derive the status of the following BIOS configuration which are important for the security: 'secure boot status (enabled), asset tag (locked), UEFI Shell Script Verification (enabled), UEFI Shell Startup (disabled), Processor AES (enabled)" If the value of any of the configuration deviates from the recommended value, overall security status will be marked as degraded. Refer to BIOS user guide for recommended value of these configurations """ try: result = get_all_nodes() final = {} for key, value in result.items(): dict_object = {} if type(value) == type(dict()): v = list(value.values()) ilo_client = client.IloClient(v[1], v[2], v[3]) dict_object = ilo_client.get_current_bios_settings() q = JSONParser(dict_object) secure_boot_status = q.dict_query("SecureBootStatus") asset_tag = q.dict_query("AssetTagProtection") shell_script_verify = q.dict_query( "UefiShellScriptVerification") shell_startup = q.dict_query("UefiShellStartup") processor_aes = q.dict_query("ProcAes") if v[0] == "secphyworker1.sec.twentynet.local" and \ secure_boot_status.lower() == "disabled": final[v[0]] = "OK" elif secure_boot_status.lower() == "enabled" and \ asset_tag.lower() == "locked" and \ shell_script_verify.lower() == "enabled" and \ shell_startup.lower() == "disabled" and \ processor_aes.lower() == "enabled": final[v[0]] = "OK" else: final[v[0]] = "Degraded" except: print("Unexpected error:", sys.exc_info()[0]) raise return (final)