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

Common power consumption and supply APIs for modular chassis #136

Merged
merged 3 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sonic_platform_base/chassis_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ def get_my_slot(self):
"""
return NotImplementedError

def is_modular_chassis(self):
"""
Retrieves whether the sonic instance is part of modular chassis

Returns:
A bool value, should return False by default or for fixed-platforms.
Should return True for supervisor-cards, line-cards etc running as part
of modular-chassis.
"""
return False

##############################################
# Component methods
##############################################
Expand Down
6 changes: 6 additions & 0 deletions sonic_platform_base/device_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ class DeviceBase(object):
peripheral device
"""

# Possible status LED colors
STATUS_LED_COLOR_GREEN = "green"
STATUS_LED_COLOR_AMBER = "amber"
STATUS_LED_COLOR_RED = "red"
STATUS_LED_COLOR_OFF = "off"

def get_name(self):
"""
Retrieves the name of the device
Expand Down
10 changes: 10 additions & 0 deletions sonic_platform_base/fan_drawer_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,13 @@ def get_status_led(self, color):
A string, one of the predefined STATUS_LED_COLOR_* strings above
"""
raise NotImplementedError

def get_maximum_consumed_power(self):
"""
Retrives the maximum power drawn by Fan Drawer

Returns:
A float, with value of the maximum consumable power of the
component.
"""
raise NotImplementedError
10 changes: 10 additions & 0 deletions sonic_platform_base/module_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ def set_admin_state(self, up):
"""
raise NotImplementedError

def get_maximum_consumed_power(self):
"""
Retrives the maximum power drawn by this module

Returns:
A float, with value of the maximum consumable power of the
module.
"""
raise NotImplementedError

##############################################
# Component methods
##############################################
Expand Down
41 changes: 35 additions & 6 deletions sonic_platform_base/psu_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ class PsuBase(device_base.DeviceBase):
# Device type definition. Note, this is a constant.
DEVICE_TYPE = "psu"

# Possible fan status LED colors
STATUS_LED_COLOR_GREEN = "green"
STATUS_LED_COLOR_AMBER = "amber"
STATUS_LED_COLOR_RED = "red"
STATUS_LED_COLOR_OFF = "off"

# List of FanBase-derived objects representing all fans
# available on the PSU
_fan_list = None
Expand All @@ -32,6 +26,9 @@ class PsuBase(device_base.DeviceBase):
# PSU class
_thermal_list = []

# Status of Master LED
psu_master_led_color = device_base.DeviceBase.STATUS_LED_COLOR_OFF

def __init__(self):
self._fan_list = []

Expand Down Expand Up @@ -219,3 +216,35 @@ def get_voltage_low_threshold(self):
e.g. 12.1
"""
raise NotImplementedError

def get_maximum_supplied_power(self):
"""
Retrieves the maximum supplied power by PSU

Returns:
A float number, the maximum power output in Watts.
e.g. 1200.1
"""
raise NotImplementedError

@classmethod
def get_status_master_led(cls):
"""
Gets the state of the Master status LED for a given device-type

Returns:
A string, one of the predefined STATUS_LED_COLOR_* strings.
"""
return cls.psu_master_led_color

@classmethod
def set_status_master_led(cls, color):
"""
Gets the state of the Master status LED for a given device-type

Returns:
bool: True if status LED state is set successfully, False if
not
"""
cls.psu_master_led_color = color
return True