- public static Global fromRib(final BgpId bgpId, final ClusterIdentifier clusterIdentifier, final RibId ribId,
- final AsNumber localAs, final List<BgpTableType> localTables,
- final Map<TablesKey, PathSelectionMode> pathSelectionStrategies, final BGPTableTypeRegistryConsumer bgpTableTypeRegistryConsumer) {
- return toGlobalConfiguration(bgpId, clusterIdentifier, localAs, localTables, pathSelectionStrategies, bgpTableTypeRegistryConsumer);
- }
-
- private static Global toGlobalConfiguration(final BgpId bgpId, final ClusterIdentifier clusterIdentifier,
- final AsNumber localAs, final List<BgpTableType> localTables,
- final Map<TablesKey, PathSelectionMode> pathSelectionStrategies, final BGPTableTypeRegistryConsumer bgpTableTypeRegistryConsumer) {
- final ConfigBuilder configBuilder = new ConfigBuilder();
- configBuilder.setAs(localAs);
- configBuilder.setRouterId(bgpId);
- if (clusterIdentifier != null) {
- configBuilder.addAugmentation(GlobalConfigAugmentation.class,
- new GlobalConfigAugmentationBuilder().setRouteReflectorClusterId(new RrClusterIdType(clusterIdentifier)).build());
- }
- return new GlobalBuilder().setAfiSafis(new AfiSafisBuilder().setAfiSafi(toAfiSafis(localTables,
- (afiSafi, tableType) -> toGlobalAfiSafiAddPath(afiSafi, tableType, pathSelectionStrategies), bgpTableTypeRegistryConsumer)).build())
- .setConfig(configBuilder.build()).build();
- }
-
- public static Neighbor fromBgpPeer(final List<AddressFamilies> addPathCapabilities,
- final List<BgpTableType> advertisedTables, final Integer holdTimer, final IpAddress ipAddress,
- final Boolean isActive, final Rfc2385Key password, final PortNumber portNumber, final Integer retryTimer,
- final AsNumber remoteAs, final PeerRole peerRole, final BGPTableTypeRegistryConsumer bgpTableTypeRegistryConsumer) {
- final NeighborBuilder neighborBuilder = new NeighborBuilder();
- neighborBuilder.setNeighborAddress(ipAddress);
- neighborBuilder.setKey(new NeighborKey(ipAddress));
- neighborBuilder.setAfiSafis(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder().setAfiSafi(toAfiSafis(advertisedTables,
- (afiSafi, tableType) -> toNeighborAfiSafiAddPath(afiSafi, tableType, addPathCapabilities), bgpTableTypeRegistryConsumer)).build());
- neighborBuilder.setTransport(new TransportBuilder().setConfig(
- new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder()
- .setPassiveMode(!isActive)
- .setMtuDiscovery(Boolean.FALSE)
- .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.Config1.class,
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.Config1Builder()
- .setRemotePort(portNumber).build())
- .build()).build());
- neighborBuilder.setConfig(
- new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder()
- .setAuthPassword(password != null ? password.getValue() : null)
- .setPeerAs(remoteAs)
- .setPeerType(toPeerType(peerRole))
- .setSendCommunity(CommunityType.NONE)
- .setRouteFlapDamping(Boolean.FALSE)
- .build());
- neighborBuilder.setTimers(new TimersBuilder().setConfig(
- new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.ConfigBuilder()
- .setHoldTime(BigDecimal.valueOf(holdTimer))
- .setConnectRetry(BigDecimal.valueOf(retryTimer))
- .setKeepaliveInterval(DEFAULT_KEEP_ALIVE)
- .setMinimumAdvertisementInterval(DEFAULT_MINIMUM_ADV_INTERVAL)
- .build()).build());
- neighborBuilder.setRouteReflector(new RouteReflectorBuilder().setConfig(
- new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.route.reflector.ConfigBuilder()
- .setRouteReflectorClient(peerRole == PeerRole.RrClient).build()).build());
- return neighborBuilder.build();
- }
-
-
- public static Neighbor fromApplicationPeer(final ApplicationRibId applicationRibId, final BgpId bgpId) {
- final NeighborBuilder neighborBuilder = new NeighborBuilder();
- neighborBuilder.setNeighborAddress(new IpAddress(new Ipv4Address(bgpId.getValue())));
- neighborBuilder.setKey(new NeighborKey(neighborBuilder.getNeighborAddress()));
- neighborBuilder.setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder()
- .setDescription(applicationRibId.getValue())
- .addAugmentation(Config2.class, new Config2Builder().setPeerGroup(APPLICATION_PEER_GROUP_NAME).build())
- .build());
-
- return neighborBuilder.build();
- }
-