From f0fabb591f5e0834f0fec31c9dcaaaf78ae4a41a Mon Sep 17 00:00:00 2001 From: sbalineni Date: Wed, 22 Jun 2016 11:56:35 -0700 Subject: [PATCH] [DM]: Configure local-as value if global asn is different When mx bgp router is conifgured with 'local-autonomous-system', DM should generate local-as conifguraion as follows. protocols { bgp { group __contrail_external__ { type internal; neighbor 10.84.7.31 { peer-as 1000; } } More details in the bug. Change-Id: If2cfb53095a6af64fa7f05e1d98c07beed7f6d0c Closes-Bug: #1549614 Closes-Bug: #1451972 --- src/config/device-manager/device_manager/db.py | 7 +++++-- .../device_manager/physical_router_config.py | 9 ++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/config/device-manager/device_manager/db.py b/src/config/device-manager/device_manager/db.py index 05013c89daf..05a57380744 100644 --- a/src/config/device-manager/device_manager/db.py +++ b/src/config/device-manager/device_manager/db.py @@ -560,8 +560,11 @@ def push_config(self): peer = BgpRouterDM.get(peer_uuid) if peer is None: continue - external = (bgp_router.params['autonomous_system'] != - peer.params['autonomous_system']) + local_as = bgp_router.params.get('local_autonomous_system') or \ + bgp_router.params.get('autonomous_system') + peer_as = peer.params.get('local_autonomous_system') or \ + peer.params.get('autonomous_system') + external = (local_as != peer_as) self.config_manager.add_bgp_peer(peer.params['address'], peer.params, attr, external) self.config_manager.set_bgp_config(bgp_router.params) diff --git a/src/config/device-manager/device_manager/physical_router_config.py b/src/config/device-manager/device_manager/physical_router_config.py index d674e009756..6f8131e1986 100644 --- a/src/config/device-manager/device_manager/physical_router_config.py +++ b/src/config/device-manager/device_manager/physical_router_config.py @@ -810,9 +810,8 @@ def _get_neighbor_config_xml(self, bgp_config, peers): self._add_family_etree(nbr, session_attr) self.add_bgp_auth_config(nbr, session_attr) break - if params.get('autonomous_system') is not None: - etree.SubElement( - nbr, "peer-as").text = str(params.get('autonomous_system')) + peer_as = params.get('local_autonomous_system') or params.get('autonomous_system') + etree.SubElement(nbr, "peer-as").text = str(peer_as) # end _get_neighbor_config_xml def send_bgp_config(self): @@ -832,8 +831,8 @@ def send_bgp_config(self): etree.SubElement( routing_options_config, "route-distinguisher-id").text = self.bgp_params['identifier'] - etree.SubElement(routing_options_config, "autonomous-system").text = \ - str(self.bgp_params.get('autonomous_system')) + local_as = self.bgp_params.get('local_autonomous_system') or self.bgp_params.get('autonomous_system') + etree.SubElement(routing_options_config, "autonomous-system").text = str(local_as) config_list = [proto_config, routing_options_config] if self.ri_config is not None: config_list.append(self.ri_config)