Skip to content

Commit

Permalink
Merge pull request #357 from SUNET/feature.fabric_metric_setting
Browse files Browse the repository at this point in the history
Allow specifying custom metric value for fabric interfaces etc
  • Loading branch information
indy-independence authored Jul 1, 2024
2 parents 4f4e2a0 + fe282d6 commit 24f9cda
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/reporef/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ Keys for interfaces.yml or interfaces_<model>.yml:
* acl_ipv4_out: Access control list to apply for egress IPv4 traffic from interface. Optional.
* acl_ipv6_in: Access control list to apply for ingress IPv6 traffic to interface. Optional.
* acl_ipv6_out: Access control list to apply for egress IPv6 traffic from interface. Optional.
* metric: Optional integer specifying metric for this interface.
* cli_append_str: Optional. Custom configuration to append to this interface.

The "downlink" ifclass is used on DIST devices to specify that this interface
Expand All @@ -434,6 +435,11 @@ Contains base system settings like:

* host: IP address or hostname of NTP server

- radius_servers: List of

* host: IP address or hostname of RADIUS server
* port: Port number. Optional

- snmp_servers: List of

* host: IP address or hostname of SNMP trap target
Expand Down
1 change: 1 addition & 0 deletions src/cnaas_nms/db/settings_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class f_interface(BaseModel):
acl_ipv4_out: Optional[str] = None
acl_ipv6_in: Optional[str] = None
acl_ipv6_out: Optional[str] = None
metric: Optional[int] = None
cli_append_str: str = ""

@field_validator("ipv4_address")
Expand Down
8 changes: 6 additions & 2 deletions src/cnaas_nms/devicehandler/sync_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def populate_device_vars(
ifindexnum: int = 0
if "ifclass" not in intf:
continue
extra_keys = ["aggregate_id", "enabled", "cli_append_str"]
extra_keys = ["aggregate_id", "enabled", "cli_append_str", "metric", "mtu", "tags"]
if intf["ifclass"] == "downlink":
data = {}
if intf["name"] in ifname_peer_map:
Expand All @@ -299,8 +299,12 @@ def populate_device_vars(
)
elif intf["ifclass"] == "fabric":
if intf["name"] in fabric_interfaces:
if_dict = {}
for extra_key_name in extra_keys:
if extra_key_name in intf:
if_dict[extra_key_name] = intf[extra_key_name]
fabric_device_variables["interfaces"].append(
{**fabric_interfaces[intf["name"]], **{"indexnum": ifindexnum}}
{**fabric_interfaces[intf["name"]], **{"indexnum": ifindexnum}, **if_dict}
)
del fabric_interfaces[intf["name"]]
else:
Expand Down

0 comments on commit 24f9cda

Please sign in to comment.