Skip to content

Commit e0705e4

Browse files
committed
Use the macsec_enabled flag in platform to enable macesc feature state
1 parent 1f9c89a commit e0705e4

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
usemsi=1
22
dmasize=64M
3+
macsec_enabled=1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
usemsi=1
22
dmasize=512M
33
default_mtu=9100
4+
macsec_enabled=1

files/build_templates/init_cfg.json.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
{%- if include_p4rt == "y" %}{% do features.append(("p4rt", "enabled", false, "enabled")) %}{% endif %}
5353
{%- if include_restapi == "y" %}{% do features.append(("restapi", "enabled", false, "enabled")) %}{% endif %}
5454
{%- if include_sflow == "y" %}{% do features.append(("sflow", "disabled", false, "enabled")) %}{% endif %}
55-
{%- if include_macsec == "y" %}{% do features.append(("macsec", "disabled", false, "enabled")) %}{% endif %}
55+
{%- if include_macsec == "y" %}{% do features.append(("macsec", "{% if 'type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'SpineRouter' and MACSEC_SUPPORTED %}enabled{% else %}disabled{% endif %}", false, "enabled")) %}{% endif %}
5656
{%- if include_system_telemetry == "y" %}{% do features.append(("telemetry", "enabled", true, "enabled")) %}{% endif %}
5757
"FEATURE": {
5858
{# has_timer field if set, will start the feature systemd .timer unit instead of .service unit #}

src/sonic-py-common/sonic_py_common/device_info.py

+26
Original file line numberDiff line numberDiff line change
@@ -654,3 +654,29 @@ def is_fast_reboot_enabled():
654654
fb_system_state = stdout.rstrip('\n')
655655

656656
return fb_system_state
657+
658+
659+
# Check if this platform has macsec capability.
660+
def is_macsec_supported():
661+
supported = 0
662+
platform_env_conf_file_path = get_platform_env_conf_file_path()
663+
664+
# platform_env.conf file not present for platform
665+
if platform_env_conf_file_path is None:
666+
return supported
667+
668+
# Else open the file check for keyword - macsec_enabled -
669+
with open(platform_env_conf_file_path) as platform_env_conf_file:
670+
for line in platform_env_conf_file:
671+
tokens = line.split('=')
672+
if len(tokens) < 2:
673+
continue
674+
if tokens[0].lower() == 'macsec_enabled':
675+
supported = tokens[1].strip()
676+
break
677+
return int(supported)
678+
679+
680+
def get_macsec_support_metadata():
681+
macsec_support_metadata = {'MACSEC_SUPPORTED': True if is_macsec_supported() else False}
682+
return macsec_support_metadata

0 commit comments

Comments
 (0)