@@ -52,12 +52,18 @@ def get_mpls_label_strgs(label_list):
5252 label_str_2_return += "/" + label_string
5353 return label_str_2_return
5454
55- def get_nexthop_info_str (nxhp_info ):
55+ def get_nexthop_info_str (nxhp_info , filterByIp ):
5656 str_2_return = ""
5757 if "ip" in nxhp_info :
58- str_2_return = " via {}," .format (nxhp_info ['ip' ])
58+ if filterByIp :
59+ str_2_return = " * {}" .format (nxhp_info ['ip' ])
60+ else :
61+ str_2_return = " via {}," .format (nxhp_info ['ip' ])
5962 if "interfaceName" in nxhp_info :
60- str_2_return += " {}," .format (nxhp_info ['interfaceName' ])
63+ if filterByIp :
64+ str_2_return += ", via {}" .format (nxhp_info ['interfaceName' ])
65+ else :
66+ str_2_return += " {}," .format (nxhp_info ['interfaceName' ])
6167 elif "directlyConnected" in nxhp_info :
6268 str_2_return = " is directly connected,"
6369 if "interfaceName" in nxhp_info :
@@ -152,13 +158,7 @@ def print_ip_routes(route_info, filter_by_ip):
152158 if "directlyConnected" in info [i ]['nexthops' ][j ]:
153159 print (" * directly connected, {}\n " .format (info [i ]['nexthops' ][j ]['interfaceName' ]))
154160 else :
155- if "ip" in info [i ]['nexthops' ][j ]:
156- str_2_print = " * {}" .format (info [i ]['nexthops' ][j ]['ip' ])
157-
158- if "active" in info [i ]['nexthops' ][j ]:
159- str_2_print += ", via {}" .format (info [i ]['nexthops' ][j ]['interfaceName' ])
160- else :
161- str_2_print += " inactive"
161+ str_2_print = get_nexthop_info_str (info [i ]['nexthops' ][j ], True )
162162 print (str_2_print )
163163 print ("" )
164164 else :
@@ -183,7 +183,7 @@ def print_ip_routes(route_info, filter_by_ip):
183183 # For all subsequent nexthops skip the spacing to not repeat the prefix section
184184 str_2_print += " " * (str_length - 3 )
185185 # Get the nexhop info portion of the string
186- str_2_print += get_nexthop_info_str (info [i ]['nexthops' ][j ])
186+ str_2_print += get_nexthop_info_str (info [i ]['nexthops' ][j ], False )
187187 # add uptime at the end of the string
188188 str_2_print += " {}" .format (info [i ]['uptime' ])
189189 # print out this string
0 commit comments