-
Notifications
You must be signed in to change notification settings - Fork 179
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
Platform Driver Development Framework (PDDF): 1) Changes to psu base class (1.0 APIs) to support PDD PSU CLI utils 2) Adding fan_base class to support PDDF fan CLI utils #57
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env python | ||
# | ||
# fan_base.py | ||
# | ||
# Abstract 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 | ||
|
||
@abc.abstractmethod | ||
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 | ||
|
||
@abc.abstractmethod | ||
def get_status(self, index): | ||
""" | ||
Retrieves the operational status of FAN defined | ||
by index 1-based <index> | ||
|
||
: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 | ||
|
||
@abc.abstractmethod | ||
def get_presence(self, index): | ||
""" | ||
Retrieves the presence status of a FAN defined | ||
by 1-based index <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 | ||
|
||
@abc.abstractmethod | ||
def get_direction(self, index): | ||
""" | ||
Retrieves the airflow direction of a FAN defined | ||
by 1-based index <index> | ||
|
||
:param index: An integer, 1-based index of the FAN of which to query status | ||
:return: string, denoting FAN airflow direction | ||
""" | ||
return "" | ||
|
||
@abc.abstractmethod | ||
def get_speed(self, index): | ||
""" | ||
Retrieves the speed of a Front FAN in the tray in revolutions per minute defined | ||
by 1-based index <index> | ||
|
||
:param index: An integer, 1-based index of the FAN of which to query speed | ||
:return: integer, denoting front FAN speed | ||
""" | ||
return 0 | ||
|
||
@abc.abstractmethod | ||
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 <index> | ||
|
||
:param index: An integer, 1-based index of the FAN of which to query speed | ||
:return: integer, denoting rear FAN speed | ||
""" | ||
return 0 | ||
|
||
@abc.abstractmethod | ||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,75 @@ def get_psu_presence(self, index): | |
""" | ||
return False | ||
|
||
def get_model(self, idx): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you may align the method defied in new platform API, if eventually you still want to go with new plugins. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to align method names as far as possible, but the methods need index of the PSU. |
||
""" | ||
Retrieves the model number/name of a power supply unit (PSU) defined | ||
by 1-based index <idx> | ||
: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 <idx> | ||
: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 <idx> | ||
: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 <idx> | ||
: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 <idx> | ||
: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 <idx> | ||
: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 <idx> | ||
: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 <fan_idx> of a power | ||
supply unit (PSU) defined by 1-based index <idx> | ||
: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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove the "abstractmethod" restriction? understood that you are following the convention in other plugin base classes. But with this restriction, it requests all the vendors to implement these functions or at least write some stub functions if they don't want to implement them, otherwise, it will fail when loading the plugins on the vendor's platform. We are in the progress to replace plugins with new platform API, so it's highly possible that some vendors don't want to implement these new plugins, so please consider this.
And I suggest you think about using new platform API instead of adding new plugins, eventually we will use new platform API, put efforts on adding new plugins is kind of waste in my view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. We will remove @AbstractMethod restriction.
We plan to move to 2.0 APIs eventually. However, we needed this change for short term to support the CLIs in some of our platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @keboliu -- plugins have been deprecated in favor of the new object-oriented platform 2.0 API. Developing new plugins seems unnecessary as they should no longer be used by platform developers.