From 54bdb179c0ea4f5bd9dc6a7233b8d3cc3b9b471a Mon Sep 17 00:00:00 2001 From: Wirut Getbamrung Date: Fri, 26 Apr 2019 10:54:27 +0700 Subject: [PATCH] [sonic_fw]: Add firmware management api base --- setup.py | 1 + sonic_fw/__init__.py | 0 sonic_fw/fw_manage_base.py | 63 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 sonic_fw/__init__.py create mode 100644 sonic_fw/fw_manage_base.py diff --git a/setup.py b/setup.py index 52b60b1d1..b55598ffd 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,7 @@ 'sonic_platform_base', 'sonic_psu', 'sonic_sfp', + 'sonic_fw' ], classifiers=[ 'Development Status :: 3 - Alpha', diff --git a/sonic_fw/__init__.py b/sonic_fw/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/sonic_fw/fw_manage_base.py b/sonic_fw/fw_manage_base.py new file mode 100644 index 000000000..4821fd785 --- /dev/null +++ b/sonic_fw/fw_manage_base.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# +# fw_manage_base.py +# +# Abstract base class for implementing platform-specific +# Firmware management functionality for SONiC +# + +try: + import abc +except ImportError as e: + raise ImportError(str(e) + " - required module not found") + + +class FwBase(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def get_module_list(self): + """ + Retrieves the list of module that available on the device + + :return: A list : the list of module that available on the device + """ + return [] + + @abc.abstractmethod + def get_fw_version(self, module_name): + """ + Retrieves the firmware version of module + + :param module_name: A string, module name + :return: A Dict, firmware version object + - Example of return object of module that doesn't have sub modules + { + "module_name": "BIOS", + "fw_version": "1.0.0" + "has_submodule" = False + } + - Example of return object of module that have sub modules + { + "module_name": "CPLD", + "fw_version": { + "CPLD1" : "1.0.0", + "CPLD2" : "1.1.0" + } + "has_submodule" = True + } + """ + return {} + + @abc.abstractmethod + def install(self, module_name, image_path): + """ + Install firmware to module + + :param module_name: A string, name of module that need to install new firmware + :param image_path: A string, path to firmware image + :return: Boolean, + - True if install process is finished without error + - False if install process is failed + """ + return False