Skip to content
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
4 changes: 4 additions & 0 deletions osism/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def read_secret(secret_name):
SONIC_EXPORT_SUFFIX = os.getenv("SONIC_EXPORT_SUFFIX", "_config_db.json")
SONIC_EXPORT_IDENTIFIER = os.getenv("SONIC_EXPORT_IDENTIFIER", "serial-number")

# Directory holding the per-HWSKU port_config .ini files (bundled in the
# repo under files/sonic/port_config and installed by the Dockerfile)
SONIC_PORT_CONFIG_PATH = os.getenv("SONIC_PORT_CONFIG_PATH", "/etc/sonic/port_config")

# SONiC ZTP firmware configuration
#
# The ZTP firmware install uses a dynamic-url built from
Expand Down
4 changes: 3 additions & 1 deletion osism/tasks/conductor/sonic/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

"""Constants and mappings for SONiC configuration."""

from osism import settings

# Tag to add AF L2VPN EVPN to BGP neighbor
BGP_AF_L2VPN_EVPN_TAG = "bgp-af-l2vpn-evpn"

Expand Down Expand Up @@ -87,7 +89,7 @@
}

# Path to SONiC port configuration files
PORT_CONFIG_PATH = "/etc/sonic/port_config"
PORT_CONFIG_PATH = settings.SONIC_PORT_CONFIG_PATH

# List of supported vendors
SUPPORTED_VENDORS = [
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/tasks/conductor/sonic/test_constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# SPDX-License-Identifier: Apache-2.0

import importlib

import pytest

from osism import settings as settings_module
from osism.tasks.conductor.sonic import constants as constants_module
from osism.tasks.conductor.sonic.constants import (
BGP_AF_L2VPN_EVPN_TAG,
DEFAULT_LOCAL_AS_PREFIX,
Expand Down Expand Up @@ -151,3 +155,19 @@ def test_supported_hwskus_entry_invariants(hwsku):
assert "-" in hwsku
vendor = hwsku.split("-")[0]
assert vendor in SUPPORTED_VENDORS


# ---------------------------------------------------------------------------
# PORT_CONFIG_PATH settings wiring
# ---------------------------------------------------------------------------


def test_port_config_path_follows_settings():
original = settings_module.SONIC_PORT_CONFIG_PATH
try:
settings_module.SONIC_PORT_CONFIG_PATH = "/custom/port_config"
reloaded = importlib.reload(constants_module)
assert reloaded.PORT_CONFIG_PATH == "/custom/port_config"
finally:
settings_module.SONIC_PORT_CONFIG_PATH = original
importlib.reload(constants_module)
14 changes: 14 additions & 0 deletions tests/unit/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,20 @@ def test_sonic_export_identifier_override(reload_settings, monkeypatch):
assert settings_module.SONIC_EXPORT_IDENTIFIER == "asset-tag"


def test_sonic_port_config_path_default(reload_settings, monkeypatch):
monkeypatch.delenv("SONIC_PORT_CONFIG_PATH", raising=False)
reload_settings()

assert settings_module.SONIC_PORT_CONFIG_PATH == "/etc/sonic/port_config"


def test_sonic_port_config_path_override(reload_settings, monkeypatch):
monkeypatch.setenv("SONIC_PORT_CONFIG_PATH", "/tmp/port_config")
reload_settings()

assert settings_module.SONIC_PORT_CONFIG_PATH == "/tmp/port_config"


# ---------------------------------------------------------------------------
# NETBOX_SECONDARIES
# ---------------------------------------------------------------------------
Expand Down