[SWDEV-537852] Update compute-partition set error messages (#505)

[SWDEV-537852] Update compute-partition set error messages

Setting compute partition needs sudo privileges. Added
AmdSmiPermissionDeniedException to display CLI elevated
permission errors.

Signed-off-by: Bindhiya Kanangot Balakrishnan <Bindhiya.KanangotBalakrishnan@amd.com>
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Co-authored-by: Maisam Arif <Maisam.Arif@amd.com>

[ROCm/amdsmi commit: 27a1705d96]
This commit is contained in:
Kanangot Balakrishnan, Bindhiya
2025-08-01 08:22:22 -05:00
committed by GitHub
parent e5d03d099a
commit 67f21bb032
3 changed files with 19 additions and 3 deletions
+1 -1
View File
@@ -155,5 +155,5 @@ if __name__ == "__main__":
except amdsmi_cli_exceptions.AmdSmiException as e:
_print_error(str(e), amd_smi_commands.logger.destination)
except amdsmi_exception.AmdSmiLibraryException as e:
exc = amdsmi_cli_exceptions.AmdSmiAMDSMIErrorException(amd_smi_commands.logger.format, e.get_error_code())
exc = amdsmi_cli_exceptions.AmdSmiLibraryErrorException(amd_smi_commands.logger.format, e.get_error_code())
_print_error(str(exc), amd_smi_commands.logger.destination)
@@ -264,6 +264,21 @@ class AmdSmiInvalidSubcommandException(AmdSmiException):
self.stdout_message = f"{common_message} Error code: {self.value}"
class AmdSmiPermissionDeniedException(AmdSmiException):
def __init__(self, command, outputformat: str):
super().__init__()
self.value = -11
self.command = command
self.output_format = outputformat
common_message = f"AMD-SMI Command '{self.command}' requires elevation (sudo privileges required)"
self.json_message["error"] = common_message
self.json_message["code"] = self.value
self.csv_message = f"error,code\n{common_message}, {self.value}"
self.stdout_message = f"{common_message} Error code: {self.value}"
class AmdSmiUnknownErrorException(AmdSmiException):
def __init__(self, command, outputformat: str):
super().__init__()
@@ -279,7 +294,7 @@ class AmdSmiUnknownErrorException(AmdSmiException):
self.stdout_message = f"{common_message} Error code: {self.value}"
class AmdSmiAMDSMIErrorException(AmdSmiException):
class AmdSmiLibraryErrorException(AmdSmiException):
def __init__(self, outputformat: str, error_code):
super().__init__()
self.value = -1000 - abs(error_code)
+2 -1
View File
@@ -217,7 +217,8 @@ class AMDSMIParser(argparse.ArgumentParser):
def _is_command_supported(self, user_input, acceptable_values, command_name):
if acceptable_values == "N/A":
raise amdsmi_cli_exceptions.AmdSmiCommandNotSupportedException(command_name, self.helpers.get_output_format())
outputformat = self.helpers.get_output_format()
raise amdsmi_cli_exceptions.AmdSmiPermissionDeniedException(command_name, outputformat)
elif str(user_input).upper() not in acceptable_values:
print(f"Valid inputs are {acceptable_values}")
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterValueException(sys.argv[1], str(user_input).upper(), self.helpers.get_output_format())