Skip to content

How do I execute multiple show commands using Nornir + Netmiko #631

Answered by ktbyers
ktbyers asked this question in Q&A
Discussion options

You must be logged in to vote

I would probably make a custom Nornir task similar to this:

def netmiko_direct(task):

    list_of_commands = ["show ip int brief", "show ip arp"]
    # Manually create Netmiko connection
    net_connect = task.host.get_connection("netmiko", task.nornir.config)
    results_dict = {}
    for cmd in list_of_commands:
        output = net_connect.send_command(cmd)
        results_dict[cmd] = output

    # You also could make a more formal Nornir Results object
    return results_dict

Replies: 2 comments 2 replies

Comment options

ktbyers
Jan 6, 2021
Maintainer Author

You must be logged in to vote
2 replies
@AKG08
Comment options

@ktbyers
Comment options

ktbyers Jan 13, 2021
Maintainer Author

Answer selected by dbarrosop
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants