From 6ad0004c29a143a0635ad7f3c81ce652313569cb Mon Sep 17 00:00:00 2001 From: Sujin Kang Date: Tue, 26 Jan 2021 13:27:47 -0800 Subject: [PATCH] [component] add auto_update_firmware() to support the auto update. (#106) To support the component firmware automatic update, add auto_update_firmware() to platform component api This is to support fwutil auto_update command to update the platform component firmware automatically. Fwutil HLD to support auto_update interfaces/commands. Azure/SONiC#648 --- sonic_platform_base/component_base.py | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sonic_platform_base/component_base.py b/sonic_platform_base/component_base.py index 37e767aa0bab..ba9c975caac4 100644 --- a/sonic_platform_base/component_base.py +++ b/sonic_platform_base/component_base.py @@ -103,3 +103,35 @@ def update_firmware(self, image_path): RuntimeError: update failed """ raise NotImplementedError + + def auto_update_firmware(self, image_path, boot_type): + """ + Updates firmware of the component + + This API performs firmware update automatically based on boot_type: it assumes firmware installation + and/or creating a loading task during the reboot, if needed, in a single call. + 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 during the reboot. + The loading task will be created by API. + + Args: + image_path: A string, path to firmware image + boot_type: A string, reboot type following the upgrade + - none/fast/warm/cold + + Returns: + Output: A return code + return_code: An integer number, status of component firmware auto-update + - return code of a positive number indicates successful auto-update + - status_installed = 1 + - status_updated = 2 + - status_scheduled = 3 + - return_code of a negative number indicates failed auto-update + - status_err_boot_type = -1 + - status_err_image = -2 + - status_err_unknown = -3 + + Raises: + RuntimeError: auto-update failure cause + """ + raise NotImplementedError