Skip to content

Refactor validate#796

Draft
ccoueffe wants to merge 7 commits into
netascode:refactor_collectionfrom
ccoueffe:refactor_validate
Draft

Refactor validate#796
ccoueffe wants to merge 7 commits into
netascode:refactor_collectionfrom
ccoueffe:refactor_validate

Conversation

@ccoueffe

Copy link
Copy Markdown
Collaborator

Related Issue(s)

Related Collection Role

  • cisco.nac_dc_vxlan.validate
  • cisco.nac_dc_vxlan.dtc.create
  • cisco.nac_dc_vxlan.dtc.deploy
  • cisco.nac_dc_vxlan.dtc.remove
  • other

Related Data Model Element

  • vxlan.fabric
  • vxlan.global
  • vxlan.topology
  • vxlan.underlay
  • vxlan.overlay
  • vxlan.overlay_extensions
  • vxlan.policy
  • vxlan.multisite
  • defaults.vxlan
  • other

Proposed Changes

Test Notes

Cisco Nexus Dashboard Version

Checklist

  • Latest commit is rebased from develop with merge conflicts resolved
  • New or updates to documentation has been made accordingly
  • Assigned the proper reviewers

ccoueffe added 4 commits May 12, 2026 13:56
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
Comment thread plugins/action/common/merge_defaults.py Outdated
#
# 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert

Comment thread plugins/action/common/merge_defaults.py Outdated
# 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert

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))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change from f-string to format?

results["msg"] = msg
return results

# Load and merge factory defaults with custom defaults from data model

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we just grouping all things into this plugin now; defaults, prepare plugins, and run map?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants