nautobot / nornir-nautobot

Nornir inventory and plugins for Nautobot.
https://docs.nautobot.com/projects/nornir-nautobot/en/latest/
33 stars 25 forks source link

GC platform_slug_map with nornir-nautobot dispatcher mapping can lead to issues #80

Open jeffkala opened 1 year ago

jeffkala commented 1 year ago

Seems like some interop with using platform_slug_map from golden config and overloading a platform from that map in the dispatcher.

GC user has platform map of:

        "platform_slug_map": {"junos": "juniper_junos"},

And dispatcher point to netmiko juniper_junos

        "dispatcher_mapping": {
            "juniper_junos": "nornir_nautobot.plugins.tasks.dispatcher.juniper_junos.NautobotNornirDriver"
        }

Issue:

with dispatcher_mapping set to juniper_junos getting:

Unable to find the driver for check_connectivity for platform: junos

if setting the dispatcher_mapping to junos getting:

                                      ^
syntax error, expecting <command>.

While debugging this is because its pulling back command to run based on default key which is show run.

Workaround is to update:

https://github.com/nautobot/nornir-nautobot/blob/bb977910f9e711fe2190a71d61b641f277e73b80/nornir_nautobot/plugins/tasks/dispatcher/default.py#LL29C1-L37C2

and in this case add a junos key.

itdependsnetworks commented 1 year ago

Perhaps we should move this as a class attribute, so:

https://github.com/nautobot/nornir-nautobot/blob/bb977910f9e711fe2190a71d61b641f277e73b80/nornir_nautobot/plugins/tasks/dispatcher/juniper_junos.py#L6

Would become

class NautobotNornirDriver(DefaultNautobotNornirDriver):
    """Collection of Nornir Tasks specific to Juniper Junos devices."""
    run_command = 'show configuration | display set'

and then update

    @staticmethod
    def get_config(task: Task, logger, obj, backup_file: str, remove_lines: list, substitute_lines: list) -> Result:
        """
        logger.log_debug(f"Executing get_config for {task.host.name} on {task.host.platform}")
        command = self.run_command

This would allow us to address issues we are seeing in ruckus as well.

jvanderaa commented 1 year ago

Makes sense if I'm picking up what is being stated right.