Bug 2963 - Make BGP peer role configurable 14/18614/12
authorLadislav Borak <lborak@cisco.com>
Mon, 20 Apr 2015 11:46:57 +0000 (13:46 +0200)
committerLadislav Borak <lborak@cisco.com>
Wed, 22 Apr 2015 14:18:47 +0000 (16:18 +0200)
- added support for BGP peer role configurable

Change-Id: I756c013538a3c10a509c48ab1b69cefac2c033da
Signed-off-by: Ladislav Borak <lborak@cisco.com>
bgp/controller-config/src/main/resources/initial/41-bgp-example.xml
bgp/rib-impl/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPPeerModule.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java
bgp/rib-impl/src/main/yang/odl-bgp-rib-impl-cfg.yang

index 3d1026ebe7df0525cc8cfa871b244e1ac6792215..d5f1539e4d62f05871142012ce5ac3dc50bbb22a 100644 (file)
                      "md5-channel-factory" attribute set and then add a "password" attribute here.
                      Note that the peer has to have the same password configured, otherwise the
                      connection will not be established.
+                     If peer role is not present, default value "Ibgp" will be used (allowed values are also "Ebgp" and
+                     "RrClient").
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-peer</type>
                     <name>example-bgp-peer</name>
                     <host>192.0.2.1</host>
                     <holdtimer>180</holdtimer>
+                    <peerRole>Ibgp<peerRole>
                     <rib>
                         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:cfg">prefix:rib</type>
                         <name>example-bgp-rib</name>
index 40924dfbb9484ce06a943721cf413f0ff607e6da..9ace4ae15b64619fe766aa90d6aa939c5f623a58 100644 (file)
@@ -42,6 +42,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.open.bgp.parameters.optional.capabilities.c.parameters.MultiprotocolCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.open.bgp.parameters.optional.capabilities.c.parameters.graceful.restart._case.GracefulRestartCapabilityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.open.bgp.parameters.optional.capabilities.c.parameters.multiprotocol._case.MultiprotocolCapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -107,9 +108,14 @@ public final class BGPPeerModule extends org.opendaylight.controller.config.yang
         final List<BgpParameters> tlvs = getTlvs(r);
         final AsNumber remoteAs = getAsOrDefault(r);
         final String password = getPasswordOrNull();
-
         final BGPSessionPreferences prefs = new BGPSessionPreferences(r.getLocalAs(), getHoldtimer(), r.getBgpIdentifier(), tlvs);
-        final BGPPeer bgpClientPeer = new BGPPeer(peerName(getHostWithoutValue()), r);
+        final BGPPeer bgpClientPeer;
+        if (getPeerRole() != null) {
+            bgpClientPeer = new BGPPeer(peerName(getHostWithoutValue()), r, getPeerRole());
+        } else {
+            bgpClientPeer = new BGPPeer(peerName(getHostWithoutValue()), r, PeerRole.Ibgp);
+        }
+
         bgpClientPeer.registerRootRuntimeBean(getRootRuntimeBeanRegistratorWrapper());
 
         getPeerRegistryBackwards().addPeer(getHostWithoutValue(), bgpClientPeer, prefs);
index b26f0f0d430a846a476ea909407b21dbb08e4c3e..c5e411ab89fa92f55a4be616536cbbc6d4eba74c 100644 (file)
@@ -84,13 +84,14 @@ public class BGPPeer implements ReusableBGPPeer, Peer, AutoCloseable, BGPPeerRun
     private long sessionEstablishedCounter = 0L;
 
     public BGPPeer(final String name, final RIB rib) {
+        this(name, rib, PeerRole.Ibgp);
+    }
+
+    public BGPPeer(final String name, final RIB rib, final PeerRole role) {
         this.rib = Preconditions.checkNotNull(rib);
         this.name = name;
         this.chain = rib.createPeerChain(this);
-
-        // FIXME: make this configurable
-        final PeerRole role = PeerRole.Ibgp;
-        this.ribWriter = AdjRibInWriter.create(rib.getYangRibId(), role, this.chain);
+        this.ribWriter = AdjRibInWriter.create(rib.getYangRibId(), role, chain);
     }
 
     @Override
index 05919b0dd9eb8aece2eaebec49f5528d57897f94..1e6b47f1b9b494aad205f81a562f11c615184f10 100644 (file)
@@ -312,6 +312,11 @@ module odl-bgp-rib-impl-cfg {
                 default 180;
             }
 
+            leaf peer-role {
+                type rib:peer-role;
+                default ibgp;
+            }
+
             leaf initiate-connection {
                 description "If true, connection will be initiated right away from current device.
                     If not, the peer will only be registered to peer registry and available for incomming bgp connections.";