Netmiko: incomplete configuration

Created on 22 Dec 2019  路  4Comments  路  Source: ktbyers/netmiko

Hello Guys,

I am trying to run a script to push ignore-mtu-mismatch on l2vpn instances on a bunch of routers, but code get stuck in the middle of the process, below is my code, and debugs Netmiko Debug.txt. please advise if you have encountered such behavior.

with open('/home/ali/l2vpn_file.txt') as f:
    vrf_ip_combination = f.read().splitlines()
PE_dict = {}
for x in vrf_ip_combination:
    router_ip = x.split(',')[0]
    instance = x.split(',')[1]
    if (router_ip not in PE_dict):
        PE_dict[router_ip] = []
    PE_dict[router_ip].append(instance)
for host in PE_dict:
    print "=======================================\n connecting to device " + host+'\n======================================='  
    remote_devices = {
        'device_type': 'juniper_junos',
        'host': host,
        'username': 'ali',
        'password': 'ali123',
    }
    try:
        session = Netmiko(**remote_devices)
        commands=[]
        for vrf in PE_dict[host]: 
            output = session.send_command("show configuration routing-instances " + vrf + "| display set")
            output_split = output.splitlines()
            for x in output_split:
                if "site-identifier" in x:
                    sn = x.split()[-3]
                    commands.append("set routing-instances " + vrf + " protocols l2vpn site " + sn + " ignore-mtu-mismatch")
        session.config_mode('configure private')
        output = session.send_config_set(commands, exit_config_mode=False)
        print(output)
        output += session.commit(and_quit=True)

Most helpful comment

You are running v2.4.2?

The juniper device is having trouble keeping up with the send commands. You can try the following things:

  • Increase delay_factor session.send_config_set(commands, delay_factor=2, exit_config_mode=False) or a higher value.
  • Use load set terminal on the JunOS configuration prompt, send all the commands and send escape with sending Ctrl+d (session.write_channel( b'\x04')
  • Write your own loop sending every config line and wait for the prompt after each line (in the development branch this is already implemented in the send_config_set method.

All 4 comments

You are running v2.4.2?

The juniper device is having trouble keeping up with the send commands. You can try the following things:

  • Increase delay_factor session.send_config_set(commands, delay_factor=2, exit_config_mode=False) or a higher value.
  • Use load set terminal on the JunOS configuration prompt, send all the commands and send escape with sending Ctrl+d (session.write_channel( b'\x04')
  • Write your own loop sending every config line and wait for the prompt after each line (in the development branch this is already implemented in the send_config_set method.

As @daanvdsanden mentioned...I would re-test this against the Netmiko develop branch as we implemented a check on each line (so this out-of-sync problem due to you sending too fast should not happen).

@ktbyers @daanvdsanden Thanks Guys, I'll give it a try and update you. Thanks

Going to close this out. Feel free to reopen if there is any more info/issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bizzy211 picture Bizzy211  路  4Comments

aegiacometti picture aegiacometti  路  6Comments

MichalTaratuta picture MichalTaratuta  路  7Comments

akei9 picture akei9  路  7Comments

yixiuGit picture yixiuGit  路  4Comments