From 6b6eadaa2346160deedd8e4f0f7cbf9cfd77c049 Mon Sep 17 00:00:00 2001 From: Fuzail Khan Date: Thu, 12 Sep 2019 03:57:09 -0700 Subject: [PATCH 1/3] Platform Driver Development Framework (PDDF): 1) Changes to psu base class (1.0 APIs) to support PDDF CLI utils, 2) Adding fan_base class to support PDDF fan CLI utils (comments incorporated) --- setup.py | 1 + sonic_fan/__init__.py | 0 sonic_fan/fan_base.py | 84 +++++++++++++++++++++++++++++++++++++++++++ sonic_psu/psu_base.py | 72 +++++++++++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+) create mode 100644 sonic_fan/__init__.py create mode 100644 sonic_fan/fan_base.py diff --git a/setup.py b/setup.py index d5cf5cf5d..c640c959d 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ 'sonic_platform_base.sonic_eeprom', 'sonic_platform_base.sonic_sfp', 'sonic_psu', + 'sonic_fan', 'sonic_sfp', ], classifiers=[ diff --git a/sonic_fan/__init__.py b/sonic_fan/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/sonic_fan/fan_base.py b/sonic_fan/fan_base.py new file mode 100644 index 000000000..1ea8836b7 --- /dev/null +++ b/sonic_fan/fan_base.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python +# +# fan_base.py +# +# Base class for implementing platform-specific +# FAN control functionality for SONiC +# + +try: + import abc +except ImportError as e: + raise ImportError (str(e) + " - required module not found") + +class FanBase(object): + __metaclass__ = abc.ABCMeta + + def get_num_fans(self): + """ + Retrieves the number of FANs supported on the device + + :return: An integer, the number of FANs supported on the device + """ + return 0 + + def get_status(self, index): + """ + Retrieves the operational status of FAN defined + by index 1-based + + :param index: An integer, 1-based index of the PSU of which to query status + :return: Boolean, + - True if FAN is running with some speed + - False if FAN has stopped running + """ + return False + + def get_presence(self, index): + """ + Retrieves the presence status of a FAN defined + by 1-based index + + :param index: An integer, 1-based index of the FAN of which to query status + :return: Boolean, True if FAN is plugged, False if not + """ + return False + + def get_direction(self, index): + """ + Retrieves the airflow direction of a FAN defined + by 1-based index + + :param index: An integer, 1-based index of the FAN of which to query status + :return: string, denoting FAN airflow direction + """ + return "" + + def get_speed(self, index): + """ + Retrieves the speed of a Front FAN in the tray in revolutions per minute defined + by 1-based index + + :param index: An integer, 1-based index of the FAN of which to query speed + :return: integer, denoting front FAN speed + """ + return 0 + + def get_speed_rear(self, index): + """ + Retrieves the speed of a rear FAN in the tray in revolutions per minute defined + by 1-based index + + :param index: An integer, 1-based index of the FAN of which to query speed + :return: integer, denoting rear FAN speed + """ + return 0 + + def set_speed(self, val): + """ + Sets the speed of all the FANs to a value denoted by the duty-cycle percentage val + + :param val: An integer, <0-100> denoting FAN duty cycle percentage + :return: Boolean, True if operation is successful, False if not + """ + return False diff --git a/sonic_psu/psu_base.py b/sonic_psu/psu_base.py index 2e2204298..cf1c06376 100644 --- a/sonic_psu/psu_base.py +++ b/sonic_psu/psu_base.py @@ -47,3 +47,75 @@ def get_psu_presence(self, index): """ return False + def get_model(self, idx): + """ + Retrieves the model number/name of a power supply unit (PSU) defined + by 1-based index + :param idx: An integer, 1-based index of the PSU of which to query model number + :return: String, denoting model number/name + """ + return "" + + def get_mfr_id(self, idx): + """ + Retrieves the manufacturing id of a power supply unit (PSU) defined + by 1-based index + :param idx: An integer, 1-based index of the PSU of which to query mfr id + :return: String, denoting manufacturing id + """ + return "" + + def get_serial(self, idx): + """ + Retrieves the serial number of a power supply unit (PSU) defined + by 1-based index + :param idx: An integer, 1-based index of the PSU of which to query serial number + :return: String, denoting serial number of the PSU unit + """ + return "" + + def get_direction(self, idx): + """ + Retrieves the airflow direction of a power supply unit (PSU) defined + by 1-based index + :param idx: An integer, 1-based index of the PSU of which to query airflow direction + :return: String, denoting the airflow direction + """ + return "" + + def get_output_voltage(self, idx): + """ + Retrieves the ouput volatage in milli volts of a power supply unit (PSU) defined + by 1-based index + :param idx: An integer, 1-based index of the PSU of which to query o/p volatge + :return: An integer, value of o/p voltage in mV if PSU is good, else zero + """ + return 0 + + def get_output_current(self, idx): + """ + Retrieves the output current in milli amperes of a power supply unit (PSU) defined + by 1-based index + :param idx: An integer, 1-based index of the PSU of which to query o/p current + :return: An integer, value of o/p current in mA if PSU is good, else zero + """ + return 0 + + def get_output_power(self, idx): + """ + Retrieves the output power in micro watts of a power supply unit (PSU) defined + by 1-based index + :param idx: An integer, 1-based index of the PSU of which to query o/p power + :return: An integer, value of o/p power in micro Watts if PSU is good, else zero + """ + return 0 + + def get_fan_rpm(self, idx, fan_idx): + """ + Retrieves the speed of fan, in rpm, denoted by 1-based of a power + supply unit (PSU) defined by 1-based index + :param idx: An integer, 1-based index of the PSU of which to query fan speed + :param fan_idx: An integer, 1-based index of the PSU-fan of which to query speed + :return: An integer, value of PSU-fan speed in rpm if PSU-fan is good, else zero + """ + return 0 From 824881f7802fa5e8a7beb4c8e4103a4a8c8ed00f Mon Sep 17 00:00:00 2001 From: Fuzail Khan Date: Mon, 16 Sep 2019 22:20:08 -0700 Subject: [PATCH 2/3] Changes as per the feedback --- sonic_psu/psu_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonic_psu/psu_base.py b/sonic_psu/psu_base.py index cf1c06376..ee21d35ee 100644 --- a/sonic_psu/psu_base.py +++ b/sonic_psu/psu_base.py @@ -110,7 +110,7 @@ def get_output_power(self, idx): """ return 0 - def get_fan_rpm(self, idx, fan_idx): + def get_fan_speed(self, idx, fan_idx): """ Retrieves the speed of fan, in rpm, denoted by 1-based of a power supply unit (PSU) defined by 1-based index From ee585461a8b61cc691fdc3ac8060eeac3fa81529 Mon Sep 17 00:00:00 2001 From: Fuzail Khan Date: Wed, 18 Sep 2019 21:09:47 -0700 Subject: [PATCH 3/3] Improving the comments section of get_spee_rear() API --- sonic_fan/fan_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonic_fan/fan_base.py b/sonic_fan/fan_base.py index 1ea8836b7..6643bfa0c 100644 --- a/sonic_fan/fan_base.py +++ b/sonic_fan/fan_base.py @@ -66,8 +66,8 @@ def get_speed(self, index): def get_speed_rear(self, index): """ - Retrieves the speed of a rear FAN in the tray in revolutions per minute defined - by 1-based index + Retrieves the speed of a rear FAN in the tray (applicable only for 2-fan tray) + in revolutions per minute defined by 1-based index :param index: An integer, 1-based index of the FAN of which to query speed :return: integer, denoting rear FAN speed