Skip to content
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

Refactor(eos_designs): Optimize conversion of structured config outputs #3240

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
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;short_esi</samp>](## "<connected_endpoints_keys.key>.[].adapters.[].ethernet_segment.short_esi") | String | Required | | | In format xxxx:xxxx:xxxx or "auto".<br>Define a manual short-esi (be careful using this on profiles) or set the value to "auto" to automatically generate the value.<br>Please see the notes under "EVPN A/A ESI dual and single-attached endpoint scenarios" before setting `short_esi: auto`.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redundancy</samp>](## "<connected_endpoints_keys.key>.[].adapters.[].ethernet_segment.redundancy") | String | | | Valid Values:<br>- <code>all-active</code><br>- <code>single-active</code> | If omitted, Port-Channels use the EOS default of all-active.<br>If omitted, Ethernet interfaces are configured as single-active.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;designated_forwarder_algorithm</samp>](## "<connected_endpoints_keys.key>.[].adapters.[].ethernet_segment.designated_forwarder_algorithm") | String | | | Valid Values:<br>- <code>auto</code><br>- <code>modulus</code><br>- <code>preference</code> | Configure DF algorithm and preferences.<br>- auto: Use preference-based algorithm and assign preference based on position of device in the 'switches' list,<br> e.g., assuming a list of three switches, this would assign a preference of 200 to the first switch, 100 to the 2nd, and 0 to the third.<br>- preference: Set preference for each switch manually using designated_forwarder_preferences key.<br>- modulus: Use the default modulus-based algorithm.<br>If omitted, Port-Channels use the EOS default of modulus.<br>If omitted, Ethernet interfaces default to the 'auto' mechanism detailed above.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;designated_forwarder_preferences</samp>](## "<connected_endpoints_keys.key>.[].adapters.[].ethernet_segment.designated_forwarder_preferences") | List, items: String | | | | Manual preference as described above, required only for preference algorithm. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "<connected_endpoints_keys.key>.[].adapters.[].ethernet_segment.designated_forwarder_preferences.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;designated_forwarder_preferences</samp>](## "<connected_endpoints_keys.key>.[].adapters.[].ethernet_segment.designated_forwarder_preferences") | List, items: Integer | | | | Manual preference as described above, required only for preference algorithm. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;int&gt;</samp>](## "<connected_endpoints_keys.key>.[].adapters.[].ethernet_segment.designated_forwarder_preferences.[]") | Integer | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dont_preempt</samp>](## "<connected_endpoints_keys.key>.[].adapters.[].ethernet_segment.dont_preempt") | Boolean | | | | Disable preemption for single-active forwarding when auto/manual DF preference is configured. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;port_channel</samp>](## "<connected_endpoints_keys.key>.[].adapters.[].port_channel") | Dictionary | | | | Used for port-channel adapter. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mode</samp>](## "<connected_endpoints_keys.key>.[].adapters.[].port_channel.mode") | String | | | Valid Values:<br>- <code>active</code><br>- <code>passive</code><br>- <code>on</code> | Port-Channel Mode. |
Expand Down Expand Up @@ -434,7 +434,7 @@

# Manual preference as described above, required only for preference algorithm.
designated_forwarder_preferences:
- <str>
- <int>

# Disable preemption for single-active forwarding when auto/manual DF preference is configured.
dont_preempt: <bool>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;short_esi</samp>](## "network_ports.[].ethernet_segment.short_esi") | String | Required | | | In format xxxx:xxxx:xxxx or "auto".<br>Define a manual short-esi (be careful using this on profiles) or set the value to "auto" to automatically generate the value.<br>Please see the notes under "EVPN A/A ESI dual and single-attached endpoint scenarios" before setting `short_esi: auto`.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redundancy</samp>](## "network_ports.[].ethernet_segment.redundancy") | String | | | Valid Values:<br>- <code>all-active</code><br>- <code>single-active</code> | If omitted, Port-Channels use the EOS default of all-active.<br>If omitted, Ethernet interfaces are configured as single-active.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;designated_forwarder_algorithm</samp>](## "network_ports.[].ethernet_segment.designated_forwarder_algorithm") | String | | | Valid Values:<br>- <code>auto</code><br>- <code>modulus</code><br>- <code>preference</code> | Configure DF algorithm and preferences.<br>- auto: Use preference-based algorithm and assign preference based on position of device in the 'switches' list,<br> e.g., assuming a list of three switches, this would assign a preference of 200 to the first switch, 100 to the 2nd, and 0 to the third.<br>- preference: Set preference for each switch manually using designated_forwarder_preferences key.<br>- modulus: Use the default modulus-based algorithm.<br>If omitted, Port-Channels use the EOS default of modulus.<br>If omitted, Ethernet interfaces default to the 'auto' mechanism detailed above.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;designated_forwarder_preferences</samp>](## "network_ports.[].ethernet_segment.designated_forwarder_preferences") | List, items: String | | | | Manual preference as described above, required only for preference algorithm. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "network_ports.[].ethernet_segment.designated_forwarder_preferences.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;designated_forwarder_preferences</samp>](## "network_ports.[].ethernet_segment.designated_forwarder_preferences") | List, items: Integer | | | | Manual preference as described above, required only for preference algorithm. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;int&gt;</samp>](## "network_ports.[].ethernet_segment.designated_forwarder_preferences.[]") | Integer | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dont_preempt</samp>](## "network_ports.[].ethernet_segment.dont_preempt") | Boolean | | | | Disable preemption for single-active forwarding when auto/manual DF preference is configured. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;port_channel</samp>](## "network_ports.[].port_channel") | Dictionary | | | | Used for port-channel adapter. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mode</samp>](## "network_ports.[].port_channel.mode") | String | | | Valid Values:<br>- <code>active</code><br>- <code>passive</code><br>- <code>on</code> | Port-Channel Mode. |
Expand Down Expand Up @@ -406,7 +406,7 @@

# Manual preference as described above, required only for preference algorithm.
designated_forwarder_preferences:
- <str>
- <int>

# Disable preemption for single-active forwarding when auto/manual DF preference is configured.
dont_preempt: <bool>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;short_esi</samp>](## "port_profiles.[].ethernet_segment.short_esi") | String | Required | | | In format xxxx:xxxx:xxxx or "auto".<br>Define a manual short-esi (be careful using this on profiles) or set the value to "auto" to automatically generate the value.<br>Please see the notes under "EVPN A/A ESI dual and single-attached endpoint scenarios" before setting `short_esi: auto`.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redundancy</samp>](## "port_profiles.[].ethernet_segment.redundancy") | String | | | Valid Values:<br>- <code>all-active</code><br>- <code>single-active</code> | If omitted, Port-Channels use the EOS default of all-active.<br>If omitted, Ethernet interfaces are configured as single-active.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;designated_forwarder_algorithm</samp>](## "port_profiles.[].ethernet_segment.designated_forwarder_algorithm") | String | | | Valid Values:<br>- <code>auto</code><br>- <code>modulus</code><br>- <code>preference</code> | Configure DF algorithm and preferences.<br>- auto: Use preference-based algorithm and assign preference based on position of device in the 'switches' list,<br> e.g., assuming a list of three switches, this would assign a preference of 200 to the first switch, 100 to the 2nd, and 0 to the third.<br>- preference: Set preference for each switch manually using designated_forwarder_preferences key.<br>- modulus: Use the default modulus-based algorithm.<br>If omitted, Port-Channels use the EOS default of modulus.<br>If omitted, Ethernet interfaces default to the 'auto' mechanism detailed above.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;designated_forwarder_preferences</samp>](## "port_profiles.[].ethernet_segment.designated_forwarder_preferences") | List, items: String | | | | Manual preference as described above, required only for preference algorithm. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "port_profiles.[].ethernet_segment.designated_forwarder_preferences.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;designated_forwarder_preferences</samp>](## "port_profiles.[].ethernet_segment.designated_forwarder_preferences") | List, items: Integer | | | | Manual preference as described above, required only for preference algorithm. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;int&gt;</samp>](## "port_profiles.[].ethernet_segment.designated_forwarder_preferences.[]") | Integer | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dont_preempt</samp>](## "port_profiles.[].ethernet_segment.dont_preempt") | Boolean | | | | Disable preemption for single-active forwarding when auto/manual DF preference is configured. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;port_channel</samp>](## "port_profiles.[].port_channel") | Dictionary | | | | Used for port-channel adapter. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mode</samp>](## "port_profiles.[].port_channel.mode") | String | | | Valid Values:<br>- <code>active</code><br>- <code>passive</code><br>- <code>on</code> | Port-Channel Mode. |
Expand Down Expand Up @@ -392,7 +392,7 @@

# Manual preference as described above, required only for preference algorithm.
designated_forwarder_preferences:
- <str>
- <int>

# Disable preemption for single-active forwarding when auto/manual DF preference is configured.
dont_preempt: <bool>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def spanning_tree(self) -> dict | None:

if spanning_tree_mode is not None:
spanning_tree["mode"] = spanning_tree_mode
priority = get(self.shared_utils.switch_data_combined, "spanning_tree_priority", default="32768")
priority = get(self.shared_utils.switch_data_combined, "spanning_tree_priority", default=32768)
if spanning_tree_mode == "mstp":
spanning_tree["mst_instances"] = [{"id": "0", "priority": priority}]
elif spanning_tree_mode == "rapid-pvst":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ def get_structured_config(
if not isinstance(results, list):
results = [results]

for result in results:
output_schema_tools.convert_data(result)

# All lists will be merged with "append" except for custom structured configuration where
# the default list merge is "append_rp" and can be overridden.
# TODO: Each dict entry can contain a list_merge key, which will be picked up by the merge function for all underlying lists.
if issubclass(cls, AvdStructuredConfigCustomStructuredConfiguration):
list_merge = get(module_vars, "custom_structured_configuration_list_merge", default="append_rp")

# Only for structured config run conversion on the data in since we still have some structured config inputs without full schema validation.
for result in results:
output_schema_tools.convert_data(result)

else:
list_merge = "append"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def _trunk_groups_mlag_l3_name(self):
return get(self.shared_utils.trunk_groups, "mlag_l3.name", required=True)

@cached_property
def spanning_tree(self):
def spanning_tree(self) -> dict:
vlans = [self.shared_utils.mlag_peer_vlan]
if self.shared_utils.mlag_peer_l3_vlan is not None:
vlans = [self.shared_utils.mlag_peer_vlan, self.shared_utils.mlag_peer_l3_vlan]
return {"no_spanning_tree_vlan": list_compress(vlans)}
vlans.append(self.shared_utils.mlag_peer_l3_vlan)

return {"no_spanning_tree_vlan": self.shared_utils.mlag_peer_vlan}
return {"no_spanning_tree_vlan": list_compress(vlans)}

@cached_property
def vlans(self) -> list:
Expand Down Expand Up @@ -216,8 +216,8 @@ def mlag_configuration(self):
"local_interface": f"Vlan{self.shared_utils.mlag_peer_vlan}",
"peer_address": self.shared_utils.mlag_peer_ip,
"peer_link": f"Port-Channel{self.shared_utils.mlag_port_channel_id}",
"reload_delay_mlag": get(self.shared_utils.platform_settings, "reload_delay.mlag"),
"reload_delay_non_mlag": get(self.shared_utils.platform_settings, "reload_delay.non_mlag"),
"reload_delay_mlag": str(get(self.shared_utils.platform_settings, "reload_delay.mlag")),
"reload_delay_non_mlag": str(get(self.shared_utils.platform_settings, "reload_delay.non_mlag")),
}
if (
get(self.shared_utils.switch_data_combined, "mlag_dual_primary_detection", default=False) is True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def patch_panel(self) -> dict | None:
"enabled": True,
"connectors": [
{
"id": 1,
"id": "1",
"type": "interface",
"endpoint": f"{interface}.{subif['number']}",
},
Expand All @@ -61,7 +61,7 @@ def patch_panel(self) -> dict | None:
if point_to_point_service.get("type") == "vpws-pseudowire":
patch["connectors"].append(
{
"id": 2,
"id": "2",
"type": "pseudowire",
"endpoint": f"bgp vpws {tenant['name']} pseudowire {point_to_point_service['name']}_{subif['number']}",
}
Expand All @@ -79,7 +79,7 @@ def patch_panel(self) -> dict | None:
"enabled": True,
"connectors": [
{
"id": 1,
"id": "1",
"type": "interface",
"endpoint": f"{interface}",
}
Expand All @@ -88,7 +88,7 @@ def patch_panel(self) -> dict | None:
if point_to_point_service.get("type") == "vpws-pseudowire":
patch["connectors"].append(
{
"id": 2,
"id": "2",
"type": "pseudowire",
"endpoint": f"bgp vpws {tenant['name']} pseudowire {point_to_point_service['name']}",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5191,7 +5191,7 @@
"type": "array",
"description": "Manual preference as described above, required only for preference algorithm.",
"items": {
"type": "string"
"type": "integer"
},
"title": "Designated Forwarder Preferences"
},
Expand Down Expand Up @@ -10999,7 +10999,7 @@
"type": "array",
"description": "Manual preference as described above, required only for preference algorithm.",
"items": {
"type": "string"
"type": "integer"
},
"title": "Designated Forwarder Preferences"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3461,9 +3461,9 @@ $defs:
description: Manual preference as described above, required only for preference
algorithm.
items:
type: str
type: int
convert_types:
- int
- str
dont_preempt:
type: bool
description: Disable preemption for single-active forwarding when auto/manual
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ $defs:
type: list
description: Manual preference as described above, required only for preference algorithm.
items:
type: str
type: int
convert_types:
- int
- str
dont_preempt:
type: bool
description: Disable preemption for single-active forwarding when auto/manual DF preference is configured.
Expand Down