From 8bc37a19d2df5e53d21e7369c9dc5087aaef87ec Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 5 Jun 2025 12:10:10 -0500 Subject: [PATCH] [SWDEV-536417] CPER & AFID CLI Fixes Signed-off-by: Maisam Arif Change-Id: I20aafb1cd2bf8386c30e6d0a0fff8df9c8587554 --- amdsmi_cli/amdsmi_commands.py | 21 ++++++++++----------- amdsmi_cli/amdsmi_parser.py | 14 ++++++++++---- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/amdsmi_cli/amdsmi_commands.py b/amdsmi_cli/amdsmi_commands.py index d3c0a58614..fb980794be 100644 --- a/amdsmi_cli/amdsmi_commands.py +++ b/amdsmi_cli/amdsmi_commands.py @@ -6451,17 +6451,16 @@ class AMDSMICommands(): self.logger.combine_arrays_to_json() self.logger.clear_multiple_devices_output() - if not self.logger.is_json_format(): - # print legend - legend_parts = [ - "\n\nLegend:", - " * = Current mode"] - legend_output = "\n".join(legend_parts) - if self.logger.destination == 'stdout': - print(legend_output) - else: - with self.logger.destination.open('a', encoding="utf-8") as output_file: - output_file.write(legend_output + '\n') + # print legend + legend_parts = [ + "\n\nLegend:", + " * = Current mode"] + legend_output = "\n".join(legend_parts) + if self.logger.destination == 'stdout': + print(legend_output) + else: + with self.logger.destination.open('a', encoding="utf-8") as output_file: + output_file.write(legend_output + '\n') def ras(self, args, multiple_devices=False, gpu=None, cper=None, afid=None, diff --git a/amdsmi_cli/amdsmi_parser.py b/amdsmi_cli/amdsmi_parser.py index d1aaef89ba..09f90ae0f8 100644 --- a/amdsmi_cli/amdsmi_parser.py +++ b/amdsmi_cli/amdsmi_parser.py @@ -1439,15 +1439,21 @@ class AMDSMIParser(argparse.ArgumentParser): ras_parser.formatter_class = lambda prog: AMDSMISubparserHelpFormatter(prog) ras_parser.set_defaults(func=func) - # Required flags and arguments: - ras_parser.add_argument("--cper", action="store_true", required=False, help=cper_help) - ras_parser.add_argument("--afid", action="store_true", required=False, help=afid_help) + # Group arguments into cper and afid categories and make them mutually exclusive + ras_exclusive_group = ras_parser.add_mutually_exclusive_group(required=True) + ras_exclusive_group.title = "RAS Exclusive Arguments" + ras_exclusive_group.add_argument("--cper", action="store_true", help=cper_help) + ras_exclusive_group.add_argument("--afid", action="store_true", help=afid_help) + + # CPER Arguments ras_parser.add_argument("--severity", type=str.lower, nargs='+', default=['all'], help=severity_help, choices=severity_choices, metavar='SEVERITY') ras_parser.add_argument("--folder", type=str, action=self._check_folder_path(), default=False, help=folder_help) ras_parser.add_argument("--file-limit", type=self._positive_int, action='store', default=1000, help=file_limit_help) - ras_parser.add_argument("--cper-file", action=self._check_cper_file_path(), metavar="CPER_FILE", help=cper_file_help) ras_parser.add_argument("--follow", action="store_true", default=False, help=follow_help) + # AFID Arguments + ras_parser.add_argument("--cper-file", action=self._check_cper_file_path(), metavar="CPER_FILE", help=cper_file_help) + # Add common modifiers and device selection arguments. self._add_device_arguments(ras_parser, required=False) self._add_command_modifiers(ras_parser)