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)
You are running v2.4.2?
The juniper device is having trouble keeping up with the send commands. You can try the following things:
session.send_config_set(commands, delay_factor=2, exit_config_mode=False) or a higher value.load set terminal on the JunOS configuration prompt, send all the commands and send escape with sending Ctrl+d (session.write_channel( b'\x04')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.
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:
session.send_config_set(commands, delay_factor=2, exit_config_mode=False)or a higher value.load set terminalon the JunOS configuration prompt, send all the commands and send escape with sending Ctrl+d (session.write_channel( b'\x04')send_config_setmethod.