Skip to content

Commit

Permalink
fix json output for capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Jul 4, 2017
1 parent 214e8ee commit 6d3ee3e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions etc/exabgp/api-open.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ neighbor 127.0.0.1 {
api announce {
processes [ announce-routes ];
send {
parsed;
open;
}
receive {
Expand Down
5 changes: 3 additions & 2 deletions etc/exabgp/run/api-open.run
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ try:
except Exception:
print >> sys.stderr, 'failure, json can not be decoded'
sys.stderr.flush()
print >> sys.stderr, 'json received:', line.rstrip()
sys.stderr.flush()
sys.exit(1)

print >> sys.stderr, 'json received:', line.rstrip()
sys.stderr.flush()

if 'shutdown' in line:
sys.exit(1)
except KeyboardInterrupt:
Expand Down
8 changes: 4 additions & 4 deletions lib/exabgp/bgp/message/open/capability/graceful.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ def json (self):
d = {
'name':'"graceful restart"',
'time':self.restart_time,
'address-family-flags':'{%s } ' % (
', '.join('"%s/%s": [%s ]' % (
' %s' % afi, safi, ' "restart"' if family & 0x80 else '') for afi, safi, family in [
'address-family-flags':'{ %s}' % (
', '.join('"%s/%s": [%s ] ' % (
'%s' % afi, safi, ' "restart"' if family & 0x80 else '') for afi, safi, family in [
(str(a), str(s), self[(a,s)]) for (a,s) in self.keys()
]
)
),
'restart-flags':'[%s] ' % (' "forwarding" ' if self.restart_flag & 0x8 else ' ')
}

return '{ %s}' % ','.join('"%s": %s' % (k,v) for k,v in six.iteritems(d))
return '{ %s}' % ', '.join('"%s": %s' % (k,v) for k,v in six.iteritems(d))

def families (self):
return self.keys()
Expand Down
2 changes: 1 addition & 1 deletion lib/exabgp/bgp/message/open/capability/ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __str__ (self):

def json (self):
variant = 'RFC' if self.ID == Capability.CODE.MULTISESSION else 'Cisco'
return '{ "name": "multisession", "variant": "%s" ,"capabilities": [%s ] }' % (variant, ','.join(' %s' % str(capa) for capa in self))
return '{ "name": "multisession", "variant": "%s", "capabilities": [%s ] }' % (variant, ','.join(' "%s"' % str(capa) for capa in self))

def extract (self):
rs = [character(0),]
Expand Down

0 comments on commit 6d3ee3e

Please sign in to comment.