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
  Faidon Liambotis: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/pybal/pybal.py b/pybal/pybal.py
index 4f7863b..31d6ee4 100755
--- a/pybal/pybal.py
+++ b/pybal/pybal.py
@@ -472,21 +472,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/255544
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I589be24c275cc73a5c04312e68bdf509e8c2533f
Gerrit-PatchSet: 2
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: bgp-med
Gerrit-Owner: Mark Bergsma <m...@wikimedia.org>
Gerrit-Reviewer: BBlack <bbl...@wikimedia.org>
Gerrit-Reviewer: Faidon Liambotis <fai...@wikimedia.org>
Gerrit-Reviewer: Giuseppe Lavagetto <glavage...@wikimedia.org>
Gerrit-Reviewer: Mark Bergsma <m...@wikimedia.org>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to