Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[component] add auto_update_firmware() to support the auto update. #106

Merged
merged 8 commits into from
Jan 26, 2021
25 changes: 25 additions & 0 deletions sonic_platform_base/component_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,28 @@ def update_firmware(self, image_path):
RuntimeError: update failed
"""
raise NotImplementedError

def auto_update_firmware(self, image_path, boot_action):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sujinmkang since this API is a part of SONiC firmware upgrade framework, please provide the description on which boot types are supported

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sujinmkang suggest renaming: boot_action -> boot_type

"""
Updates firmware of the component

This API performs firmware update automatically based on boot_action: it assumes firmware installation
and/or creating a loading task during a boot action, 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image_path : can it be mentioned that the firmware_image be a self extracting binary..

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got clarification from HLD.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API will have any return values? Please mention if required.

boot_action: A string, boot action following the upgrade

Returns:
Output: A string, status and info
status: True or False, firmware auto-update status
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sujinmkang suggest to use status codes:

status_installed=1
status_updated=2
status_scheduled=3

Copy link
Contributor Author

@sujinmkang sujinmkang Nov 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nazariig
the original idea was for status to indicate the auto-update performed status which means performed successfully or not. For info, it gives more detail how the update has been performed. And platform vendor can return any information for the failure that is why the info was open.
Instead of having two outputs for the api, we can define the return_code as below based on your input . do you have any other failure cause to be added?

return_code

status_installed = 1
stauts_updated = 2
status_scheduled = 3
status_error_boottype = -1
status_error_image = -2
status_error_others = -3

info: The detail information of the firmware auto-update status.
"updated"/"installed"(which needs a reboot for the firmware to be active)/"scheduled"

Raises:
RuntimeError: auto-update failure cause
"""
raise NotImplementedError