Skip to content

Commit

Permalink
Common power consumption and supply APIs for modular chassis (sonic-n…
Browse files Browse the repository at this point in the history
…et#136)

sonic-platform-base: Changes to introduce APIs for modular chassis for power-consumption and supplied

HLD: sonic-net/SONiC#646

PSUd APIs for power requirement calculations

get_maximum_supplied_power() - per PSU
get_status_master_led() - get master psu led status. Class method.
set_status_master_led() - set master psu led status. Class method.

get_maximum_consumed_power(self) - per consumer API. Consumers are modules, Fans
  • Loading branch information
mprabhu-nokia authored Nov 12, 2020
1 parent b37f156 commit 8813b1d
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 6 deletions.
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

0 comments on commit 8813b1d

Please sign in to comment.