Mark Bergsma has submitted this change and it was merged.
Change subject: Add BGP MED support
......................................................................
Add BGP MED support
Adds a global pybal.conf configuration option 'bgp-med' which sets a
BGP MED attribute on all NLRI if non-zero. This can be used e.g. for
BGP failover between multiple PyBal instances where the router selects
the routes for the the PyBal instance with the lowest MED value as sent
by PyBal.
Change-Id: I589be24c275cc73a5c04312e68bdf509e8c2533f
---
M pybal/pybal.py
1 file changed, 6 insertions(+), 7 deletions(-)
Approvals:
Mark Bergsma: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pybal/pybal.py b/pybal/pybal.py
index cbffd3a..dd439e1 100755
--- a/pybal/pybal.py
+++ b/pybal/pybal.py
@@ -467,21 +467,20 @@
peerAddr=self.globalConfig.get('bgp-peer-address'))
asPath = [int(asn) for asn in self.globalConfig.get('bgp-as-path',
str(self.bgpPeering.myASN)).split()]
- attributes = {}
+ med = self.globalConfig.getint('bgp-med', 0)
+ baseAttrs = [bgp.OriginAttribute(), bgp.ASPathAttribute(asPath)]
+ if med: baseAttrs.append(bgp.MEDAttribute(med))
+ attributes = {}
try:
- attributes[(bgp.AFI_INET, bgp.SAFI_UNICAST)] =
bgp.FrozenAttributeDict([
- bgp.OriginAttribute(),
- bgp.ASPathAttribute(asPath),
+ attributes[(bgp.AFI_INET, bgp.SAFI_UNICAST)] =
bgp.FrozenAttributeDict(baseAttrs + [
bgp.NextHopAttribute(self.globalConfig['bgp-nexthop-ipv4'])])
except KeyError:
if (bgp.AFI_INET, bgp.SAFI_UNICAST) in BGPFailover.prefixes:
raise ValueError("IPv4 BGP NextHop (global configuration
variable 'bgp-nexthop-ipv4') not set")
try:
- attributes[(bgp.AFI_INET6, bgp.SAFI_UNICAST)] =
bgp.FrozenAttributeDict([
- bgp.OriginAttribute(),
- bgp.ASPathAttribute(asPath),
+ attributes[(bgp.AFI_INET6, bgp.SAFI_UNICAST)] =
bgp.FrozenAttributeDict(baseAttrs + [
bgp.MPReachNLRIAttribute((bgp.AFI_INET6, bgp.SAFI_UNICAST,
bgp.IPv6IP(self.globalConfig['bgp-nexthop-ipv6']), []))])
except KeyError:
--
To view, visit https://gerrit.wikimedia.org/r/267251
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I589be24c275cc73a5c04312e68bdf509e8c2533f
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Mark Bergsma <[email protected]>
Gerrit-Reviewer: Mark Bergsma <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits