def __ins_rem_psu_fan_fault_action(req): """ Function to process psu fan fault action """ slot = req[SLOT] fan_id = req[FAN_ID] if common.g_psu_tbl.has_key(slot): entity = common.g_psu_tbl[slot] res_hdl = common.g_psu_tbl[slot]['res_hdl'] cur_state = common.get_entity_info_state(res_hdl) if cur_state == consts.PLAT_MEDIA_PRESENT: if fan_id in xrange(1, entity['fNum'] + 1): state = __get_state(req[ACTION]) common.set_entity_fan_status(entity['f%sres_hdl' % fan_id], state) else: print ERROR_HELP_STRING % (FAN_ID, fan_id, 1, entity['fNum']) elif cur_state == consts.PLAT_MEDIA_NOT_PRESENT: print 'error: Psu %s is already in state present=0' % (slot) else: print 'error: Unknown issue in reading data for Psu %s' % (slot) else: print ERROR_HELP_STRING % (SLOT, slot, min( common.g_psu_tbl), max(common.g_psu_tbl))
def process_entity_fan_status(media_tbl, media_str, status): """Process the platform entity media fan fault status event.""" # Get the max fan for script CLI prompt max_fan = media_tbl[1]['fNum'] if status == consts.PLAT_MEDIA_NO_FAULT: cli_str = 'Clr' else: cli_str = 'Ins' while True: print HELP_STRING_MEDIA_FAN_FAULT_EVENT % ( media_str, cli_str, media_str, max(media_tbl.keys()), max_fan) cmd = raw_input('Enter %sFanFlt%s: ' % (media_str, cli_str)) if cmd in ['-q', 'q']: common.exit_script() elif cmd in ['-e', 'e']: break elif cmd.isdigit() and media_tbl.has_key(int(cmd)): # All chars of string are digits and within range media_entry = media_tbl[int(cmd)] # Get current media state state = common.get_entity_info_state(media_entry['res_hdl']) if state == consts.PLAT_MEDIA_PRESENT: fan = raw_input('Enter %sFanFlt%sFan: ' % (media_str, cli_str)) if fan.isdigit() and \ (int(fan) in xrange(1, media_entry['fNum'] + 1)): common.set_entity_fan_status(media_entry['f%sres_hdl' \ % int(fan)], status) else: print ' Unexpected %sFanFlt%sFan %s' % (media_str, cli_str, fan) elif state == consts.PLAT_MEDIA_NOT_PRESENT: print ' Error %s %s not present' % (media_str, cmd) else: print ' Error in reading %s %s state %s' % (media_str, cmd, state) else: print ' Unexpected %s %s\n' % (media_str, cmd)
def chk_psu_fan_is_not_faulty(args): """ Check for psu fan fault """ media_entry = common.g_psu_tbl[int(args[cmdline.SLOT])] # Get current media state state = common.get_entity_info_state(media_entry['res_hdl']) if state == consts.PLAT_MEDIA_PRESENT: if (int(args[cmdline.FAN_ID]) in xrange(1, media_entry['fNum'] + 1)): curr_state = common.get_entity_fan_status( media_entry['f%sres_hdl' % int(args[cmdline.FAN_ID])]) return curr_state == consts.PLAT_MEDIA_NO_FAULT
def __ins_rem_psu_fault_action(req): """ Function to process psu fault action """ slot = req[SLOT] if common.g_psu_tbl.has_key(slot): res_hdl = common.g_psu_tbl[slot]['res_hdl'] cur_state = common.get_entity_info_state(res_hdl) state = __get_state(req[ACTION]) if cur_state == consts.PLAT_MEDIA_PRESENT: common.set_entity_info_status(res_hdl, state) elif cur_state == consts.PLAT_MEDIA_NOT_PRESENT: print 'error: Psu %s is already in state present=0' % (slot) else: print ERROR_HELP_STRING % (SLOT, slot, min( common.g_psu_tbl), max(common.g_psu_tbl))
def __ins_rem_fantray_action(req): """ Function to process fantray insert/remove action """ slot = req[SLOT] if common.g_fantray_tbl.has_key(slot): res_hdl = common.g_fantray_tbl[slot]['res_hdl'] cur_state = common.get_entity_info_state(res_hdl) state = __get_state(req[ACTION]) if cur_state != consts.PLAT_MEDIA_ERROR: if cur_state != state: common.set_entity_info_state(res_hdl, state) else: print 'error: Fantray %s is already in state present=%s' \ % (slot, cur_state) else: print ERROR_HELP_STRING % (SLOT, slot, min( common.g_fantray_tbl), max(common.g_fantray_tbl))
def process_entity_state(media_tbl, media_str, state): """Process the platform entity info media state.""" if state == consts.PLAT_MEDIA_NOT_PRESENT: cli_str = 'Rmv' else: cli_str = 'Ins' while True: print HELP_STRING_MEDIA_STATE_EVENT % (media_str, cli_str, media_str, max(media_tbl.keys())) cmd = raw_input('Enter %s%s: ' % (media_str, cli_str)) if cmd in ['-q', 'q']: common.exit_script() elif cmd in ['-e', 'e']: break elif cmd.isdigit() and media_tbl.has_key(int(cmd)): # All chars of string are digits and within range res_hdl = media_tbl[int(cmd)]['res_hdl'] # Get current state of entity media cur_state = common.get_entity_info_state(res_hdl) if cur_state == consts.PLAT_MEDIA_PRESENT \ or cur_state == consts.PLAT_MEDIA_NOT_PRESENT: if cur_state != state: common.set_entity_info_state(res_hdl, state) else: print ' %s %s already %s' % (media_str, cmd, cli_str) else: print ' Error in reading %s %s state %d' % (media_str, cmd, state) else: print ' Unexpected %s%s %s\n' % (media_str, cli_str, cmd)
def process_entity_fault(media_tbl, media_str, status): """Process the platform entity media fault event.""" if status == consts.PLAT_MEDIA_NO_FAULT: cli_str = 'Clr' else: cli_str = 'Ins' while True: print HELP_STRING_MEDIA_FAULT_EVENT % (media_str, cli_str, media_str, max(media_tbl.keys())) cmd = raw_input('Enter %sFlt%s: ' % (media_str, cli_str)) if cmd in ['-q', 'q']: common.exit_script() elif cmd in ['-e', 'e']: break elif cmd.isdigit() and media_tbl.has_key(int(cmd)): # All chars of string are digits and within range res_hdl = media_tbl[int(cmd)]['res_hdl'] state = common.get_entity_info_state(res_hdl) if state == consts.PLAT_MEDIA_PRESENT: common.set_entity_info_status(res_hdl, status) elif state == consts.PLAT_MEDIA_NOT_PRESENT: print ' Error %s %s not present' % (media_str, cmd) else: print ' Error in reading %s %s state %d' % (media_str, cmd, state) else: print ' Unexpected %sFlt%s %s\n' % (media_str, cli_str, cmd)
def chk_psu_is_absent(args): """ Check for psu absence """ res_hdl = common.g_psu_tbl[int(args[cmdline.SLOT])]['res_hdl'] curr_state = common.get_entity_info_state(res_hdl) return curr_state == consts.PLAT_MEDIA_NOT_PRESENT
def chk_fantray_is_present(args): """ Check for fantray presence """ res_hdl = common.g_fantray_tbl[int(args[cmdline.SLOT])]['res_hdl'] curr_state = common.get_entity_info_state(res_hdl) return curr_state == consts.PLAT_MEDIA_PRESENT