From 5449d78cc4cb1c397341fffc17e7b3e79d68a69c Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Fri, 8 Nov 2024 11:25:50 -0600 Subject: [PATCH] Adjusted private helper variables Signed-off-by: Maisam Arif Change-Id: I0590b9ee5a1b4d5e6d4ae71c9587550c8d95033b --- amdsmi_cli/amdsmi_helpers.py | 73 +++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/amdsmi_cli/amdsmi_helpers.py b/amdsmi_cli/amdsmi_helpers.py index b9dcca61ba..c28a89d575 100644 --- a/amdsmi_cli/amdsmi_helpers.py +++ b/amdsmi_cli/amdsmi_helpers.py @@ -78,41 +78,6 @@ class AMDSMIHelpers(): self._is_passthrough = True - def os_info(self, string_format=True): - """Return operating_system and type information ex. (Linux, Baremetal) - params: - string_format (bool) True to return in string format, False to return Tuple - returns: - str or (str, str) - """ - operating_system = "" - if self._is_linux: - operating_system = "Linux" - elif self._is_windows: - operating_system = "Windows" - else: - operating_system = "Unknown" - - operating_system_type = "" - if self._is_baremetal: - operating_system_type = "Baremetal" - elif self._is_virtual_os: - operating_system_type = "Guest" - elif self._is_hypervisor: - operating_system_type = "Hypervisor" - else: - operating_system_type = "Unknown" - - # Passthrough Override - if self._is_passthrough: - operating_system_type = "Guest (Passthrough)" - - if string_format: - return f"{operating_system} {operating_system_type}" - - return (operating_system, operating_system_type) - - def is_virtual_os(self): return self._is_virtual_os @@ -126,6 +91,9 @@ class AMDSMIHelpers(): # Returns True if system is baremetal, if system is hypervisor this should return False return self._is_baremetal + def is_passthrough(self): + return self._is_passthrough + def is_linux(self): return self._is_linux @@ -135,6 +103,41 @@ class AMDSMIHelpers(): return self._is_windows + def os_info(self, string_format=True): + """Return operating_system and type information ex. (Linux, Baremetal) + params: + string_format (bool) True to return in string format, False to return Tuple + returns: + str or (str, str) + """ + operating_system = "" + if self.is_linux(): + operating_system = "Linux" + elif self.is_windows(): + operating_system = "Windows" + else: + operating_system = "Unknown" + + operating_system_type = "" + if self.is_baremetal(): + operating_system_type = "Baremetal" + elif self.is_virtual_os(): + operating_system_type = "Guest" + elif self.is_hypervisor(): + operating_system_type = "Hypervisor" + else: + operating_system_type = "Unknown" + + # Passthrough Override + if self.is_passthrough(): + operating_system_type = "Guest (Passthrough)" + + if string_format: + return f"{operating_system} {operating_system_type}" + + return (operating_system, operating_system_type) + + def get_amdsmi_init_flag(self): return AMDSMI_INIT_FLAG