configured as a route reflector.";
}
}
- augment bgp/neighbors/neighbor/config {
- ext:augment-identifier neighbor-config-augmentation;
- leaf simple-routing-policy {
- type bgp-rib:simple-routing-policy;
- }
- }
augment bgp/neighbors/neighbor/state {
ext:augment-identifier neighbor_state-augmentation;
uses bgp-op:bgp-neighbor_state;
}
}
- typedef simple-routing-policy {
- type enumeration {
- enum announce-none { description "Don't announce routes to this peer"; }
- enum learn-none { description "Don't learn routes from this peer"; }
- }
- }
-
grouping route {
uses bgp-msg:path-attributes;
}
type peer-role;
mandatory true;
}
- leaf simple-routing-policy {
- type simple-routing-policy;
- }
list supported-tables {
key "afi safi";
uses bgp-mp:bgp-add-path-table-type;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Optional;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.SimpleRoutingPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.peer.AdjRibIn;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.peer.AdjRibOut;
private static final NodeIdentifier PEER_TABLES = new NodeIdentifier(SupportedTables.QNAME);
private static final NodeIdentifier TABLES = new NodeIdentifier(Tables.QNAME);
private static final QName SEND_RECEIVE = QName.create(SupportedTables.QNAME, "send-receive").intern();
- private static final NodeIdentifier SIMPLE_ROUTING_POLICY_NID =
- new NodeIdentifier(QName.create(Peer.QNAME, "simple-routing-policy").intern());
// FIXME: is there a utility method to construct this?
private static final ContainerNode EMPTY_ADJRIBIN = Builders.containerBuilder()
private final YangInstanceIdentifier ribPath;
private final DOMTransactionChain chain;
private final PeerRole role;
- private final Optional<SimpleRoutingPolicy> simpleRoutingPolicy;
private AdjRibInWriter(final YangInstanceIdentifier ribPath, final DOMTransactionChain chain, final PeerRole role,
- final Optional<SimpleRoutingPolicy> simpleRoutingPolicy, final YangInstanceIdentifier peerPath,
- final Map<TablesKey, TableContext> tables) {
+ final YangInstanceIdentifier peerPath, final Map<TablesKey, TableContext> tables) {
this.ribPath = requireNonNull(ribPath);
this.chain = requireNonNull(chain);
this.tables = requireNonNull(tables);
this.role = requireNonNull(role);
- this.simpleRoutingPolicy = simpleRoutingPolicy;
this.peerPath = peerPath;
}
* Create a new writer using a transaction chain.
*
* @param role peer's role
- * @param simpleRoutingPolicy simple Routing Policy {@link SimpleRoutingPolicy}
* @param chain transaction chain @return A fresh writer instance
*/
static AdjRibInWriter create(@Nonnull final YangInstanceIdentifier ribId, @Nonnull final PeerRole role,
- final Optional<SimpleRoutingPolicy> simpleRoutingPolicy, @Nonnull final DOMTransactionChain chain) {
- return new AdjRibInWriter(ribId, chain, role, simpleRoutingPolicy, null, Collections.emptyMap());
+ @Nonnull final DOMTransactionChain chain) {
+ return new AdjRibInWriter(ribId, chain, role, null, Collections.emptyMap());
}
/**
}
}
}, MoreExecutors.directExecutor());
- return new AdjRibInWriter(this.ribPath, this.chain, this.role, this.simpleRoutingPolicy, newPeerPath, tb);
+ return new AdjRibInWriter(this.ribPath, this.chain, this.role, newPeerPath, tb);
}
/**
private void installAdjRibsOutTables(final YangInstanceIdentifier newPeerPath, final RIBSupportContext rs,
final NodeIdentifierWithPredicates instanceIdentifierKey, final TablesKey tableKey,
final SendReceive sendReceive, final DOMDataWriteTransaction tx) {
- if (!isAnnounceNone(this.simpleRoutingPolicy)) {
- final NodeIdentifierWithPredicates supTablesKey = RibSupportUtils.toYangKey(SupportedTables.QNAME, tableKey);
- final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> tt =
- Builders.mapEntryBuilder().withNodeIdentifier(supTablesKey);
- for (final Entry<QName, Object> e : supTablesKey.getKeyValues().entrySet()) {
- tt.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
- }
- if (sendReceive != null) {
- tt.withChild(ImmutableNodes.leafNode(SEND_RECEIVE, sendReceive.toString().toLowerCase(Locale.ENGLISH)));
- }
- tx.put(LogicalDatastoreType.OPERATIONAL, newPeerPath.node(PEER_TABLES).node(supTablesKey), tt.build());
- rs.createEmptyTableStructure(tx, newPeerPath.node(EMPTY_ADJRIBOUT.getIdentifier())
- .node(TABLES).node(instanceIdentifierKey));
+ final NodeIdentifierWithPredicates supTablesKey = RibSupportUtils.toYangKey(SupportedTables.QNAME, tableKey);
+ final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> tt =
+ Builders.mapEntryBuilder().withNodeIdentifier(supTablesKey);
+ for (final Entry<QName, Object> e : supTablesKey.getKeyValues().entrySet()) {
+ tt.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
}
+ if (sendReceive != null) {
+ tt.withChild(ImmutableNodes.leafNode(SEND_RECEIVE, sendReceive.toString().toLowerCase(Locale.ENGLISH)));
+ }
+ tx.put(LogicalDatastoreType.OPERATIONAL, newPeerPath.node(PEER_TABLES).node(supTablesKey), tt.build());
+ rs.createEmptyTableStructure(tx, newPeerPath.node(EMPTY_ADJRIBOUT.getIdentifier())
+ .node(TABLES).node(instanceIdentifierKey));
}
private YangInstanceIdentifier createEmptyPeerStructure(final PeerId newPeerId, final DOMDataWriteTransaction tx) {
pb.withNodeIdentifier(peerKey);
pb.withChild(ImmutableNodes.leafNode(PEER_ID, peerId));
pb.withChild(ImmutableNodes.leafNode(PEER_ROLE, PeerRoleUtil.roleForString(this.role)));
- if (this.simpleRoutingPolicy.isPresent() && this.role != PeerRole.Internal) {
- pb.withChild(ImmutableNodes.leafNode(SIMPLE_ROUTING_POLICY_NID,
- simpleRoutingPolicyString(this.simpleRoutingPolicy.get())));
- }
pb.withChild(ImmutableMapNodeBuilder.create().withNodeIdentifier(PEER_TABLES).build());
pb.withChild(EMPTY_ADJRIBIN);
- if (!isLearnNone(this.simpleRoutingPolicy)) {
- pb.withChild(EMPTY_EFFRIBIN);
- }
- if (!isAnnounceNone(this.simpleRoutingPolicy)) {
- pb.withChild(EMPTY_ADJRIBOUT);
- }
+ pb.withChild(EMPTY_EFFRIBIN);
+ pb.withChild(EMPTY_ADJRIBOUT);
return pb.build();
}
ctx.removeRoutes(tx, nlri);
tx.submit();
}
-
- static boolean isAnnounceNone(final java.util.Optional<SimpleRoutingPolicy> peerStatus) {
- return peerStatus.isPresent() && peerStatus.get() == SimpleRoutingPolicy.AnnounceNone;
- }
-
- static boolean isLearnNone(final java.util.Optional<SimpleRoutingPolicy> peerStatus) {
- return peerStatus.isPresent() && peerStatus.get() == SimpleRoutingPolicy.LearnNone;
- }
-
- private static String simpleRoutingPolicyString(final SimpleRoutingPolicy simpleRoutingPolicy) {
- switch (simpleRoutingPolicy) {
- case AnnounceNone:
- return "announce-none";
- case LearnNone:
- return "learn-none";
- default:
- throw new IllegalArgumentException("Unhandled Simple Routing Policy " + simpleRoutingPolicy);
- }
- }
}
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Optional;
import java.util.Set;
import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.ApplicationRibId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.SimpleRoutingPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.peer.AdjRibIn;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables;
this.chain = this.rib.createPeerChain(this);
this.writerChain = this.rib.createPeerChain(this);
- final Optional<SimpleRoutingPolicy> simpleRoutingPolicy = Optional.of(SimpleRoutingPolicy.AnnounceNone);
this.peerId = RouterIds.createPeerId(this.ipAddress);
final Set<TablesKey> localTables = this.rib.getLocalTablesKeys();
localTables.forEach(tablesKey -> {
final ExportPolicyPeerTracker exportTracker = this.rib.getExportPolicyPeerTracker(tablesKey);
if (exportTracker != null) {
- exportTracker.registerPeer(this.peerId, null, this.peerIId, PeerRole.Internal, simpleRoutingPolicy);
+ exportTracker.registerPeer(this.peerId, null, this.peerIId, PeerRole.Internal);
}
this.supportedTables.add(RibSupportUtils.toYangTablesKey(tablesKey));
});
setAdvertizedGracefulRestartTableTypes(Collections.emptyList());
- this.adjRibInWriter = AdjRibInWriter.create(this.rib.getYangRibId(), PeerRole.Internal, simpleRoutingPolicy,
- this.writerChain);
+ this.adjRibInWriter = AdjRibInWriter.create(this.rib.getYangRibId(), PeerRole.Internal, this.writerChain);
final RIBSupportContextRegistry context = this.rib.getRibSupportContext();
final RegisterAppPeerListener registerAppPeerListener = () -> {
synchronized (this) {
package org.opendaylight.protocol.bgp.rib.impl;
import static java.util.Objects.requireNonNull;
-import static org.opendaylight.protocol.bgp.rib.impl.AdjRibInWriter.isAnnounceNone;
-import static org.opendaylight.protocol.bgp.rib.impl.AdjRibInWriter.isLearnNone;
-import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Objects;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev171207.PeerContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.SimpleRoutingPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.PeerKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
private final Map<TablesKey, AdjRibOutListener> adjRibOutListenerSet = new HashMap<>();
private final RpcProviderRegistry rpcRegistry;
private final PeerRole peerRole;
- private final Optional<SimpleRoutingPolicy> simpleRoutingPolicy;
@GuardedBy("this")
private AbstractRegistration trackerRegistration;
@GuardedBy("this")
private Map<TablesKey, SendReceive> addPathTableMaps = Collections.emptyMap();
public BGPPeer(final IpAddress neighborAddress, final RIB rib, final PeerRole role,
- final SimpleRoutingPolicy peerStatus, final RpcProviderRegistry rpcRegistry,
+ final RpcProviderRegistry rpcRegistry,
final Set<TablesKey> afiSafisAdvertized,
final Set<TablesKey> afiSafisGracefulAdvertized) {
//FIXME BUG-6971 Once Peer Group is implemented, pass it
super(rib.getInstanceIdentifier(), null, neighborAddress, afiSafisAdvertized,
afiSafisGracefulAdvertized);
this.peerRole = role;
- this.simpleRoutingPolicy = Optional.ofNullable(peerStatus);
this.rib = requireNonNull(rib);
this.name = Ipv4Util.toStringIP(neighborAddress);
this.rpcRegistry = rpcRegistry;
this.chain = rib.createPeerChain(this);
}
- @VisibleForTesting
- BGPPeer(final IpAddress neighborAddress, final RIB rib, final PeerRole role,
- final RpcProviderRegistry rpcRegistry, final Set<TablesKey> afiSafisAdvertized,
- final Set<TablesKey> afiSafisGracefulAdvertized) {
- this(neighborAddress, rib, role, null, rpcRegistry, afiSafisAdvertized, afiSafisGracefulAdvertized);
- }
-
private static Attributes nextHopToAttribute(final Attributes attrs, final MpReachNlri mpReach) {
if (attrs.getCNextHop() == null && mpReach.getCNextHop() != null) {
final AttributesBuilder attributesBuilder = new AttributesBuilder(attrs);
}
public synchronized void instantiateServiceInstance() {
- this.ribWriter = AdjRibInWriter.create(this.rib.getYangRibId(), this.peerRole, this.simpleRoutingPolicy,
- this.chain);
+ this.ribWriter = AdjRibInWriter.create(this.rib.getYangRibId(), this.peerRole, this.chain);
setActive(true);
}
setAdvertizedGracefulRestartTableTypes(advertizedGracefulRestartTableTypes.stream()
.map(t -> new TablesKey(t.getAfi(), t.getSafi())).collect(Collectors.toList()));
- final boolean announceNone = isAnnounceNone(this.simpleRoutingPolicy);
this.addPathTableMaps = mapTableTypesFamilies(addPathTablesType);
- if (!announceNone) {
- for (final TablesKey key : this.tables) {
- createAdjRibOutListener(key, true);
- }
+ for (final TablesKey key : this.tables) {
+ createAdjRibOutListener(key, true);
}
for(final TablesKey tablesKey :this.tables) {
final ExportPolicyPeerTracker exportTracker = this.rib.getExportPolicyPeerTracker(tablesKey);
if (exportTracker != null) {
this.tableRegistration.add(exportTracker.registerPeer(this.peerId, this.addPathTableMaps.get(tablesKey),
- this.peerIId, this.peerRole, this.simpleRoutingPolicy));
+ this.peerIId, this.peerRole));
}
}
- addBgp4Support(announceNone);
-
- if (!isLearnNone(this.simpleRoutingPolicy)) {
- this.effRibInWriter = EffectiveRibInWriter.create(this.rib.getService(),
- this.rib.createPeerChain(this),
- this.peerIId, this.rib.getImportPolicyPeerTracker(),
- this.rib.getRibSupportContext(),
- this.peerRole,
- this.tables);
- registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
- }
+ addBgp4Support();
+
+ this.effRibInWriter = EffectiveRibInWriter.create(this.rib.getService(),
+ this.rib.createPeerChain(this),
+ this.peerIId, this.rib.getImportPolicyPeerTracker(),
+ this.rib.getRibSupportContext(),
+ this.peerRole,
+ this.tables);
+ registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
this.ribWriter = this.ribWriter.transform(this.peerId, this.rib.getRibSupportContext(), this.tables,
this.addPathTableMaps);
}
//try to add a support for old-school BGP-4, if peer did not advertise IPv4-Unicast MP capability
- private void addBgp4Support(final boolean announceNone) {
+ private void addBgp4Support() {
final TablesKey key = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
- if (this.tables.add(key) && !announceNone) {
+ if (this.tables.add(key)) {
createAdjRibOutListener(key, false);
final ExportPolicyPeerTracker exportTracker = this.rib.getExportPolicyPeerTracker(key);
if (exportTracker != null) {
this.tableRegistration.add(exportTracker.registerPeer(peerId, null, this.peerIId,
- this.peerRole, this.simpleRoutingPolicy));
+ this.peerRole));
}
}
}
LOG.error("Transaction chain failed.", cause);
this.chain.close();
this.chain = this.rib.createPeerChain(this);
- this.ribWriter = AdjRibInWriter.create(this.rib.getYangRibId(), this.peerRole, this.simpleRoutingPolicy,
- this.chain);
+ this.ribWriter = AdjRibInWriter.create(this.rib.getYangRibId(), this.peerRole, this.chain);
releaseConnection();
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.SendReceive;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.SimpleRoutingPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
}
private synchronized AbstractRegistration addToExportGroups(final PeerId peerId,
- final YangInstanceIdentifier peerPath, final PeerRole peerRole) {
+ final YangInstanceIdentifier peerPath, final PeerRole peerRole) {
final PeerExportGroupRegistry peerExp = this.groups.computeIfAbsent(peerRole,
- k -> new PeerExportGroupImpl(this.policyDatabase.exportPolicyForRole(peerRole)));
+ k -> new PeerExportGroupImpl(this.policyDatabase.exportPolicyForRole(peerRole)));
final AbstractRegistration registration = peerExp.registerPeer(peerId, new PeerExporTuple(peerPath, peerRole));
@Override
public synchronized AbstractRegistration registerPeer(final PeerId peerId, final SendReceive sendReceive,
- final YangInstanceIdentifier peerPath, final PeerRole peerRole,
- final Optional<SimpleRoutingPolicy> optSimpleRoutingPolicy) {
+ final YangInstanceIdentifier peerPath, final PeerRole peerRole) {
if (sendReceive != null) {
this.peerAddPathTables.put(peerId, sendReceive);
LOG.debug("Supported Add BestPath table {} added to peer {}", sendReceive, peerId);
}
- final SimpleRoutingPolicy simpleRoutingPolicy = optSimpleRoutingPolicy.orElse(null);
- if (SimpleRoutingPolicy.AnnounceNone != simpleRoutingPolicy) {
- this.peerTables.put(peerId, false);
- }
+ this.peerTables.put(peerId, false);
this.peerRoles.put(peerPath, peerRole);
LOG.debug("Supported table {} added to peer {} role {}", this.localTableKey, peerId, peerRole);
final AbstractRegistration registration = addToExportGroups(peerId, peerPath, peerRole);
import static java.util.Objects.requireNonNull;
import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getHoldTimer;
import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getPeerAs;
-import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getSimpleRoutingPolicy;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
final Set<TablesKey> afiSafisAdvertized = OpenConfigMappingUtil
.toTableKey(afisSAfis.getAfiSafi(), tableTypeRegistry);
this.bgpPeer = new BGPPeer(this.neighborAddress, rib,
- OpenConfigMappingUtil.toPeerRole(neighbor),
- getSimpleRoutingPolicy(neighbor), BgpPeer.this.rpcRegistry,
+ OpenConfigMappingUtil.toPeerRole(neighbor), BgpPeer.this.rpcRegistry,
afiSafisAdvertized, Collections.emptySet());
final List<BgpParameters> bgpParameters = getBgpParameters(neighbor, rib, tableTypeRegistry);
final KeyMapping keyMapping = OpenConfigMappingUtil.getNeighborKey(neighbor);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.Config2Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.GlobalConfigAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.GlobalConfigAugmentationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.NeighborConfigAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.NeighborConfigAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.ApplicationRibId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.SimpleRoutingPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
return new ClusterIdentifier(globalConfig.getRouterId());
}
- public static SimpleRoutingPolicy getSimpleRoutingPolicy(final Neighbor neighbor) {
- if (neighbor.getConfig() != null) {
- final NeighborConfigAugmentation augmentation = neighbor.getConfig().getAugmentation(NeighborConfigAugmentation.class);
- if (augmentation != null) {
- return augmentation.getSimpleRoutingPolicy();
- }
- }
- return null;
- }
-
private static org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.Config getTimersConfig(final Neighbor neighbor) {
final Timers timers = neighbor.getTimers();
return timers != null ? timers.getConfig() : null;
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 SimpleRoutingPolicy simpleRoutingPolicy, final BGPTableTypeRegistryConsumer bgpTableTypeRegistryConsumer) {
+ final AsNumber remoteAs, final PeerRole peerRole, final BGPTableTypeRegistryConsumer bgpTableTypeRegistryConsumer) {
final NeighborBuilder neighborBuilder = new NeighborBuilder();
neighborBuilder.setNeighborAddress(ipAddress);
neighborBuilder.setKey(new NeighborKey(ipAddress));
.setPeerType(toPeerType(peerRole))
.setSendCommunity(CommunityType.NONE)
.setRouteFlapDamping(Boolean.FALSE)
- .addAugmentation(NeighborConfigAugmentation.class, setNeighborAugmentation(simpleRoutingPolicy))
.build());
neighborBuilder.setTimers(new TimersBuilder().setConfig(
new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.ConfigBuilder()
return neighborBuilder.build();
}
- private static NeighborConfigAugmentation setNeighborAugmentation(final SimpleRoutingPolicy simpleRoutingPolicy) {
- if (simpleRoutingPolicy != null) {
- return new NeighborConfigAugmentationBuilder().setSimpleRoutingPolicy(simpleRoutingPolicy).build();
- }
- return null;
- }
-
public static PeerRole toPeerRole(final Neighbor neighbor) {
if (isRrClient(neighbor)) {
return PeerRole.RrClient;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.never;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.CheckedFuture;
import java.util.Collections;
import java.util.Map;
-import java.util.Optional;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Rib;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.SimpleRoutingPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.peer.AdjRibIn;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.peer.SupportedTables;
public class AdjRibsInWriterTest {
+ private static final TablesKey K4 = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
+ private static final Map<TablesKey, SendReceive> ADD_PATH_TABLE_MAPS = Collections.singletonMap(K4, SendReceive.Both);
+ private final Set<TablesKey> tableTypes = Sets.newHashSet(K4);
+ private final String peerIp = "12.34.56.78";
@Mock
private DOMTransactionChain chain;
-
@Mock
private DOMDataWriteTransaction tx;
-
@Mock
private RIBSupportContextRegistry registry;
-
@Mock
private RIBSupportContext context;
-
private AdjRibInWriter writer;
- private static final TablesKey K4 = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
- private final Set<TablesKey> tableTypes = Sets.newHashSet(K4);
- private static final Map<TablesKey, SendReceive> ADD_PATH_TABLE_MAPS = Collections.singletonMap(K4, SendReceive.Both);
-
- private final String peerIp = "12.34.56.78";
-
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
Mockito.doReturn("MockedTrans").when(this.tx).toString();
Mockito.doReturn(this.tx).when(this.chain).newWriteOnlyTransaction();
- final CheckedFuture<?, ?> checkedFuture = Mockito.mock(CheckedFuture.class);
+ final CheckedFuture<?, ?> checkedFuture = Mockito.mock(CheckedFuture.class);
Mockito.doNothing().when(checkedFuture).addListener(any(), any());
Mockito.doReturn(checkedFuture).when(this.tx).submit();
Mockito.doNothing().when(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.any(YangInstanceIdentifier.class), Mockito.any(NormalizedNode.class));
@Test
public void testTransform() {
- this.writer = AdjRibInWriter.create(YangInstanceIdentifier.of(Rib.QNAME), PeerRole.Ebgp, Optional.empty(), this.chain);
+ this.writer = AdjRibInWriter.create(YangInstanceIdentifier.of(Rib.QNAME), PeerRole.Ebgp, this.chain);
assertNotNull(this.writer);
final YangInstanceIdentifier peerPath = YangInstanceIdentifier.builder().node(Rib.QNAME).node(Peer.QNAME).nodeWithKey(Peer.QNAME,
- AdjRibInWriter.PEER_ID_QNAME, this.peerIp).build();
+ AdjRibInWriter.PEER_ID_QNAME, this.peerIp).build();
this.writer.transform(new PeerId(this.peerIp), this.registry, this.tableTypes, ADD_PATH_TABLE_MAPS);
verifyPeerSkeletonInsertedCorrectly(peerPath);
// verify supported tables were inserted for ipv4
Mockito.verify(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.eq(peerPath.node(SupportedTables.QNAME)
- .node(RibSupportUtils.toYangKey(SupportedTables.QNAME, K4))), Mockito.any(NormalizedNode.class));
+ .node(RibSupportUtils.toYangKey(SupportedTables.QNAME, K4))), Mockito.any(NormalizedNode.class));
verifyUptodateSetToFalse(peerPath);
}
private void verifyUptodateSetToFalse(final YangInstanceIdentifier peerPath) {
final YangInstanceIdentifier path = peerPath.node(AdjRibIn.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(K4))
- .node(Attributes.QNAME).node(AdjRibInWriter.ATTRIBUTES_UPTODATE_FALSE.getNodeType());
+ .node(Attributes.QNAME).node(AdjRibInWriter.ATTRIBUTES_UPTODATE_FALSE.getNodeType());
Mockito.verify(this.tx).merge(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.eq(path), Mockito.eq(AdjRibInWriter.ATTRIBUTES_UPTODATE_FALSE));
}
private void verifyPeerSkeletonInsertedCorrectly(final YangInstanceIdentifier peerPath) {
Mockito.verify(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.eq(peerPath),
- Mockito.eq(this.writer.peerSkeleton(IdentifierUtils.peerKey(peerPath), this.peerIp)));
- }
-
- @Test
- public void testAnnounceNoneTransform() {
- this.writer = AdjRibInWriter.create(YangInstanceIdentifier.of(Rib.QNAME), PeerRole.Ebgp, Optional.of(SimpleRoutingPolicy.AnnounceNone), this.chain);
- assertNotNull(this.writer);
- final YangInstanceIdentifier peerPath = YangInstanceIdentifier.builder().node(Rib.QNAME).node(Peer.QNAME).nodeWithKey(Peer.QNAME,
- AdjRibInWriter.PEER_ID_QNAME, this.peerIp).build();
- this.writer.transform(new PeerId(this.peerIp), this.registry, this.tableTypes, ADD_PATH_TABLE_MAPS);
- verifyPeerSkeletonInsertedCorrectly(peerPath);
- // verify supported tables were not inserted for ipv4, AnnounceNone
- Mockito.verify(this.tx, never()).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.eq(peerPath.node(SupportedTables.QNAME)
- .node(RibSupportUtils.toYangKey(SupportedTables.QNAME, K4))), Mockito.any(NormalizedNode.class));
- verifyUptodateSetToFalse(peerPath);
-
+ Mockito.eq(this.writer.peerSkeleton(IdentifierUtils.peerKey(peerPath), this.peerIp)));
}
}
\ No newline at end of file
import java.util.ArrayList;
import java.util.List;
-import java.util.Optional;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.SendReceive;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.SimpleRoutingPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
public void testExportPolicyPeerTrackerImpl() throws Exception {
final ExportPolicyPeerTrackerImpl exportPpt = new ExportPolicyPeerTrackerImpl(PD, TABLE_KEY);
- TABLE_REGISTRATION.add(exportPpt.registerPeer(PEER_ID1, SendReceive.Both, YII_PEER1, PeerRole.RrClient, Optional.empty()));
- TABLE_REGISTRATION.add(exportPpt.registerPeer(PEER_ID2, SendReceive.Receive, YII_PEER2, PeerRole.Ibgp, Optional.of(SimpleRoutingPolicy.AnnounceNone)));
- TABLE_REGISTRATION.add(exportPpt.registerPeer(PEER_ID3, SendReceive.Send, YII_PEER3, PeerRole.Ebgp, Optional.of(SimpleRoutingPolicy.LearnNone)));
- TABLE_REGISTRATION.add(exportPpt.registerPeer(PEER_ID4, null, YII_PEER4, PeerRole.Ibgp, Optional.empty()));
+ TABLE_REGISTRATION.add(exportPpt.registerPeer(PEER_ID1, SendReceive.Both, YII_PEER1, PeerRole.RrClient));
+ TABLE_REGISTRATION.add(exportPpt.registerPeer(PEER_ID2, SendReceive.Receive, YII_PEER2, PeerRole.Ibgp));
+ TABLE_REGISTRATION.add(exportPpt.registerPeer(PEER_ID3, SendReceive.Send, YII_PEER3, PeerRole.Ebgp));
+ TABLE_REGISTRATION.add(exportPpt.registerPeer(PEER_ID4, null, YII_PEER4, PeerRole.Ibgp));
assertEquals(PeerRole.RrClient, exportPpt.getRole(YII_PEER1));
assertEquals(PeerRole.Ibgp, exportPpt.getRole(YII_PEER2));
assertTrue(exportPpt.getPeerGroup(PeerRole.Ibgp).containsPeer(PEER_ID4));
assertTrue(exportPpt.isTableSupported(PEER_ID1));
- assertFalse(exportPpt.isTableSupported(PEER_ID2));
+ assertTrue(exportPpt.isTableSupported(PEER_ID2));
assertTrue(exportPpt.isTableSupported(PEER_ID3));
assertTrue(exportPpt.isTableSupported(PEER_ID4));
assertFalse(exportPpt.isTableSupported(PEER_ID5));
import static org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createAfiSafi;
import static org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createNeighborExpected;
import static org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createTransport;
-import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getSimpleRoutingPolicy;
import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil.INSTANCE;
import com.google.common.collect.ImmutableList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.Config2Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.GlobalConfigAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.GlobalConfigAugmentationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.NeighborConfigAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.NeighborConfigAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.Protocol1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.ApplicationRibId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.SimpleRoutingPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
assertEquals(CLUSTER_ID.getValue(), OpenConfigMappingUtil.getClusterIdentifier(configBuilder.build()).getValue());
}
- @Test
- public void testGetSimpleRoutingPolicy() {
- final NeighborBuilder neighborBuilder = new NeighborBuilder();
- assertNull(getSimpleRoutingPolicy(neighborBuilder.build()));
- neighborBuilder.setConfig(new ConfigBuilder()
- .addAugmentation(NeighborConfigAugmentation.class,
- new NeighborConfigAugmentationBuilder().setSimpleRoutingPolicy(SimpleRoutingPolicy.LearnNone).build()).build());
- assertEquals(SimpleRoutingPolicy.LearnNone, getSimpleRoutingPolicy(neighborBuilder.build()));
- }
-
@Test
public void isAppNeighbor() {
assertFalse(OpenConfigMappingUtil.isApplicationPeer(new NeighborBuilder().setConfig(new ConfigBuilder().build()).build()));
@Test
public void fromBgpPeer() {
- final Neighbor result = OpenConfigMappingUtil.fromBgpPeer(FAMILIES, TABLE_TYPES, 30, NEIGHBOR_ADDRESS, true, null, PORT_NUMBER, 30, AS, PeerRole.Ibgp, null, this.tableTypeRegistry);
+ final Neighbor result = OpenConfigMappingUtil.fromBgpPeer(FAMILIES, TABLE_TYPES, 30, NEIGHBOR_ADDRESS, true, null, PORT_NUMBER, 30, AS, PeerRole.Ibgp, this.tableTypeRegistry);
final List<AfiSafi> afisafis = new ArrayList<>();
afisafis.add(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class)
.addAugmentation(AfiSafi1.class, new AfiSafi1Builder().setReceive(true).setSendMax(Shorts.checkedCast(ALL_PATHS)).build()).build());
package org.opendaylight.protocol.bgp.rib.spi;
-import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.protocol.concepts.AbstractRegistration;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.SendReceive;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.SimpleRoutingPolicy;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
/**
* @param sendReceive send receive add ath configuration of the peer
* @param peerPath Yii of the peer
* @param peerRole Role of the peer
- * @param simpleRoutingPolicy optional
- */
+l */
@Nonnull
AbstractRegistration registerPeer(@Nonnull PeerId peerId, @Nullable SendReceive sendReceive,
- @Nonnull YangInstanceIdentifier peerPath, @Nonnull PeerRole peerRole,
- @Nonnull Optional<SimpleRoutingPolicy> simpleRoutingPolicy);
+ @Nonnull YangInstanceIdentifier peerPath, @Nonnull PeerRole peerRole);
/**
* Returns PeerExportGroup per role.