From 2632a5912c246b1ddab97450a7b85aebaa2fb0a3 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Mon, 13 Apr 2020 15:21:45 +0000 Subject: [PATCH 1/4] [component]: Introduce new firmware management API. Signed-off-by: Nazarii Hnydyn --- sonic_platform_base/component_base.py | 57 ++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/sonic_platform_base/component_base.py b/sonic_platform_base/component_base.py index 97444460ae2f..444750ee87f2 100644 --- a/sonic_platform_base/component_base.py +++ b/sonic_platform_base/component_base.py @@ -39,9 +39,37 @@ def get_firmware_version(self): """ raise NotImplementedError + def get_available_firmware_version(self, image_path): + """ + Retrieves the available firmware version of the component + + Args: + image_path: A string, path to firmware image + + Returns: + A string containing the available firmware version of the component + """ + raise NotImplementedError + + def get_update_notification(self, image_path): + """ + Retrieves a notification on what should be done in order to complete + the component firmware update + + Args: + image_path: A string, path to firmware image + + Returns: + A string containing the component firmware update notification if required. + By default 'None' value will be used, which indicates that no actions are required + """ + return None + def install_firmware(self, image_path): """ - Installs firmware to the component + Installs firmware to the component. + It's user's responsibility to complete firmware update + in case some extra steps are required (e.g., reboot, power cycle, etc.) Args: image_path: A string, path to firmware image @@ -50,3 +78,30 @@ def install_firmware(self, image_path): A boolean, True if install was successful, False if not """ raise NotImplementedError + + def update_firmware(self, image_path): + """ + Updates firmware of the component. + It's API's responsibility to complete firmware update + in case some extra steps are required (e.g., reboot, power cycle, etc.) + + Args: + image_path: A string, path to firmware image + + Raises: + RuntimeError: update failed + """ + raise NotImplementedError + + def is_delayed_firmware_update_supported(self, image_path): + """ + Retrieves a value indicating whether immediate actions are required + to complete the component firmware update (e.g., reboot, power cycle, etc.) + + Args: + image_path: A string, path to firmware image + + Returns: + A boolean, True if delayed firmware update supported, False if not + """ + raise NotImplementedError From 777901f7a30ad16255629358e641d505402631bb Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Fri, 24 Apr 2020 09:54:34 +0000 Subject: [PATCH 2/4] [component]: Update firmware management API. Signed-off-by: Nazarii Hnydyn --- sonic_platform_base/component_base.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/sonic_platform_base/component_base.py b/sonic_platform_base/component_base.py index 444750ee87f2..93cf20366ced 100644 --- a/sonic_platform_base/component_base.py +++ b/sonic_platform_base/component_base.py @@ -51,7 +51,7 @@ def get_available_firmware_version(self, image_path): """ raise NotImplementedError - def get_update_notification(self, image_path): + def get_firmware_update_notification(self, image_path): """ Retrieves a notification on what should be done in order to complete the component firmware update @@ -92,16 +92,3 @@ def update_firmware(self, image_path): RuntimeError: update failed """ raise NotImplementedError - - def is_delayed_firmware_update_supported(self, image_path): - """ - Retrieves a value indicating whether immediate actions are required - to complete the component firmware update (e.g., reboot, power cycle, etc.) - - Args: - image_path: A string, path to firmware image - - Returns: - A boolean, True if delayed firmware update supported, False if not - """ - raise NotImplementedError From b066ec7fa9f58b7e8dec3c43c6fa30d2104da994 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Fri, 24 Apr 2020 11:14:36 +0000 Subject: [PATCH 3/4] [component]: Extend docstrings for firmware management API. Signed-off-by: Nazarii Hnydyn --- sonic_platform_base/component_base.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sonic_platform_base/component_base.py b/sonic_platform_base/component_base.py index 93cf20366ced..7cbe478c1457 100644 --- a/sonic_platform_base/component_base.py +++ b/sonic_platform_base/component_base.py @@ -68,8 +68,13 @@ def get_firmware_update_notification(self, image_path): def install_firmware(self, image_path): """ Installs firmware to the component. - It's user's responsibility to complete firmware update - in case some extra steps are required (e.g., reboot, power cycle, etc.) + + This API performs firmware installation only: this may/may not be the same as firmware update. + In case platform component requires some extra steps (apart from calling Low Level Utility) + to load the installed firmware (e.g, reboot, power cycle, etc.) - this must be done manually by user. + + Note: in case immediate actions are required to complete the component firmware update + (e.g., reboot, power cycle, etc.) - will be done automatically by API and no return value provided Args: image_path: A string, path to firmware image @@ -82,8 +87,10 @@ def install_firmware(self, image_path): def update_firmware(self, image_path): """ Updates firmware of the component. - It's API's responsibility to complete firmware update - in case some extra steps are required (e.g., reboot, power cycle, etc.) + + This API performs firmware update: it assumes firmware installation and loading in a single call. + In case platform componet requires some extra steps (apart from calling Low Level Utility) + to load the installed firmware (e.g, reboot, power cycle, etc.) - this will be done automatically by API. Args: image_path: A string, path to firmware image From d96344e22cf90cbb4b36b476320786363d66cb6d Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Thu, 30 Apr 2020 11:53:34 +0000 Subject: [PATCH 4/4] [component]: Fix review comments. Signed-off-by: Nazarii Hnydyn --- sonic_platform_base/component_base.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sonic_platform_base/component_base.py b/sonic_platform_base/component_base.py index 7cbe478c1457..37e767aa0bab 100644 --- a/sonic_platform_base/component_base.py +++ b/sonic_platform_base/component_base.py @@ -34,6 +34,8 @@ def get_firmware_version(self): """ Retrieves the firmware version of the component + Note: the firmware version will be read from HW + Returns: A string containing the firmware version of the component """ @@ -43,6 +45,8 @@ def get_available_firmware_version(self, image_path): """ Retrieves the available firmware version of the component + Note: the firmware version will be read from image + Args: image_path: A string, path to firmware image @@ -67,11 +71,11 @@ def get_firmware_update_notification(self, image_path): def install_firmware(self, image_path): """ - Installs firmware to the component. + Installs firmware to the component This API performs firmware installation only: this may/may not be the same as firmware update. In case platform component requires some extra steps (apart from calling Low Level Utility) - to load the installed firmware (e.g, reboot, power cycle, etc.) - this must be done manually by user. + to load the installed firmware (e.g, reboot, power cycle, etc.) - this must be done manually by user Note: in case immediate actions are required to complete the component firmware update (e.g., reboot, power cycle, etc.) - will be done automatically by API and no return value provided @@ -86,11 +90,11 @@ def install_firmware(self, image_path): def update_firmware(self, image_path): """ - Updates firmware of the component. + Updates firmware of the component This API performs firmware update: it assumes firmware installation and loading in a single call. - In case platform componet requires some extra steps (apart from calling Low Level Utility) - to load the installed firmware (e.g, reboot, power cycle, etc.) - this will be done automatically by API. + In case platform component requires some extra steps (apart from calling Low Level Utility) + to load the installed firmware (e.g, reboot, power cycle, etc.) - this will be done automatically by API Args: image_path: A string, path to firmware image