-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[docker-platform-monitor]: Add LED control daemon and plugin for x86_64-arista_7050_qx32 platform #691
Merged
Merged
[docker-platform-monitor]: Add LED control daemon and plugin for x86_64-arista_7050_qx32 platform #691
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e47366c
Add files for building ledd package; add ledd to docker-platform-moni…
jleveque 47f1839
Add sonic-platform-daemons submodule
jleveque b27fb75
Rename ledd.mk -> sonic-ledd.mk
jleveque ba7ac7b
Add led_control.py plugin for x86_64-arista_7050_qx32 platform
jleveque f40b26e
Rename Dockerfile -> Dockerfile.j2
jleveque 49b4e28
Fix build
jleveque 107f478
Remove blank line
jleveque File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
device/arista/x86_64-arista_7050_qx32/plugins/led_control.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env python | ||
# | ||
# led_control.py | ||
# | ||
# Platform-specific LED control functionality for SONiC | ||
# | ||
|
||
try: | ||
from sonic_led.led_control_base import LedControlBase | ||
except ImportError, e: | ||
raise ImportError (str(e) + " - required module not found") | ||
|
||
|
||
class LedControl(LedControlBase): | ||
"""Platform specific LED control class""" | ||
|
||
SONIC_PORT_NAME_PREFIX = "Ethernet" | ||
|
||
LED_SYSFS_PATH_BREAKOUT_CAPABLE = "/sys/class/leds/qsfp{0}_{1}/brightness" | ||
LED_SYSFS_PATH_NO_BREAKOUT = "/sys/class/leds/qsfp{0}/brightness" | ||
|
||
QSFP_BREAKOUT_START_IDX = 1 | ||
QSFP_BREAKOUT_END_IDX = 24 | ||
QSFP_NO_BREAKOUT_START_IDX = 25 | ||
QSFP_NO_BREAKOUT_END_IDX = 32 | ||
|
||
LED_COLOR_OFF = 0 | ||
LED_COLOR_GREEN = 1 | ||
LED_COLOR_YELLOW = 2 | ||
|
||
# Helper method to map SONiC port name to Arista QSFP index | ||
def _port_name_to_qsfp_index(self, port_name): | ||
# Strip "Ethernet" off port name | ||
if not port_name.startswith(self.SONIC_PORT_NAME_PREFIX): | ||
return -1 | ||
|
||
sonic_port_num = int(port_name[len(self.SONIC_PORT_NAME_PREFIX):]) | ||
|
||
# SONiC port nums are 0-based and increment by 4 | ||
# Arista QSFP indices are 1-based and increment by 1 | ||
return ((sonic_port_num/4) + 1) | ||
|
||
# Concrete implementation of port_link_state_change() method | ||
def port_link_state_change(self, port, state): | ||
qsfp_index = self._port_name_to_qsfp_index(port) | ||
|
||
# Ignore invalid QSFP indices | ||
if qsfp_index <= 0: | ||
return | ||
|
||
# QSFP indices 1-24 are breakout-capable and have four LEDs, | ||
# whereas indices 25-32 are not breakout-capable, and only have one | ||
if qsfp_index <= self.QSFP_BREAKOUT_END_IDX: | ||
led_sysfs_path = self.LED_SYSFS_PATH_BREAKOUT_CAPABLE.format(qsfp_index, 1) | ||
else: | ||
led_sysfs_path = self.LED_SYSFS_PATH_NO_BREAKOUT.format(qsfp_index) | ||
|
||
led_file = open(led_sysfs_path, "w") | ||
|
||
if state == "up": | ||
led_file.write("%d" % self.LED_COLOR_GREEN) | ||
else: | ||
led_file.write("%d" % self.LED_COLOR_OFF) | ||
|
||
led_file.close() | ||
|
||
# Constructor | ||
def __init__(self): | ||
# Initialize: Turn all front panel QSFP LEDs off | ||
for qsfp_index in range(self.QSFP_BREAKOUT_START_IDX, self.QSFP_BREAKOUT_END_IDX + 1): | ||
for lane in range(1, 5): | ||
led_sysfs_path = self.LED_SYSFS_PATH_BREAKOUT_CAPABLE.format(qsfp_index, lane) | ||
with open(led_sysfs_path, 'w') as led_file: | ||
led_file.write("%d" % self.LED_COLOR_OFF) | ||
|
||
for qsfp_index in range(self.QSFP_NO_BREAKOUT_START_IDX, self.QSFP_NO_BREAKOUT_END_IDX + 1): | ||
led_sysfs_path = self.LED_SYSFS_PATH_NO_BREAKOUT.format(qsfp_index) | ||
with open(led_sysfs_path, 'w') as led_file: | ||
led_file.write("%d" % self.LED_COLOR_OFF) | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
FROM docker-config-engine | ||
|
||
# Make apt-get non-interactive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Update apt's package index files | ||
RUN apt-get update | ||
|
||
RUN apt-get install -y python-pip sensord | ||
|
||
{% if docker_platform_monitor_debs.strip() %} | ||
# Copy built Debian packages | ||
COPY \ | ||
{% for deb in docker_platform_monitor_debs.split(' ') -%} | ||
debs/{{ deb }}{{' '}} | ||
{%- endfor -%} | ||
debs/ | ||
{%- endif %} | ||
|
||
{% if docker_platform_monitor_debs.strip() %} | ||
# Install built Debian packages | ||
RUN dpkg -i \ | ||
{% for deb in docker_platform_monitor_debs.split(' ') -%} | ||
debs/{{ deb }}{{' '}} | ||
{%- endfor %} | ||
{%- endif %} | ||
|
||
{% if docker_platform_monitor_whls.strip() %} | ||
# Copy built Python wheels | ||
COPY \ | ||
{% for whl in docker_platform_monitor_whls.split(' ') -%} | ||
python-wheels/{{ whl }}{{' '}} | ||
{%- endfor -%} | ||
python-wheels/ | ||
{%- endif %} | ||
|
||
{% if docker_platform_monitor_whls.strip() %} | ||
# Install built Python wheels | ||
RUN pip install \ | ||
{% for whl in docker_platform_monitor_whls.split(' ') -%} | ||
python-wheels/{{ whl }}{{' '}} | ||
{%- endfor %} | ||
{%- endif %} | ||
|
||
COPY python-wheels /python-wheels | ||
|
||
# Install Python SwSS SDK (dependency of sonic-ledd) | ||
RUN pip install /python-wheels/swsssdk-2.0.1-py2-none-any.whl | ||
|
||
# Clean up | ||
RUN apt-get remove -y python-pip | ||
RUN apt-get clean -y | ||
RUN apt-get autoclean -y | ||
RUN apt-get autoremove -y | ||
RUN rm -rf /debs /python-wheels ~/.cache | ||
|
||
COPY ["start.sh", "lm-sensors.sh", "/usr/bin/"] | ||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] | ||
|
||
ENTRYPOINT ["/usr/bin/supervisord"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# sonic-ledd (SONiC Front-panel LED control daemon) Debian package | ||
|
||
SONIC_LEDD = python-sonic-ledd_1.0-1_all.deb | ||
$(SONIC_LEDD)_SRC_PATH = $(SRC_PATH)/sonic-platform-daemons/sonic-ledd | ||
SONIC_PYTHON_STDEB_DEBS += $(SONIC_LEDD) |
Submodule sonic-platform-daemons
added at
bd7c31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
later, once we have break out. this needs to handle the break out lanes.