kat Posted December 20, 2022 Posted December 20, 2022 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))
jonny18 Posted December 20, 2022 Posted December 20, 2022 (edited) 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 December 20, 2022 by jonny18 1
kat Posted December 21, 2022 Author Posted December 21, 2022 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 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now