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

Initial MSD Support #249

Draft
wants to merge 75 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
a86f756
MSD sub-main changes
anramgop Nov 25, 2024
77532ee
MSD sub-main changes
anramgop Nov 25, 2024
d37cdc4
Added sub-main-common and service model validation
anramgop Nov 26, 2024
49dcb6d
Split validate and load functions
anramgop Nov 27, 2024
7ef9df8
Refactoring sub main common
anramgop Nov 27, 2024
0bd0e4f
MSD create role
anramgop Nov 27, 2024
075475e
Additional refactoring for MSD and VXLAN workflows
mikewiebe Dec 3, 2024
9a73ea9
updates for msd fabric templating
mtarking Dec 3, 2024
9fd9855
resolve conflicts
mtarking Dec 3, 2024
0a1b042
remove dup file
mtarking Dec 3, 2024
e413ba3
update create task for msd
mtarking Dec 3, 2024
a220edd
update create task for msd
mtarking Dec 3, 2024
87c8395
Add child fabrics logic
mikewiebe Dec 3, 2024
3b2ad70
Merge branch 'msd' of https://github.com/netascode/ansible-dc-vxlan i…
mikewiebe Dec 3, 2024
a1b5bbd
updated defaults
mtarking Dec 3, 2024
c81d63a
Merge branch 'msd' of github.com:netascode/ansible-dc-vxlan into msd
mtarking Dec 3, 2024
9070b83
Update prepare plugins
mikewiebe Dec 3, 2024
e7520ec
more work on msd & shift to overlay key from overlay_services but wit…
mtarking Dec 5, 2024
95730f2
Merge branch 'msd' of github.com:netascode/ansible-dc-vxlan into msd
mtarking Dec 5, 2024
58aca5a
Merge branch 'develop' into msd
mtarking Dec 5, 2024
f821779
updates for build and deployment of both single fabrics and msd fabrics
mtarking Dec 5, 2024
73abf69
chagnes from review with mike
mtarking Dec 5, 2024
becfbd5
update fabric name reference to use extended
mtarking Dec 5, 2024
b6cbb56
updats to msite templates
mtarking Dec 5, 2024
1e7af33
update to msd tempaltes and add conditional to only run child fabrics…
mtarking Dec 6, 2024
48019b0
first commit from hospital
mtarking Dec 9, 2024
15655e7
updates for remove child fabrics and isn
mtarking Dec 9, 2024
13c8ba6
updates to current msd workflow
mtarking Dec 11, 2024
88742d2
merge develop
mtarking Dec 11, 2024
1219609
update github templates
mtarking Dec 11, 2024
a33823f
fix pipeline errors
mtarking Dec 11, 2024
4eb8d41
fix pipeline errors
mtarking Dec 11, 2024
898fc20
fix deprecation error in pipeline
mtarking Dec 11, 2024
b0cb580
fix deprecation error in pipeline
mtarking Dec 11, 2024
58bb54a
fix deprecation error in pipeline
mtarking Dec 11, 2024
9ccf722
Fix prep_001 plugin for multisite
mikewiebe Dec 12, 2024
2e64830
Workflow fixes
mikewiebe Dec 13, 2024
597272d
Merge develop and cleanup
mikewiebe Dec 20, 2024
58dd0f0
Fix list defaults bug
mikewiebe Dec 20, 2024
e7ef318
Prepare plugin refactor
mikewiebe Dec 21, 2024
e7ee3ff
More refactoring
mikewiebe Dec 22, 2024
7c31491
Initialize shared dict vars
mikewiebe Dec 22, 2024
6293b98
refactored external network into new format
mthurstocisco Jan 8, 2025
cffab66
more refactoring for external fabrics
mthurstocisco Jan 9, 2025
e019b74
bug fix in sub_main_external in common
mthurstocisco Jan 9, 2025
c2a0c48
External plus refactoring
mikewiebe Jan 10, 2025
4ab1f16
ISN remove devices and bug fixes
mikewiebe Jan 13, 2025
fdaa9d0
Enable child fabric delete mode flag
mikewiebe Jan 14, 2025
e765809
Github actions fixes
mikewiebe Jan 14, 2025
cde1ce4
GitHub Actions Issues
mikewiebe Jan 14, 2025
c6e6d3b
More GitHub Actions Fixes
mikewiebe Jan 14, 2025
5382ce2
Deploy False for Fabrics
mikewiebe Jan 15, 2025
57b7636
Refactor for sharing code and simplification
mikewiebe Jan 16, 2025
7d7a39f
Refactoring and Multisite VRF and Network Removal Flag
mikewiebe Jan 16, 2025
2fdcaa9
Merge branch 'develop' into msd
mikewiebe Jan 16, 2025
459d305
Fix route control no data
mikewiebe Jan 25, 2025
553df9e
Fix github actions issue
mikewiebe Jan 25, 2025
d948485
Fix rule 401
mikewiebe Jan 25, 2025
573184e
update defaults for msite
mtarking Jan 28, 2025
b7c3f28
fix typo
mtarking Jan 28, 2025
3b0a958
fix defaults
mtarking Jan 28, 2025
a0d2a08
refactor template groupings for vpc and vrf loopback
mtarking Jan 28, 2025
650efef
fix to isn fabric template
mtarking Jan 28, 2025
3c9cc02
get fabric attributes, fix msd templates, & start work on mapping swi…
mtarking Jan 29, 2025
0ef58cd
fix errors
mtarking Jan 29, 2025
938458d
refactor msite build for preprocessing for vrfs/networks attachments
mtarking Jan 30, 2025
f89bb1b
fix lint errors
mtarking Jan 30, 2025
2cd93f0
add msd child fabric vrfs template & fix lint errors
mtarking Jan 30, 2025
5627f6b
fixes
mtarking Jan 30, 2025
cf01600
set msite prepare defaults
mtarking Jan 30, 2025
116a424
Merge branch 'develop' into msd
mtarking Feb 1, 2025
81156d2
updated existing rules to allow empty vrfs & add first msite rule
mtarking Feb 2, 2025
5aa7677
fix lint errors
mtarking Feb 2, 2025
e29c17e
add msite cross-ref rule
mtarking Feb 2, 2025
fd4c73c
fix typo
mtarking Feb 2, 2025
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
Prev Previous commit
Next Next commit
Refactor for sharing code and simplification
  • Loading branch information
mikewiebe committed Jan 16, 2025
commit 57b7636b01352a8d0eaf67ed5ae91fab758ced09
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def prepare(self):
model_data = self.kwargs['results']['model_extended']

# This plugin does not apply to the follwing fabric types
if model_data['vxlan']['fabric']['type'] in ['ISN', 'MSD', 'MCF']:
if model_data['vxlan']['fabric']['type'] in ['MSD', 'MCF']:
return self.kwargs['results']

# Loop over all the roles in vxlan.topology.switches.role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def prepare(self):
model_data = self.kwargs['results']['model_extended']

# We don't have switches for Multisite fabrics so need special handling
if model_data['vxlan']['fabric']['type'] in ('MSD', 'MCF', 'ISN'):
if model_data['vxlan']['fabric']['type'] in ('MSD', 'MCF'):
switches = []
else:
switches = model_data['vxlan']['topology']['switches']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def prepare(self):
model_data = self.kwargs['results']['model_extended']

# This plugin does not apply to the follwing fabric types
if model_data['vxlan']['fabric']['type'] in ['ISN', 'MSD', 'MCF']:
if model_data['vxlan']['fabric']['type'] in ['MSD', 'MCF']:
return self.kwargs['results']

model_data['vxlan']['topology']['interfaces'] = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def __init__(self, **kwargs):
def prepare(self):
model_data = self.kwargs['results']['model_extended']

if model_data['vxlan']['fabric']['type'] == 'ISN':
return self.kwargs['results']
# if model_data['vxlan']['fabric']['type'] == 'ISN':
# return self.kwargs['results']

# Check if vxlan.topology is defined
if model_data.get('vxlan').get('topology') is not None:
Expand Down
4 changes: 2 additions & 2 deletions plugins/action/dtc/get_poap_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def run(self, tmp=None, task_vars=None):
params = {}
params['model_data'] = self._task.args["model_data"]

if params['model_data']['vxlan']['fabric']['type'] == 'ISN':
return results
# if params['model_data']['vxlan']['fabric']['type'] == 'ISN':
# return results

params['action_plugin'] = self._execute_module
params['task_vars'] = task_vars
Expand Down
6 changes: 3 additions & 3 deletions plugins/action/dtc/update_switch_hostname_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def run(self, tmp=None, task_vars=None):
)

dm_switches = []
if model_data["vxlan"]["fabric"]["type"] in ('VXLAN_EVPN', 'External'):
if model_data["vxlan"]["fabric"]["type"] in ('VXLAN_EVPN', 'ISN', 'External'):
dm_switches = model_data["vxlan"]["topology"]["switches"]
elif model_data["vxlan"]["fabric"]["type"] in ('ISN'):
dm_switches = model_data["vxlan"]["multisite"]["isn"]["topology"]["switches"]
# elif model_data["vxlan"]["fabric"]["type"] in ('ISN'):
# dm_switches = model_data["vxlan"]["multisite"]["isn"]["topology"]["switches"]

switch_match = next((item for item in dm_switches if item["serial_number"] == switch_serial_number))

Expand Down
22 changes: 15 additions & 7 deletions plugins/plugin_utils/data_model_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@
model_keys['VXLAN_EVPN']['policy.groups'] = [root_key, 'policy', 'groups', 'LIST']
model_keys['VXLAN_EVPN']['policy.switches'] = [root_key, 'policy', 'switches', 'LIST']

# ISN KEYS

model_keys['ISN']['topology'] = [root_key, 'topology', 'KEY']
model_keys['ISN']['topology.edge_connections'] = [root_key, 'topology', 'edge_connections', 'LIST']
model_keys['ISN']['topology.fabric_links'] = [root_key, 'topology', 'fabric_links', 'LIST']
model_keys['ISN']['topology.switches'] = [root_key, 'topology', 'switches', 'LIST']
model_keys['ISN']['topology.switches.freeform'] = [root_key, 'topology', 'switches', 'freeform', 'LIST_INDEX']
model_keys['ISN']['topology.switches.interfaces'] = [root_key, 'topology', 'switches', 'interfaces', 'LIST_INDEX']
model_keys['ISN']['topology.vpc_peers'] = [root_key, 'topology', 'vpc_peers', 'LIST']
# ---
model_keys['ISN']['policy'] = [root_key, 'policy', 'KEY']
model_keys['ISN']['policy.policies'] = [root_key, 'policy', 'policies', 'LIST']
model_keys['ISN']['policy.groups'] = [root_key, 'policy', 'groups', 'LIST']
model_keys['ISN']['policy.switches'] = [root_key, 'policy', 'switches', 'LIST']

# MSD KEYS

# ---
Expand All @@ -77,10 +92,3 @@
model_keys['MSD']['multisite.overlay.networks'] = [root_key, 'multisite', 'overlay', 'networks', 'LIST']
model_keys['MSD']['multisite.overlay.network_attach_groups'] = [root_key, 'multisite', 'overlay', 'network_attach_groups', 'LIST']
model_keys['MSD']['multisite.overlay.network_attach_groups.switches'] = [root_key, 'multisite', 'overlay', 'network_attach_groups', 'switches', 'LIST_INDEX']

# ISN KEYS

# ---
model_keys['ISN']['multisite.isn'] = [root_key, 'multisite', 'isn', 'KEY']
model_keys['ISN']['multisite.isn.topology'] = [root_key, 'multisite', 'isn', 'topology', 'KEY']
model_keys['ISN']['multisite.isn.topology.switches'] = [root_key, 'multisite', 'isn', 'topology', 'switches', 'LIST']
77 changes: 77 additions & 0 deletions roles/dtc/common/tasks/common/ndfc_fabric.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# SPDX-License-Identifier: MIT

---

- name: Initialize changes_detected Var
ansible.builtin.set_fact:
changes_detected_fabric: false
delegate_to: localhost

- name: Set file_name Var
ansible.builtin.set_fact:
file_name: "ndfc_fabric.yml"
delegate_to: localhost

- name: Stat Previous File If It Exists
ansible.builtin.stat:
path: "{{ path_name }}{{ file_name }}"
register: data_file_previous
delegate_to: localhost
# TODO: Add capability to overridde path variable above for CI/CD pipeline

- name: Backup Previous Data File If It Exists
ansible.builtin.copy:
src: "{{ path_name }}{{ file_name }}"
dest: "{{ path_name }}{{ file_name }}.old"
when: data_file_previous.stat.exists

- name: Delete Previous Data File If It Exists
ansible.builtin.file:
state: absent
path: "{{ path_name }}{{ file_name }}"
delegate_to: localhost
when: data_file_previous.stat.exists

- name: Build Fabric Creation Parameters From Template
ansible.builtin.template:
src: ndfc_fabric.j2
dest: "{{ path_name }}{{ file_name }}"
delegate_to: localhost

- ansible.builtin.set_fact:
fabric_config: "{{ lookup('file', path_name + file_name) | from_yaml }}"
delegate_to: localhost

- name: Diff Previous and Current Data Files
cisco.nac_dc_vxlan.dtc.diff_model_changes:
file_name_previous: "{{ path_name }}{{ file_name }}.old"
file_name_current: "{{ path_name }}{{ file_name }}"
register: file_diff_result
delegate_to: localhost

- name: Set File Change Flag Based on File Diff Result
ansible.builtin.set_fact:
changes_detected_fabric: true
delegate_to: localhost
when:
- file_diff_result.file_data_changed
- check_roles['save_previous']
83 changes: 83 additions & 0 deletions roles/dtc/common/tasks/common/ndfc_fabric_links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# SPDX-License-Identifier: MIT

---

- name: Initialize changes_detected Var
ansible.builtin.set_fact:
changes_detected_fabric_links: false
delegate_to: localhost

- name: Set file_name Var
ansible.builtin.set_fact:
file_name: "ndfc_fabric_links.yml"
delegate_to: localhost

- name: Stat Previous File If It Exists
ansible.builtin.stat:
path: "{{ path_name }}{{ file_name }}"
register: data_file_previous
delegate_to: localhost

- name: Backup Previous Data File If It Exists
ansible.builtin.copy:
src: "{{ path_name }}{{ file_name }}"
dest: "{{ path_name }}{{ file_name }}.old"
when: data_file_previous.stat.exists

- name: Delete Previous Data File If It Exists
ansible.builtin.file:
state: absent
path: "{{ path_name }}{{ file_name }}"
delegate_to: localhost
when: data_file_previous.stat.exists

- name: Build Fabric Links
ansible.builtin.template:
src: ndfc_fabric_links.j2
dest: "{{ path_name }}{{ file_name }}"
delegate_to: localhost

- name: Set fabric_links Var default
ansible.builtin.set_fact:
fabric_links: []
delegate_to: localhost

- name: Set fabric_links Var
ansible.builtin.set_fact:
fabric_links: "{{ lookup('file', path_name + file_name) | from_yaml }}"
when: MD_Extended.vxlan.topology.fabric_links | length > 0
delegate_to: localhost

- name: Diff Previous and Current Data Files
cisco.nac_dc_vxlan.dtc.diff_model_changes:
file_name_previous: "{{ path_name }}{{ file_name }}.old"
file_name_current: "{{ path_name }}{{ file_name }}"
register: file_diff_result
delegate_to: localhost

- name: Set File Change Flag Based on File Diff Result
ansible.builtin.set_fact:
changes_detected_fabric_links: true
delegate_to: localhost
when:
- file_diff_result.file_data_changed
- check_roles['save_previous']
83 changes: 83 additions & 0 deletions roles/dtc/common/tasks/common/ndfc_interface_access.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# SPDX-License-Identifier: MIT

---

- name: Initialize changes_detected Var
ansible.builtin.set_fact:
changes_detected_interface_access: false
delegate_to: localhost

- name: Set file_name Var
ansible.builtin.set_fact:
file_name: "ndfc_interface_access.yml"
delegate_to: localhost

- name: Stat Previous File If It Exists
ansible.builtin.stat:
path: "{{ path_name }}{{ file_name }}"
register: data_file_previous
delegate_to: localhost

- name: Backup Previous Data File If It Exists
ansible.builtin.copy:
src: "{{ path_name }}{{ file_name }}"
dest: "{{ path_name }}{{ file_name }}.old"
when: data_file_previous.stat.exists

- name: Delete Previous Data File If It Exists
ansible.builtin.file:
state: absent
path: "{{ path_name }}{{ file_name }}"
delegate_to: localhost
when: data_file_previous.stat.exists

- name: Build Interface
ansible.builtin.template:
src: ndfc_interfaces/ndfc_interface_access.j2
dest: "{{ path_name }}{{ file_name }}"
delegate_to: localhost

- name: Set interface_access Var
ansible.builtin.set_fact:
interface_access: []
delegate_to: localhost

- name: Set interface_access Var
ansible.builtin.set_fact:
interface_access: "{{ lookup('file', path_name + file_name) | from_yaml }}"
when: MD_Extended.vxlan.topology.interfaces.modes.access.count > 0
delegate_to: localhost

- name: Diff Previous and Current Data Files
cisco.nac_dc_vxlan.dtc.diff_model_changes:
file_name_previous: "{{ path_name }}{{ file_name }}.old"
file_name_current: "{{ path_name }}{{ file_name }}"
register: file_diff_result
delegate_to: localhost

- name: Set File Change Flag Based on File Diff Result
ansible.builtin.set_fact:
changes_detected_interface_access: true
delegate_to: localhost
when:
- file_diff_result.file_data_changed
- check_roles['save_previous']
Loading
Loading