nautobot / nautobot-app-golden-config

Golden Configuration App for Nautobot.
https://docs.nautobot.com/projects/golden-config/en/latest/
Other
98 stars 56 forks source link

Allow utilization of `napalm_driver` field from Platform model to map to drivers #247

Closed timber-schroeder closed 1 year ago

timber-schroeder commented 2 years ago

Environment

Proposed Functionality

The Platform structure in Nautobot already contains a field called napalm_driver, which is designed to map to an individual OS automation driver, while the name of the platform model is not. For example, all of the platforms I use are simply the version numbers of the NOS in question, with the manufacturer and napalm_driver fields taking care of the NOS vendor and automation driver settings respectively. This is also how the model was originally documented to be used under Netbox.

In the immediate term this can be worked around by manually maintaining a large mapping list under platform_slug_map, however that isn't really ideal as you then have to update the Nautobot configuration every time you add a new platform.

Ideally, I would like to have a platform_napalm_driver_slug_map, which could optionally be used as an alternative to platform_slug_map, which would map the napalm_driver field instead of the Platform slug. Pulling arguments from something similar to the napalm_args field would also be nice however that would require a Platform model update to better support alternative drivers.

Use Case

Create two platforms, Junos 18.1R1 and Junos 18.1R2. Set both napalm_driver fields to 'junos'. Add "platform_napalm_driver_slug_map": {"junos": "juniper_junos"} to this plugin's configuration. The destination is arbitrary and continues to map to network_os entries as the existing platform_slug_map does.

itdependsnetworks commented 2 years ago

All the code for this has been centralized here: https://github.com/nautobot/nautobot-plugin-golden-config/blob/44430319795273bcc6572075209eb31174db806b/nautobot_golden_config/utilities/utils.py#L8-L12

I think I would prefer a generic function, similar to the pattern here: https://github.com/nautobot/nautobot-plugin-golden-config/blob/develop/docs/navigating-compliance-custom.md#configuration

This way one could do arbitrary mappings, such as using a custom field.

timber-schroeder commented 2 years ago

A custom function handler for this case would be great, and I would likely do exactly what you mentioned and put a custom field on platforms (nornir_driver or something like that).

jeffkala commented 1 year ago

Think this actually is solved in 1.6 of nautobot with the platform mapping functionality.

itdependsnetworks commented 1 year ago

In 2.0 we will move to a network_driver based solution.