From c06b37a44055330328ba79d890d33c4e87536b00 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 6 Oct 2017 14:28:19 -0700 Subject: [PATCH] Add sonic_psu module along with initial psu_base.py base class for plugins (#116) --- setup.py | 2 +- sonic_psu/__init__.py | 0 sonic_psu/psu_base.py | 26 ++++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 sonic_psu/__init__.py create mode 100644 sonic_psu/psu_base.py diff --git a/setup.py b/setup.py index c4ee75816e57..37b1f8d7d619 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ url='https://github.com/Azure/sonic-utilities', maintainer='Joe LeVeque', maintainer_email='jolevequ@microsoft.com', - packages=['config', 'sfputil', 'show', 'sonic_eeprom', 'sonic_sfp', "sonic_installer"], + packages=['config', 'sfputil', 'show', 'sonic_eeprom', 'sonic_installer', 'sonic_psu', 'sonic_sfp'], package_data={ 'show': ['aliases.ini'] }, diff --git a/sonic_psu/__init__.py b/sonic_psu/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sonic_psu/psu_base.py b/sonic_psu/psu_base.py new file mode 100644 index 000000000000..b20e6af2723f --- /dev/null +++ b/sonic_psu/psu_base.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# +# psu_base.py +# +# Abstract base class for implementing platform-specific +# PSU control functionality for SONiC +# + +try: + import abc +except ImportError, e: + raise ImportError (str(e) + " - required module not found") + +class PsuBase(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def get_psu_status(self, index): + """ + Retrieves the oprational status of power supply unit (PSU) defined + by index + + :param index: An integer, index of the PSU of which to query status + :return: Boolean, True if PSU is operating properly, False if PSU is faulty + """ + return False