Jump to content

CCIE EI Section3 (Automation)


kat

Recommended Posts

Is this correct below?
 

import cli
import re

show_vrf = cli.execute('show vrf brief | inc ipv')
for each in show_vrf.splitlines():
 vrf_info = re.split('\s{2,}',each.strip())
 vrf_name = vrf_info[0]
 vrf_address_fam = vrf_info[2]
 if 'ipv4' in vrf_address_fam:
  print(cli.execute('show ip route vrf'+vrf_name))
 if 'ipv6' in vrf_address_fam:
  print(cli.execute('show ipv6 route vrf'+vrf_name))

Link to comment
Share on other sites

That script will not run properly a space is missing in the print statements:

11 hours ago, kat said:

if 'ipv4' in vrf_address_fam:
  print(cli.execute('show ip route vrf'+vrf_name))
 if 'ipv6' in vrf_address_fam:
  print(cli.execute('show ipv6 route vrf'+vrf_name))

Should be

if 'ipv4' in vrf_address_fam:
  print(cli.execute('show ip route vrf '+vrf_name))
 if 'ipv6' in vrf_address_fam:
  print(cli.execute('show ipv6 route vrf '+vrf_name))

If 3.2 did not change the wording should be fine to do it like this

Edited by jonny18
  • Like 1
Link to comment
Share on other sites

10 hours ago, jonny18 said:

That script will not run properly a space is missing in the print statements:

Should be

if 'ipv4' in vrf_address_fam:
  print(cli.execute('show ip route vrf '+vrf_name))
 if 'ipv6' in vrf_address_fam:
  print(cli.execute('show ipv6 route vrf '+vrf_name))

If 3.2 did not change the wording should be fine to do it like this

Thank you for answering.

The questions doesn't seem to change so the code should be fine

 

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...