Refactor validate#796
Draft
ccoueffe wants to merge 7 commits into
Draft
Conversation
Move data loading and syntax validation outside the rules loop to avoid redundant schema parsing and YAML reloading on each iteration. Reduces validation time from ~98s to ~26s (3.8x speedup) on a 4-host fabric.
Signed-off-by: ccoueffe <ccoueffe@cisco.com>
Merge manage_model_files, mark stages, and model diff logic into nac_dc_validate.py action plugin. Role now runs as 2 Ansible tasks (plugin + meta:end_host) instead of 12+, saving ~1.5min per run. - Remove sub_main.yml, cleanup_model_files.yml, manage_model_files task files - Remove manage_model_files.py plugin (logic absorbed into nac_dc_validate) - main.yml now calls nac_dc_validate directly with tags
mtarking
requested changes
May 20, 2026
| # | ||
| # 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 | ||
| # this software and associated documentation files (the 'Software'), to deal in |
| # copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Comment on lines
+196
to
+210
| if fabric_type in ("VXLAN_EVPN",): | ||
| rules_list.append("{0}common".format(rules)) | ||
| rules_list.append("{0}ibgp_vxlan/".format(rules)) | ||
| rules_list.append("{0}common_vxlan".format(rules)) | ||
| elif fabric_type in ("eBGP_VXLAN",): | ||
| rules_list.append("{0}common".format(rules)) | ||
| rules_list.append("{0}ebgp_vxlan/".format(rules)) | ||
| rules_list.append("{0}common_vxlan".format(rules)) | ||
| elif fabric_type in ("MSD", "MCFG"): | ||
| rules_list.append("{0}multisite/".format(rules)) | ||
| elif fabric_type in ("ISN",): | ||
| rules_list.append("{0}isn/".format(rules)) | ||
| elif fabric_type in ("External",): | ||
| rules_list.append("{0}common".format(rules)) | ||
| rules_list.append("{0}external/".format(rules)) |
Collaborator
There was a problem hiding this comment.
Why the change from f-string to format?
Comment on lines
+241
to
+262
| rules_list.append("{0}common".format(rules)) | ||
| rules_list.append("{0}ibgp_vxlan/".format(rules)) | ||
| rules_list.append("{0}common_vxlan".format(rules)) | ||
| elif fabric_type in ("MSD", "MCFG"): | ||
| rules_list.append("{0}multisite/".format(rules)) | ||
| elif fabric_type in ("ISN",): | ||
| rules_list.append("{0}isn/".format(rules)) | ||
| elif fabric_type in ("External",): | ||
| rules_list.append("{0}common".format(rules)) | ||
| rules_list.append("{0}external/".format(rules)) | ||
| elif fabric_type in ("eBGP_VXLAN",): | ||
| results["failed"] = True | ||
| results["msg"] = ( | ||
| "Fabric type {0} requires using vxlan.fabric.type.".format( | ||
| fabric_type | ||
| ) | ||
| ) | ||
| else: | ||
| results['failed'] = True | ||
| results['msg'] = f"vxlan.fabric.type {results['data']['vxlan']['global']['fabric_type']} is not a supported fabric type." | ||
| results["failed"] = True | ||
| results["msg"] = ( | ||
| "vxlan.fabric.type {0} is not a supported fabric type.".format( | ||
| fabric_type |
Collaborator
There was a problem hiding this comment.
Why the change from f-string to format?
| results["msg"] = msg | ||
| return results | ||
|
|
||
| # Load and merge factory defaults with custom defaults from data model |
Collaborator
There was a problem hiding this comment.
Are we just grouping all things into this plugin now; defaults, prepare plugins, and run map?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue(s)
Related Collection Role
Related Data Model Element
Proposed Changes
Test Notes
Cisco Nexus Dashboard Version
Checklist