From b6d0ea6a29ff717e6324a4ba464d0ae18e2fb6f2 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Fri, 24 Nov 2023 15:00:56 +0530 Subject: [PATCH] [arcconf] add getconfig and GETLOGS commands for all available controllers Currently, the arcconf getconfig and GETLOGS commands are added with the assumption that the system has only one controller with ID 1. It is possible that a system can have multiple controllers, so commands need to be added to extract information for all available controllers. The arcconf utility does not have a dedicated command to get the list of controllers available in the system. Therefore, parse the 'arcconf list' output to obtain the controller ID for all controllers in the system, and add getconfig and GETLOGS commands for each available controllers. Signed-off-by: Sourabh Jain Suggested-by: Borislav Stoymirski --- sos/report/plugins/arcconf.py | 44 +++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/sos/report/plugins/arcconf.py b/sos/report/plugins/arcconf.py index 7f0f020865..46703e638c 100644 --- a/sos/report/plugins/arcconf.py +++ b/sos/report/plugins/arcconf.py @@ -21,11 +21,41 @@ class arcconf(Plugin, IndependentPlugin): commands = ("arcconf",) def setup(self): - - # get list of adapters - self.add_cmd_output([ - "arcconf getconfig 1", - "arcconf list", - "arcconf GETLOGS 1 UART" - ]) + # Get the list of available adapters + listarcconf = self.collect_cmd_output("arcconf list") + + # Parse the 'arcconf list' output and extract controller IDs. + # For each Controller ID found in 'arcconf list', add commands + # for getconfig and GETLOGS + # + # Sample 'arcconf list' output: + # + # Controller information + # ------------------------------------------------------------- + # Controller ID : Status, Slot, Mode, Name, SerialNumber, WWN + # ------------------------------------------------------------- + # Controller 1: : Optimal, Slot XXXX, XXXX, XXXX, XXXX, XXXX + # ------------------------------------------------------------- + # Controller 2: : Optimal, Slot XXXX, XXXX, XXXX, XXXX, XXXX + + if listarcconf['status'] == 0: + for line in listarcconf['output'].splitlines(): + words = line.split() + + # Skip lines with fewer than two words. + if len(words) < 2: + continue + + # Line with "Controller XX: *" has Controller ID + if words[0] != "Controller" or not words[1].endswith(":"): + continue + + # Controller ID ends with ':', so remove it + controller_id = words[1][:-1] + + # Add new command with Controller ID + self.add_cmd_output([ + f"arcconf getconfig {controller_id}", + f"arcconf GETLOGS UART {controller_id}", + ]) # vim: et ts=4 sw=4