Skip to content

Commit

Permalink
fix software version feature
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Jul 15, 2024
1 parent c7c3afe commit 8b61bf2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/exabgp/bgp/message/open/capability/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _software_version(self, neighbor):
if not neighbor['capability']['software-version']:
return

self[Capability.CODE.SOFTRWARE_VERSION] = SoftwareVersion()
self[Capability.CODE.SOFTWARE_VERSION] = SoftwareVersion()

def _operational(self, neighbor):
if not neighbor['capability']['operational']:
Expand Down
2 changes: 1 addition & 1 deletion src/exabgp/bgp/message/open/capability/capability.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class CODE(int):
ROUTE_REFRESH_CISCO = _CapabilityCode(_CapabilityCode.ROUTE_REFRESH_CISCO)
MULTISESSION_CISCO = _CapabilityCode(_CapabilityCode.MULTISESSION_CISCO)
HOSTNAME = _CapabilityCode(_CapabilityCode.HOSTNAME)
SOFTRWARE_VERSION = _CapabilityCode(_CapabilityCode.SOFTWARE_VERSION)
SOFTWARE_VERSION = _CapabilityCode(_CapabilityCode.SOFTWARE_VERSION)
OPERATIONAL = _CapabilityCode(_CapabilityCode.OPERATIONAL)
AIGP = _CapabilityCode(_CapabilityCode.AIGP)
# fmt: on
Expand Down
16 changes: 8 additions & 8 deletions src/exabgp/bgp/message/open/capability/software_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@

@Capability.register()
class SoftwareVersion(Capability):
ID = Capability.CODE.SOFTRWARE_VERSION
ID = Capability.CODE.SOFTWARE_VERSION
SOFTWARE_VERSION_MAX_LEN = 64

def __init__(self):
self.software_version = f"ExaBGP/{version}"
software_version = f"ExaBGP/{version}"
if len(software_version) > self.SOFTWARE_VERSION_MAX_LEN:
software_version = software_version[:self.SOFTWARE_VERSION_MAX_LEN - 3] + '...'
self.software_version = software_version

def __str__(self):
return f'SoftwareVersion({self.software_version})'
return 'SoftwareVersion(%s)' % self.software_version

def json(self):
return f'{ "software-version": "{self.software_version}" }'
return '{ "software-version": "%s" }' % self.software_version

def extract(self):
software_version = self.software_version.encode('utf-8')
if len(software_version) > self.SOFTWARE_VERSION_MAX_LEN:
software_version = software_version[: self.SOFTWARE_VERSION_MAX_LEN]
return [bytes([len(software_version)]) + software_version]
return [bytes([len(self.software_version)]) + self.software_version.encode('utf-8')]

@staticmethod
def unpack_capability(instance, data, capability=None): # pylint: disable=W0613
Expand Down

0 comments on commit 8b61bf2

Please sign in to comment.