Skip to content
Closed
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
@@ -1,4 +1,4 @@
{# Auto-generated NDFC DC VXLAN EVPN VRFs config data structure for fabric {{ vxlan.fabric.name }} #}
{# Auto-generated NDFC DC VXLAN EVPN Networks config data structure for fabric {{ vxlan.fabric.name }} #}
{% set networks = [] %}
{% if data_model_extended.vxlan.overlay.networks is defined and data_model_extended.vxlan.overlay.networks %}
{% set networks = data_model_extended.vxlan.overlay.networks %}
Expand Down Expand Up @@ -65,6 +65,15 @@
{% endif %}
{% for attach in network_attach_groups_dict[net['network_attach_group']] %}
- ip_address: {{ attach['mgmt_ip_address'] }}
{% if attach['networks'] is defined %}
{% for attached_net in attach['networks'] %}
{% if attached_net['name'] == net['name'] %}
{% if ndfc_version | cisco.nac_dc_vxlan.version_compare('12.4.1', '>=') %}
svi_enabled: {{ attached_net['svi_enabled'] | default(defaults.vxlan.overlay.network_attach_groups.svi_enabled) }}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% if attach['ports'] is defined %}
ports: {{ attach['ports'] }}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@
{% endif %}
{% for attach in network_attach_groups_dict[net['network_attach_group']] %}
- ip_address: {{ attach['mgmt_ip_address'] }}
{% if attach['networks'] is defined %}
{% for attached_net in attach['networks'] %}
{% if attached_net['name'] == net['name'] %}
{% if ndfc_version | cisco.nac_dc_vxlan.version_compare('12.4.1', '>=') %}
svi_enabled: {{ attached_net['svi_enabled'] | default(defaults.vxlan.overlay.network_attach_groups.svi_enabled) }}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% if attach['ports'] is defined %}
ports: {{ attach['ports'] }}
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions roles/validate/files/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ factory_defaults:
switches: []
network_attach_groups:
switches: []
svi_enabled: true
policy:
template_name: switch_freeform
priority: 500
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def match(cls, data_model):
if sm_networks and network_attach_groups:
results = cls.cross_reference_switches(network_attach_groups, switches, 'network', results)
results = cls.cross_reference_vpc_peers(network_attach_groups, vpc_peers, 'network', results)
results = cls.cross_reference_attached_networks(network_attach_groups, sm_networks, 'network', results)

return results

Expand Down Expand Up @@ -179,3 +180,34 @@ def cross_reference_vpc_peers(cls, attach_groups, vpc_peers, target, results):
)

return results

@classmethod
def cross_reference_attached_networks(cls, network_attach_groups, networks, target, results):
"""
Check if each network defined under the network_attach_group exists.
"""

if not network_attach_groups:
return results

for attach_group in network_attach_groups:
group_name = attach_group.get('name')
group_switches = attach_group.get('switches', [])
networks_name = [net['name'] for net in networks]

for switch in group_switches:
hostname = switch.get('hostname')
attached_networks = switch.get('networks')

if attached_networks:
for network in attached_networks:
attached_network_name = network.get('name')
if attached_network_name not in networks_name:
results.append(
f"{target}_attach_group '{group_name}' contains switch '{hostname}' "
f"which defines a network '{attached_network_name}', but the network "
f"is not defined in the service model. Add the Network to the service "
f"model and re-run the playbook."
)

return results
Loading