@@ -52,12 +52,18 @@ def get_mpls_label_strgs(label_list):
52
52
label_str_2_return += "/" + label_string
53
53
return label_str_2_return
54
54
55
- def get_nexthop_info_str (nxhp_info ):
55
+ def get_nexthop_info_str (nxhp_info , filterByIp ):
56
56
str_2_return = ""
57
57
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' ])
59
62
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' ])
61
67
elif "directlyConnected" in nxhp_info :
62
68
str_2_return = " is directly connected,"
63
69
if "interfaceName" in nxhp_info :
@@ -152,13 +158,7 @@ def print_ip_routes(route_info, filter_by_ip):
152
158
if "directlyConnected" in info [i ]['nexthops' ][j ]:
153
159
print (" * directly connected, {}\n " .format (info [i ]['nexthops' ][j ]['interfaceName' ]))
154
160
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 )
162
162
print (str_2_print )
163
163
print ("" )
164
164
else :
@@ -183,7 +183,7 @@ def print_ip_routes(route_info, filter_by_ip):
183
183
# For all subsequent nexthops skip the spacing to not repeat the prefix section
184
184
str_2_print += " " * (str_length - 3 )
185
185
# 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 )
187
187
# add uptime at the end of the string
188
188
str_2_print += " {}" .format (info [i ]['uptime' ])
189
189
# print out this string
0 commit comments