netdevops / hier_config

Hierarchical Configuration
MIT License
126 stars 24 forks source link

Ability to add pre and post processing of config #73

Open empi89 opened 4 years ago

empi89 commented 4 years ago

I am adding functionality for HPE Comware switches. However, as VLAN configuration mixes multiple vlans into the same configuration statement things are getting a bit complicated. I have written a pre/post processor for dealing with it. However from architectural standpoints this is a mess.

Could you please advise on a more generic approach to implement it?

See my request for comments branch on this: https://github.com/empi89/hier_config/tree/rfc-pre-and-postprocessing

aedwardstx commented 4 years ago

In my environment, I solve these types of issues with post running and compiled config load fixups. These fixups happen before the running and compiled config comparison to build remediation conifg. See the below example. I'm open to these sorts of fixups being part of the project.

running config

vlan 1-3,5

compiled config

vlan 1
  name ABCD
vlan 2,3,5

Would be normalized to the following in the running config:

vlan 1
vlan 2
vlan 3
vlan 5

And would be normalized to the following in the running config:

vlan 1
  name ABCD
vlan 2
vlan 3
vlan 5

Then, the resulting remediation config would reflect the appropriate changes:

vlan 1
  name ABCD
empi89 commented 4 years ago

Thanks for your feedback on this!

So you would like to have a more generic post-load processor integrated? I would say that this approach would also work for comware here and I can change the code in this way.

What would be your approach to integrate those post-load processors into the existing architecture?

empi89 commented 4 years ago

I have changed the branch a bit. Is this as you intended?

v0tti commented 2 years ago

I have similar issues with VLAN ranges. I think additionally to the Comware specific changes a generic approach would be helpful.

itdependsnetworks commented 2 years ago

This may be helpful to help manage vlan configurations https://netutils.readthedocs.io/en/latest/netutils/vlan/index.html