Skip to content

Commit

Permalink
Feat(eos_designs): Add ptp_settings to replace ptp key in eos_des…
Browse files Browse the repository at this point in the history
…igns (#4155)

Co-authored-by: Laxmikant Chintakindi <[email protected]>
Co-authored-by: Claus Holbech <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
4 people committed Jul 25, 2024
1 parent 7da9898 commit 047e7ca
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ service routing protocols model multi-agent
!
hostname host1
!
ptp clock-identity 00:1C:73:1e:00:65
ptp priority1 30
ptp priority2 101
ptp domain 127
ptp mode boundary
ptp monitor threshold offset-from-master 250
ptp monitor threshold mean-path-delay 1500
ptp monitor sequence-id
ptp monitor threshold missing-message announce 3 sequence-ids
ptp monitor threshold missing-message delay-resp 3 sequence-ids
ptp monitor threshold missing-message follow-up 3 sequence-ids
ptp monitor threshold missing-message sync 3 sequence-ids
!
no enable password
no aaa root
!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ management_api_http:
enable_vrfs:
- name: MGMT
enable_https: true
ptp:
mode: boundary
clock_identity: 00:1C:73:1e:00:65
priority1: 30
priority2: 101
domain: 127
monitor:
enabled: true
threshold:
offset_from_master: 250
mean_path_delay: 1500
missing_message:
sequence_ids:
enabled: true
announce: 3
delay_resp: 3
follow_up: 3
sync: 3
loopback_interfaces:
- name: Loopback0
description: EVPN_Overlay_Peering
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
ptp:
enabled: true
auto_clock_identity: true
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
# Test that auto_clock_identify: false works on a global level:
ptp:
ptp_settings:
enabled: true
auto_clock_identity: false

# Test `ptp_settings` setting overrides `ptp` setting.
ptp:
enabled: false
auto_clock_identity: true
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ PTP must be specifically enabled:
- on the fabric level, for example FABRIC.yml

```yaml
ptp:
ptp_settings:
enabled: true
```
Expand Down Expand Up @@ -184,7 +184,7 @@ If you prefer to have PTP clock identity be the system MAC-address of the switch
- on the fabric level, for example FABRIC.yml

```yaml
ptp:
ptp_settings:
auto_clock_identity: < true | false | default -> true >
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ roles/eos_designs/docs/tables/platform-settings.md
See the [Configuring PTP](how-to/ptp.md) how-to for details.

--8<--
roles/eos_designs/docs/tables/ptp.md
roles/eos_designs/docs/tables/ptp_settings.md
--8<--

## Custom Structured Configuration
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions python-avd/pyavd/_eos_designs/schema/eos_designs.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55526,6 +55526,42 @@
],
"title": "PTP Profiles"
},
"ptp_settings": {
"type": "object",
"description": "Common PTP settings.\n`ptp_settings` replaces the old `ptp` key. `ptp_settings` takes precedence.",
"properties": {
"enabled": {
"type": "boolean",
"title": "Enabled"
},
"profile": {
"type": "string",
"enum": [
"aes67",
"smpte2059-2",
"aes67-r16-2016"
],
"default": "aes67-r16-2016",
"title": "Profile"
},
"domain": {
"type": "integer",
"minimum": 0,
"maximum": 255,
"title": "Domain"
},
"auto_clock_identity": {
"type": "boolean",
"default": true,
"title": "Auto Clock Identity"
}
},
"additionalProperties": false,
"patternProperties": {
"^_.+$": {}
},
"title": "PTP Settings"
},
"queue_monitor_length": {
"type": "object",
"properties": {
Expand Down
31 changes: 29 additions & 2 deletions python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3183,8 +3183,12 @@ keys:
'
ptp:
deprecation:
warning: true
new_key: ptp_settings
remove_in_version: v5.0.0
documentation_options:
table: ptp
table: ptp_settings
type: dict
keys:
enabled:
Expand All @@ -3204,7 +3208,7 @@ keys:
default: true
ptp_profiles:
documentation_options:
table: ptp
table: ptp_settings
type: list
items:
type: dict
Expand Down Expand Up @@ -3273,6 +3277,29 @@ keys:
sync_message:
interval: 0
transport: ipv4
ptp_settings:
documentation_options:
table: ptp_settings
type: dict
description: 'Common PTP settings.
`ptp_settings` replaces the old `ptp` key. `ptp_settings` takes precedence.'
keys:
enabled:
type: bool
profile:
type: str
valid_values:
- aes67
- smpte2059-2
- aes67-r16-2016
default: aes67-r16-2016
domain:
type: int
$ref: eos_cli_config_gen#/keys/ptp/keys/domain
auto_clock_identity:
type: bool
default: true
queue_monitor_length:
documentation_options:
table: system-settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
type: dict
keys:
ptp:
deprecation:
warning: true
new_key: 'ptp_settings'
remove_in_version: v5.0.0
documentation_options:
table: ptp
table: ptp_settings
type: dict
keys:
enabled:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type: dict
keys:
ptp_profiles:
documentation_options:
table: ptp
table: ptp_settings
type: list
items:
type: dict
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2023-2024 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
# yaml-language-server: $schema=../../../../plugins/plugin_utils/schema/avd_meta_schema.json
# Line above is used by RedHat's YAML Schema vscode extension
# Use Ctrl + Space to get suggestions for every field. Autocomplete will pop up after typing 2 letters.
type: dict
keys:
ptp_settings:
documentation_options:
table: ptp_settings
type: dict
# TODO AVD5.0: Update description to not mention ptp key.
description: |-
Common PTP settings.
`ptp_settings` replaces the old `ptp` key. `ptp_settings` takes precedence.
keys:
enabled:
type: bool
profile:
type: str
valid_values:
- "aes67"
- "smpte2059-2"
- "aes67-r16-2016"
default: "aes67-r16-2016"
domain:
type: int
$ref: "eos_cli_config_gen#/keys/ptp/keys/domain"
auto_clock_identity:
type: bool
default: true
6 changes: 3 additions & 3 deletions python-avd/pyavd/_eos_designs/shared_utils/ptp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from functools import cached_property
from typing import TYPE_CHECKING

from ..._utils import get, get_item
from ..._utils import default, get, get_item

if TYPE_CHECKING:
from . import SharedUtils
Expand Down Expand Up @@ -54,7 +54,7 @@ class PtpMixin:

@cached_property
def ptp_enabled(self: SharedUtils) -> bool:
default_ptp_enabled = get(self.hostvars, "ptp.enabled")
default_ptp_enabled = default(get(self.hostvars, "ptp_settings.enabled"), get(self.hostvars, "ptp.enabled"))
return get(self.switch_data_combined, "ptp.enabled", default=default_ptp_enabled) is True

@cached_property
Expand All @@ -63,7 +63,7 @@ def ptp_mlag(self: SharedUtils) -> bool:

@cached_property
def ptp_profile_name(self: SharedUtils) -> str:
default_ptp_profile = get(self.hostvars, "ptp.profile", default="aes67-r16-2016")
default_ptp_profile = default(get(self.hostvars, "ptp_settings.profile"), get(self.hostvars, "ptp.profile"), "aes67-r16-2016")
return get(self.switch_data_combined, "ptp.profile", default_ptp_profile)

@cached_property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from functools import cached_property

from ...._errors import AristaAvdMissingVariableError
from ...._utils import get, strip_null_from_data
from ...._utils import default, get, strip_null_from_data
from ....j2filters import convert_dicts, natural_sort
from ...avdfacts import AvdFacts
from .ntp import NtpMixin
Expand Down Expand Up @@ -660,11 +660,11 @@ def ptp(self) -> dict | None:
if not self.shared_utils.ptp_enabled:
# Since we have overlapping data model "ptp" between eos_designs and eos_cli_config_gen,
# we need to overwrite the input dict if set but not enabled.
# TODO: AVD5.0.0 Remove this handling since the `ptp` key is removed from eos_designs.
if get(self._hostvars, "ptp") is not None:
return {}
return None

default_ptp_domain = get(self._hostvars, "ptp.domain", default=127)
default_ptp_domain = default(get(self._hostvars, "ptp_settings.domain"), get(self._hostvars, "ptp.domain"), 127)
default_ptp_priority1 = get(self.shared_utils.node_type_key_data, "default_ptp_priority1", default=127)
default_clock_identity = None

Expand All @@ -675,8 +675,7 @@ def ptp(self) -> dict | None:
raise AristaAvdMissingVariableError(f"'id' must be set on '{self.shared_utils.hostname}' to set ptp priority2")

priority2 = self.shared_utils.id % 256

default_auto_clock_identity = get(self._hostvars, "ptp.auto_clock_identity", default=True)
default_auto_clock_identity = default(get(self._hostvars, "ptp_settings.auto_clock_identity"), get(self._hostvars, "ptp.auto_clock_identity"), True)
if get(self.shared_utils.switch_data_combined, "ptp.auto_clock_identity", default=default_auto_clock_identity) is True:
clock_identity_prefix = get(self.shared_utils.switch_data_combined, "ptp.clock_identity_prefix", default="00:1C:73")
default_clock_identity = f"{clock_identity_prefix}:{priority1:02x}:00:{priority2:02x}"
Expand Down

0 comments on commit 047e7ca

Please sign in to comment.