bgp: show VPNv4 Prefix information

But the result looks unexpected regarding of show_command .
I can’t find the advertised labels or assigned labels for vpnv4 prefix .
 (reference: http://sourceforge.net/p/ryu/mailman/message/32686423/ )
Therfore, I've patched the codes for formatting as follows .
=> needs for fixing labels attribute after that .

INFO:bgpspeaker.api.base:API method operator.show called with args: {'params': ['rib', 'all'], 'format': 'cli'}
Status codes: * valid, > best
     Network                          Labels   Next Hop             Reason          Metric LocPrf Path/Origin
Family: rtfilter
 *>  64512:64511:101                  None     0.0.0.0              Only Path                     2
Family: vpnv6
Family: vpnv4
 *>  64511:101:10.10.0.1/32           ([17],)  192.168.100.100      Only Path       0             64511 2
 *>  64511:101:10.20.2.0/24           ([100],) 0.0.0.0              Only Path                     2
 *>  64511:101:10.20.1.0/24           ([100],) 0.0.0.0              Only Path                     2
 *>  64511:101:10.20.3.0/24           ([100],) 0.0.0.0              Only Path                     2
Family: ipv4
Family: ipv6

Signed-off-by: Toshiki Tsuboi <t.tsubo2000@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Toshiki Tsuboi 2014-08-09 23:37:00 +09:00 committed by FUJITA Tomonori
parent 712460fa93
commit 4b07ae4714
2 changed files with 12 additions and 4 deletions

View File

@ -3,14 +3,15 @@ import StringIO
class RouteFormatterMixin(object):
fmtstr = ' {0:<3s} {1:<32s} {2:<20s} {3:<15s} {4:<6s} {5:<6s} {6:<}\n'
fmtstr = ' {0:<3s} {1:<32s} {2:<8s} {3:<20s} {4:<15s} '\
'{5:<6s} {6:<6s} {7:<}\n'
@classmethod
def _format_family_header(cls):
ret = ''
ret += ('Status codes: * valid, > best\n')
ret += cls.fmtstr.format('', 'Network', 'Next Hop', 'Reason', 'Metric',
'LocPrf', 'Path')
ret += cls.fmtstr.format('', 'Network', 'Labels', 'Next Hop', 'Reason',
'Metric', 'LocPrf', 'Path/Origin')
return ret
@classmethod
@ -26,6 +27,7 @@ class RouteFormatterMixin(object):
bpr = path.get('bpr')
next_hop = path.get('nexthop')
med = path.get('metric')
labels = path.get('labels')
localpref = path.get('localpref')
# Construct path status string.
path_status = '*'
@ -38,7 +40,7 @@ class RouteFormatterMixin(object):
prefix = path.get('prefix')
# Append path info to String buffer.
buff.write(cls.fmtstr.format(path_status, prefix,
buff.write(cls.fmtstr.format(path_status, prefix, labels,
next_hop, bpr, str(med),
str(localpref),
' '.join(map(str, aspath))))

View File

@ -130,9 +130,15 @@ class InternalApi(object):
localpref = path.get_pattr(BGP_ATTR_TYPE_LOCAL_PREF)
localpref = localpref.value if localpref else ''
if hasattr(path.nlri, 'label_list'):
labels = path.nlri.label_list
else:
labels = None
return {'best': (path == dst.best_path),
'bpr': bpr,
'prefix': path.nlri.formatted_nlri_str,
'labels': labels,
'nexthop': nexthop,
'metric': med,
'aspath': aspath,