import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.DefaultPolicyType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.apply.policy.group.apply.policy.Config;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
@Override
public Optional<Attributes> applyImportPolicies(final BGPRouteEntryImportParameters policyParameters,
- final Attributes attributes) {
+ final Attributes attributes, final Class<? extends AfiSafiType> afiSafi) {
RouteAttributeContainer currentAttributes = routeAttributeContainerFalse(attributes);
for (final String policyName : this.importPolicy) {
for (final Statement statement : this.statements.getUnchecked(policyName)) {
currentAttributes = this.policyRegistry
- .applyImportStatement(this.ribBaseParameters, policyParameters, currentAttributes, statement);
+ .applyImportStatement(this.ribBaseParameters, afiSafi, policyParameters, currentAttributes,
+ statement);
}
}
if (!currentAttributes.anyConditionSatisfied()) {
@Override
public Optional<Attributes> applyExportPolicies(final BGPRouteEntryExportParameters policyParameters,
- final Attributes attributes) {
+ final Attributes attributes, final Class<? extends AfiSafiType> afiSafi) {
RouteAttributeContainer currentAttributes = routeAttributeContainerFalse(attributes);
for (final String policyName : this.exportPolicy) {
for (final Statement statement : this.statements.getUnchecked(policyName)) {
currentAttributes = this.policyRegistry.applyExportStatement(
- this.ribBaseParameters, policyParameters, currentAttributes, statement);
+ this.ribBaseParameters, afiSafi, policyParameters, currentAttributes, statement);
}
}
if (!currentAttributes.anyConditionSatisfied()) {
--- /dev/null
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry;
+
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.attribute.conditions.AsPathLength;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpOriginAttrType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeComparison;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeEq;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeGe;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeLe;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.AsPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPref;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.MultiExitDisc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.Origin;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.as.path.Segments;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AsPathSegment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.CNextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.EmptyNextHopCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv6NextHopCase;
+
+/**
+ * Bgp Attribute Conditions Util per check conditions matchs.
+ *
+ * @author Claudio D. Gasparini
+ */
+final class BgpAttributeConditionsUtil {
+ private BgpAttributeConditionsUtil() {
+ throw new UnsupportedOperationException();
+ }
+
+ static boolean matchConditions(
+ final Class<? extends AfiSafiType> afiSafi,
+ final Attributes attributes,
+ final BgpConditions conditions) {
+ if (!matchAfiSafi(afiSafi, conditions.getAfiSafiIn())) {
+ return false;
+ }
+
+ if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
+ return false;
+ }
+
+ if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
+ return false;
+ }
+
+ if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
+ return false;
+ }
+
+ if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
+ return false;
+ }
+
+ if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean matchAfiSafi(
+ final Class<? extends AfiSafiType> afiSafi,
+ final List<Class<? extends AfiSafiType>> afiSafiIn) {
+ if (afiSafiIn == null) {
+ return true;
+ }
+ return afiSafiIn.contains(afiSafi);
+ }
+
+ private static boolean matchMED(final MultiExitDisc multiExitDisc, final Long med) {
+ if (multiExitDisc == null || med == null) {
+ return true;
+ }
+
+ return multiExitDisc.getMed().equals(med);
+ }
+
+ private static boolean matchOrigin(final Origin origin, final BgpOriginAttrType originEq) {
+ if (origin == null || originEq == null) {
+ return true;
+ }
+ return origin.getValue().getIntValue() == originEq.getIntValue();
+ }
+
+ private static boolean matchAsPathLength(final AsPath asPath, final AsPathLength asPathLength) {
+ if (asPath == null || asPathLength == null) {
+ return true;
+ }
+
+ final List<Segments> segments = asPath.getSegments();
+ int total = segments.stream().map(AsPathSegment::getAsSequence)
+ .filter(Objects::nonNull).mapToInt(List::size).sum();
+
+ if (total == 0) {
+ total = segments.stream().map(AsPathSegment::getAsSet)
+ .filter(Objects::nonNull).mapToInt(List::size).sum();
+ }
+
+ final Class<? extends AttributeComparison> comp = asPathLength.getOperator();
+ final long asPathLenght = asPathLength.getValue();
+ if (comp == AttributeEq.class) {
+ return total == asPathLenght;
+ } else if (comp == AttributeGe.class) {
+ return total >= asPathLenght;
+ } else if (comp == AttributeLe.class) {
+ return total <= asPathLenght;
+ }
+ return false;
+ }
+
+
+ private static boolean matchNextHopIn(final CNextHop nextHop, final List<IpAddress> nextHopIn) {
+ if (nextHop == null || nextHopIn == null || nextHop instanceof EmptyNextHopCase) {
+ return true;
+ }
+
+ IpAddress global;
+ if (nextHop instanceof Ipv4NextHopCase) {
+ global = new IpAddress(((Ipv4NextHopCase) nextHop).getIpv4NextHop().getGlobal());
+ } else {
+ global = new IpAddress(((Ipv6NextHopCase) nextHop).getIpv6NextHop().getGlobal());
+ }
+ return nextHopIn.contains(global);
+ }
+
+ private static boolean matchLocalPref(final LocalPref localPref, final Long localPrefEq) {
+ if (localPref == null || localPrefEq == null) {
+ return true;
+ }
+ return localPref.getPref().equals(localPrefEq);
+ }
+}
import com.google.common.base.Preconditions;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import java.util.Objects;
import javax.annotation.concurrent.GuardedBy;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsAugmentationPolicy;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpMatchConditions;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.Conditions1;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.attribute.conditions.AsPathLength;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchAsPathSet;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchCommunitySet;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchExtCommunitySet;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpOriginAttrType;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeComparison;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeEq;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeGe;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeLe;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Conditions;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.AsPath;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPref;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.MultiExitDisc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.Origin;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.as.path.Segments;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AsPathSegment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.CNextHop;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.EmptyNextHopCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv6NextHopCase;
import org.opendaylight.yangtools.concepts.AbstractRegistration;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-public final class BgpConditionsRegistry {
+final class BgpConditionsRegistry {
@GuardedBy("this")
private final Map<Class<? extends Augmentation<BgpConditions>>,
BgpConditionsAugmentationPolicy> bgpConditionsAugRegistry = new HashMap<>();
private final Map<Class<? extends ChildOf<BgpMatchConditions>>,
BgpConditionsPolicy> bgpConditionsRegistry = new HashMap<>();
- public AbstractRegistration registerBgpConditionsAugmentationPolicy(
+ AbstractRegistration registerBgpConditionsAugmentationPolicy(
final Class<? extends Augmentation<BgpConditions>> conditionPolicyClass,
final BgpConditionsAugmentationPolicy conditionPolicy) {
synchronized (this.bgpConditionsAugRegistry) {
}
}
- public <T extends ChildOf<BgpMatchConditions>, N> AbstractRegistration registerBgpConditionsPolicy(
+ <T extends ChildOf<BgpMatchConditions>, N> AbstractRegistration registerBgpConditionsPolicy(
final Class<T> conditionPolicyClass,
final BgpConditionsPolicy<T, N> conditionPolicy) {
synchronized (this.bgpConditionsRegistry) {
}
@SuppressWarnings("unchecked")
- public boolean matchExportConditions(
+ boolean matchExportConditions(
+ final Class<? extends AfiSafiType> afiSafi,
final RouteEntryBaseAttributes entryInfo,
final BGPRouteEntryExportParameters routeEntryExportParameters,
final Attributes attributes,
if (bgpConditionsAug != null) {
final BgpConditions bgpConditions = bgpConditionsAug.getBgpConditions();
- if (!matchExportCondition(entryInfo, routeEntryExportParameters, attributes,
+ if (!matchExportCondition(afiSafi, entryInfo, routeEntryExportParameters, attributes,
bgpConditions)) {
return false;
}
}
- public boolean matchImportConditions(
+ boolean matchImportConditions(
+ final Class<? extends AfiSafiType> afiSafi,
final RouteEntryBaseAttributes entryInfo,
final BGPRouteEntryImportParameters routeEntryImportParameters,
final Attributes attributes,
if (bgpConditionsAug != null) {
final BgpConditions bgpConditions = bgpConditionsAug.getBgpConditions();
synchronized (this) {
- if (!matchImportCondition(entryInfo, routeEntryImportParameters, attributes,
+ if (!matchImportCondition(afiSafi, entryInfo, routeEntryImportParameters, attributes,
bgpConditions)) {
return false;
}
@SuppressWarnings("unchecked")
private boolean matchImportCondition(
+ final Class<? extends AfiSafiType> afiSafi,
final RouteEntryBaseAttributes routeEntryInfo,
final BGPRouteEntryImportParameters routeEntryImportParameters,
final Attributes attributes,
final BgpConditions conditions) {
- if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
- return false;
- }
-
- if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
- return false;
- }
-
- if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
- return false;
- }
-
- if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
- return false;
- }
-
- if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
+ if (!BgpAttributeConditionsUtil.matchConditions(afiSafi, attributes, conditions)) {
return false;
}
@SuppressWarnings("unchecked")
private boolean matchExportCondition(
+ final Class<? extends AfiSafiType> afiSafi,
final RouteEntryBaseAttributes routeEntryInfo,
final BGPRouteEntryExportParameters routeEntryExportParameters,
final Attributes attributes,
final BgpConditions conditions) {
- if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
- return false;
- }
-
- if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
- return false;
- }
-
- if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
- return false;
- }
-
- if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
- return false;
- }
-
- if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
+ if (!BgpAttributeConditionsUtil.matchConditions(afiSafi, attributes, conditions)) {
return false;
}
return true;
}
-
- private boolean matchMED(final MultiExitDisc multiExitDisc, final Long med) {
- if (multiExitDisc == null || med == null) {
- return true;
- }
-
- return multiExitDisc.getMed().equals(med);
- }
-
- private boolean matchOrigin(final Origin origin, final BgpOriginAttrType originEq) {
- if (origin == null || originEq == null) {
- return true;
- }
- return origin.getValue().getIntValue() == originEq.getIntValue();
- }
-
- private boolean matchAsPathLength(final AsPath asPath, final AsPathLength asPathLength) {
- if (asPath == null || asPathLength == null) {
- return true;
- }
-
- final List<Segments> segments = asPath.getSegments();
- int total = segments.stream().map(AsPathSegment::getAsSequence)
- .filter(Objects::nonNull).mapToInt(List::size).sum();
-
- if (total == 0) {
- total = segments.stream().map(AsPathSegment::getAsSet)
- .filter(Objects::nonNull).mapToInt(List::size).sum();
- }
-
- final Class<? extends AttributeComparison> comp = asPathLength.getOperator();
- final long asPathLenght = asPathLength.getValue();
- if (comp == AttributeEq.class) {
- return total == asPathLenght;
- } else if (comp == AttributeGe.class) {
- return total >= asPathLenght;
- } else if (comp == AttributeLe.class) {
- return total <= asPathLenght;
- }
- return false;
- }
-
-
- private boolean matchNextHopIn(final CNextHop nextHop, final List<IpAddress> nextHopIn) {
- if (nextHop == null || nextHopIn == null || nextHop instanceof EmptyNextHopCase) {
- return true;
- }
-
- IpAddress global;
- if (nextHop instanceof Ipv4NextHopCase) {
- global = new IpAddress(((Ipv4NextHopCase) nextHop).getIpv4NextHop().getGlobal());
- } else {
- global = new IpAddress(((Ipv6NextHopCase) nextHop).getIpv6NextHop().getGlobal());
- }
- return nextHopIn.contains(global);
- }
-
- private boolean matchLocalPref(final LocalPref localPref, final Long localPrefEq) {
- if (localPref == null || localPrefEq == null) {
- return true;
- }
- return localPref.getPref().equals(localPrefEq);
- }
}
import java.util.HashMap;
import java.util.Map;
import javax.annotation.concurrent.GuardedBy;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsAugmentationPolicy;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsPolicy;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpMatchConditions;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Conditions;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yangtools.concepts.AbstractRegistration;
@GuardedBy("this")
private final Map<Class<? extends Augmentation<Conditions>>, ConditionsAugPolicy> conditionsRegistry
= new HashMap<>();
- //TODO Implement match prefix
- //private final GenericConditionPolicyHandler genericConditionHandler;
private final BgpConditionsRegistry bgpConditionsRegistry = new BgpConditionsRegistry();
- ConditionsRegistryImpl(final DataBroker databroker) {
- // this.genericConditionHandler = new GenericConditionPolicyHandler(databroker);
+ ConditionsRegistryImpl() {
}
AbstractRegistration registerConditionPolicy(final Class<? extends Augmentation<Conditions>> conditionPolicyClass,
@SuppressWarnings("unchecked")
boolean matchExportConditions(
+ final Class<? extends AfiSafiType> afiSafi,
final RouteEntryBaseAttributes entryInfo,
final BGPRouteEntryExportParameters routeEntryExportParameters,
final Attributes attributes,
final Conditions conditions) {
if (!this.bgpConditionsRegistry
- .matchExportConditions(entryInfo, routeEntryExportParameters, attributes, conditions)) {
+ .matchExportConditions(afiSafi, entryInfo, routeEntryExportParameters, attributes, conditions)) {
return false;
}
@SuppressWarnings("unchecked")
boolean matchImportConditions(
- final RouteEntryBaseAttributes entryInfo,
+ final Class<? extends AfiSafiType> afiSafi, final RouteEntryBaseAttributes entryInfo,
final BGPRouteEntryImportParameters routeEntryImportParameters,
final Attributes attributes,
final Conditions conditions) {
- /*if (!this.genericConditionHandler
- .matchImportCondition(routeEntryImportParameters, conditions)) {
- return false;
- }*/
-
if (!this.bgpConditionsRegistry
- .matchImportConditions(entryInfo, routeEntryImportParameters, attributes, conditions)) {
+ .matchImportConditions(afiSafi, entryInfo, routeEntryImportParameters, attributes, conditions)) {
return false;
}
import static org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer.routeAttributeContainerTrue;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.ActionsAugPolicy;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionAugPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpMatchConditions;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.BgpActions;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Conditions;
private final ConditionsRegistryImpl conditionsRegistry;
private final ActionsRegistryImpl actionsRegistry;
- public StatementRegistry(final DataBroker databroker) {
- this.conditionsRegistry = new ConditionsRegistryImpl(databroker);
+ public StatementRegistry() {
+ this.conditionsRegistry = new ConditionsRegistryImpl();
this.actionsRegistry = new ActionsRegistryImpl();
}
@Override
public RouteAttributeContainer applyExportStatement(
final RouteEntryBaseAttributes routeEntryInfo,
+ final Class<? extends AfiSafiType> afiSafi,
final BGPRouteEntryExportParameters routeEntryExportParameters,
final RouteAttributeContainer attributes,
final Statement statement) {
final Attributes att = attributes.getAttributes();
if (att == null || !this.conditionsRegistry.matchExportConditions(
+ afiSafi,
routeEntryInfo,
routeEntryExportParameters,
att,
@Override
public RouteAttributeContainer applyImportStatement(
final RouteEntryBaseAttributes routeEntryInfo,
+ final Class<? extends AfiSafiType> afiSafi,
final BGPRouteEntryImportParameters routeEntryImportParameters,
final RouteAttributeContainer attributes,
final Statement statement) {
final Attributes att = attributes.getAttributes();
if (att == null || !this.conditionsRegistry.matchImportConditions(
+ afiSafi,
routeEntryInfo,
routeEntryImportParameters,
attributes.getAttributes(),
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
/**
* Apply statement to BGP Route Attributes (Export Policy).
*
* @param routeEntryInfo contains route Entry Info(AS, ClusterId, OriginatorId)
+ * @param afiSafi Afi Safi Type
* @param baseExportParameters export Parameters
* @param attributes route attributes
* @param statement Statement containing Conditions/Actions
@Nonnull
RouteAttributeContainer applyExportStatement(
@Nonnull RouteEntryBaseAttributes routeEntryInfo,
+ @Nonnull Class<? extends AfiSafiType> afiSafi,
@Nonnull BGPRouteEntryExportParameters baseExportParameters,
@Nonnull RouteAttributeContainer attributes,
@Nonnull Statement statement);
* Apply statement to BGP Route Attributes (Import Policy).
*
* @param routeEntryInfo contains route Entry Info(AS, ClusterId, OriginatorId)
+ * @param afiSafi Afi Safi Type
* @param routeBaseParameters route base parameters
* @param attributes route attributes
* @param statement Statement containing Conditions/Actions
@Nonnull
RouteAttributeContainer applyImportStatement(
@Nonnull RouteEntryBaseAttributes routeEntryInfo,
+ @Nonnull Class<? extends AfiSafiType> afiSafi,
@Nonnull BGPRouteEntryImportParameters routeBaseParameters,
@Nonnull RouteAttributeContainer attributes,
@Nonnull Statement statement);
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
- <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
-
<odl:specific-reference-list id="statementActivatorList"
interface="org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.StatementProviderActivator"/>
<bean id="statementRegistry"
class="org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.StatementRegistry">
- <argument ref="dataBroker"/>
</bean>
<bean id="statementProviderActivator"
@Override
public void setUp() throws Exception {
super.setUp();
- this.statementRegistry = new StatementRegistry(getDataBroker());
+ this.statementRegistry = new StatementRegistry();
}
protected List<Statement> loadStatement(final String policyName) throws ExecutionException, InterruptedException {
import org.mockito.Mock;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
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.message.rev180329.path.attributes.Attributes;
= routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
import org.mockito.Mock;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setAsPath(asPath.build()).build());
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setAsPath(asPath.build()).build());
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setAsPath(asPath.build()).build());
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
import org.mockito.Mock;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
.build());
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
.build());
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
.build());
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
.build());
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
+ this.exportParameters,
+ attributeContainer,
+ statement);
+ assertNull(result.getAttributes());
+ }
+
+ @Test
+ public void testAfiSafiIn() {
+ Statement statement = this.basicStatements.stream()
+ .filter(st -> st.getName().equals("afi-safi-in-test")).findFirst().get();
+ RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
+ .setLocalPref(new LocalPrefBuilder().setPref(350L).build())
+ .build());
+
+ RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
+ this.baseAttributes,
+ IPV6UNICAST.class,
+ this.exportParameters,
+ attributeContainer,
+ statement);
+ assertNotNull(result.getAttributes());
+
+
+ attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
+ .setLocalPref(new LocalPrefBuilder().setPref(100L).build())
+ .build());
+ result = this.statementRegistry.applyExportStatement(
+ this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
<reject-route/>
</actions>
</statement>
+ <statement>
+ <name>afi-safi-in-test</name>
+ <conditions>
+ <bgp-conditions xmlns="http://openconfig.net/yang/bgp-policy">
+ <afi-safi-in xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-in>
+ </bgp-conditions>
+ </conditions>
+ <actions>
+ <reject-route/>
+ </actions>
+ </statement>
<statement>
<name>multiple-append-test</name>
<conditions>
@Override
public void setUp() throws Exception {
super.setUp();
- this.statementRegistry = new StatementRegistry(getDataBroker());
+ this.statementRegistry = new StatementRegistry();
final StatementActivator activator = new StatementActivator(getDataBroker());
activator.start(this.statementRegistry);
}
import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole;
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attInput,
statement);
import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole;
RouteAttributeContainer result = this.statementRegistry.applyImportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.importParameters,
attInput,
statement);
import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
AsNumber.getDefaultInstance("65"))).build())).build()).build());
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
AsNumber.getDefaultInstance("65"))).build())).build()).build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
)).build()).build());
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
AsNumber.getDefaultInstance("65"))).build())).build()).build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
AsNumber.getDefaultInstance("200"))).build())).build()).build());
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getFromPeerId();
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getFromPeerId();
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getToPeerId();
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getToPeerId();
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(this.multipleCom);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(this.multipleCom);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(this.multipleExtCom);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(this.multipleExtCom);
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
this.baseAttributes,
+ IPV4UNICAST.class,
this.exportParameters,
attributeContainer,
statement);
final BGPRouteEntryExportParameters baseExp = new BGPRouteEntryExportParametersImpl(
this.peerTracker.getPeer(path.getPeerId()), toPeer);
final Optional<Attributes> effAttrib = routeEntryDep.getRoutingPolicies()
- .applyExportPolicies(baseExp, path.getAttributes());
+ .applyExportPolicies(baseExp, path.getAttributes(), routeEntryDep.getAfiSafType());
if (effAttrib.isPresent()) {
Identifier routeIdentifier = ribSupport.createRouteListKey(destPeerSupAddPath
? path.getPathId() : NON_PATH_ID_VALUE, routeKey);
final BGPRouteEntryExportParameters baseExp
= new BGPRouteEntryExportParametersImpl(fromPeer, toPeer);
effAttrib = routeEntryDep.getRoutingPolicies()
- .applyExportPolicies(baseExp, attributes);
+ .applyExportPolicies(baseExp, attributes, routeEntryDep.getAfiSafType());
}
Route newRoute = null;
InstanceIdentifier ribOutRoute = null;
final BGPRouteEntryExportParameters routeEntry = new BGPRouteEntryExportParametersImpl(
this.peerTracker.getPeer(this.bestPath.getPeerId()), toPeer);
final Optional<Attributes> effAttrib = entryDep.getRoutingPolicies()
- .applyExportPolicies(routeEntry, this.bestPath.getAttributes());
+ .applyExportPolicies(routeEntry, this.bestPath.getAttributes(), entryDep.getAfiSafType());
if (effAttrib.isPresent()) {
final Route route = createRoute(ribSupport,
entryInfo.getRouteKey(), this.bestPath.getPathId(), this.bestPath);
private void fillAdjRibsOut(
@Nullable final Attributes attributes,
@Nullable final Route route,
- final Identifier routeKey, final PeerId fromPeerId,
+ final Identifier routeKey,
+ final PeerId fromPeerId,
final RouteEntryDependenciesContainer routeEntryDep,
final WriteTransaction tx) {
/*
if (fromPeer != null && attributes != null) {
final BGPRouteEntryExportParameters routeEntry
= new BGPRouteEntryExportParametersImpl(fromPeer, toPeer);
- effAttr = routingPolicies.applyExportPolicies(routeEntry, attributes);
+ effAttr = routingPolicies.applyExportPolicies(routeEntry, attributes, routeEntryDep.getAfiSafType());
}
final InstanceIdentifier ribOutTarget
= ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), routeKey);
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry;
import org.opendaylight.protocol.bgp.rib.impl.state.BGPSessionStateImpl;
private final YangInstanceIdentifier adjRibsInId;
private final InstanceIdentifier<AdjRibOut> peerRibOutIId;
private final KeyedInstanceIdentifier<Peer, PeerKey> peerIId;
+ private final BGPTableTypeRegistryConsumer tableTypeRegistry;
private DOMTransactionChain chain;
private DOMTransactionChain writerChain;
private EffectiveRibInWriter effectiveRibInWriter;
void register();
}
- public ApplicationPeer(final ApplicationRibId applicationRibId, final Ipv4Address ipAddress, final RIB rib) {
+ public ApplicationPeer(
+ final BGPTableTypeRegistryConsumer tableTypeRegistry,
+ final ApplicationRibId applicationRibId, final Ipv4Address ipAddress, final RIB rib) {
super(rib, applicationRibId.getValue(), APP_PEER_GROUP, PeerRole.Internal,
new IpAddress(ipAddress), Collections.emptySet());
+ this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
final RIB targetRib = requireNonNull(rib);
this.rawIdentifier = InetAddresses.forString(ipAddress.getValue()).getAddress();
this.adjRibsInId = targetRib.getYangRibId().node(Peer.QNAME)
this.adjRibInWriter = this.adjRibInWriter.transform(this.peerId, this.peerPath, context, localTables,
Collections.emptyMap(), registerAppPeerListener);
this.effectiveRibInWriter = new EffectiveRibInWriter(this, this.rib,
- this.rib.createPeerChain(this), this.peerIId, localTables);
+ this.rib.createPeerChain(this), this.peerIId, localTables, this.tableTypeRegistry
+ );
this.effectiveRibInWriter.init();
this.bgpSessionState.registerMessagesCounter(this);
this.trackerRegistration = this.rib.getPeerTracker().registerPeer(this);
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.impl.message.update.LocalPreferenceAttributeParser;
private final RIB rib;
private final Map<TablesKey, AdjRibOutListener> adjRibOutListenerSet = new HashMap<>();
private final RpcProviderRegistry rpcRegistry;
+ private final BGPTableTypeRegistryConsumer tableTypeRegistry;
private InstanceIdentifier<AdjRibOut> peerRibOutIId;
@GuardedBy("this")
private AbstractRegistration trackerRegistration;
private boolean sessionUp;
public BGPPeer(
+ final BGPTableTypeRegistryConsumer tableTypeRegistry,
final IpAddress neighborAddress,
final String peerGroupName,
final RIB rib,
final Set<TablesKey> afiSafisGracefulAdvertized) {
super(rib, Ipv4Util.toStringIP(neighborAddress), peerGroupName, role, clusterId,
localAs, neighborAddress, afiSafisAdvertized, afiSafisGracefulAdvertized);
+ this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
this.rib = requireNonNull(rib);
this.rpcRegistry = rpcRegistry;
this.chain = rib.createPeerDOMChain(this);
}
BGPPeer(
+ final BGPTableTypeRegistryConsumer tableTypeRegistry,
final IpAddress neighborAddress,
final RIB rib,
final PeerRole role,
final RpcProviderRegistry rpcRegistry,
final Set<TablesKey> afiSafisAdvertized,
final Set<TablesKey> afiSafisGracefulAdvertized) {
- this(neighborAddress, null, rib, role, null, null, rpcRegistry, afiSafisAdvertized,
- afiSafisGracefulAdvertized);
+ this(tableTypeRegistry, neighborAddress, null, rib, role, null, null, rpcRegistry,
+ afiSafisAdvertized, afiSafisGracefulAdvertized);
}
final Set<TablesKey> setTables = advertizedTableTypes.stream().map(t -> new TablesKey(t.getAfi(), t.getSafi()))
.collect(Collectors.toSet());
this.tables = ImmutableSet.copyOf(setTables);
- this.effRibInWriter = new EffectiveRibInWriter(this, this.rib, this.rib.createPeerChain(this),
- peerIId, this.tables);
+ this.effRibInWriter = new EffectiveRibInWriter(this, this.rib,
+ this.rib.createPeerChain(this),
+ peerIId, this.tables, this.tableTypeRegistry);
registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
this.peerRibOutIId = peerIId.child(AdjRibOut.class);
this.effRibInWriter.init();
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry;
import org.opendaylight.protocol.bgp.rib.impl.state.peer.PrefixesInstalledCounters;
private final Map<TablesKey, LongAdder> prefixesInstalled;
private final BGPRibRoutingPolicy ribPolicies;
private final BGPRouteEntryImportParameters peerImportParameters;
+ private final BGPTableTypeRegistryConsumer tableTypeRegistry;
- EffectiveRibInWriter(final BGPRouteEntryImportParameters peer, final RIB rib,
+ EffectiveRibInWriter(
+ final BGPRouteEntryImportParameters peer,
+ final RIB rib,
final BindingTransactionChain chain,
final KeyedInstanceIdentifier<Peer, PeerKey> peerIId,
- @Nonnull final Set<TablesKey> tables) {
+ final Set<TablesKey> tables,
+ final BGPTableTypeRegistryConsumer tableTypeRegistry
+ ) {
this.registry = requireNonNull(rib.getRibSupportContext());
this.chain = requireNonNull(chain);
this.peerIId = requireNonNull(peerIId);
this.prefixesReceived = buildPrefixesTables(tables);
this.ribPolicies = requireNonNull(rib.getRibPolicies());
this.databroker = requireNonNull(rib.getDataBroker());
+ this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
this.peerImportParameters = peer;
}
final InstanceIdentifier routeIID = ribSupport.createRouteIdentifier(tablePath, routeKey);
CountersUtil.increment(this.prefixesReceived.get(tk), tk);
final Optional<Attributes> effAtt = this.ribPolicies
- .applyImportPolicies(this.peerImportParameters, route.getAttributes());
+ .applyImportPolicies(this.peerImportParameters, route.getAttributes(),
+ tableTypeRegistry.getAfiSafiType(ribSupport.getTablesKey()).get());
if (effAtt.isPresent()) {
CountersUtil.increment(this.prefixesInstalled.get(tk), tk);
tx.put(LogicalDatastoreType.OPERATIONAL, routeIID, route);
import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
import org.opendaylight.protocol.bgp.rib.spi.RouterIds;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.Rib;
final BGPRibRoutingPolicy ribPolicies,
final BGPPeerTracker peerTracker,
final TablesKey tablesKey,
+ final Class<? extends AfiSafiType> afiSafiType,
final PathSelectionMode pathSelectionMode) {
this.chain = requireNonNull(chain);
this.ribIId = requireNonNull(ribIId);
this.pathSelectionMode = pathSelectionMode;
this.entryDep = new RouteEntryDependenciesContainerImpl(this.ribSupport, ribPolicies,
- tablesKey, this.locRibTableIID);
+ tablesKey, afiSafiType, this.locRibTableIID);
init();
}
- public static LocRibWriter create(@Nonnull final RIBSupport ribSupport,
+ public static LocRibWriter create(
+ @Nonnull final RIBSupport ribSupport,
@Nonnull final TablesKey tablesKey,
+ @Nonnull final Class<? extends AfiSafiType> afiSafiType,
@Nonnull final BindingTransactionChain chain,
@Nonnull final KeyedInstanceIdentifier<Rib, RibKey> ribIId,
@Nonnull final AsNumber ourAs,
@Nonnull final BGPPeerTracker peerTracker,
@Nonnull final PathSelectionMode pathSelectionStrategy) {
return new LocRibWriter(ribSupport, chain, ribIId, ourAs.getValue(), dataBroker, ribPolicies,
- peerTracker, tablesKey, pathSelectionStrategy);
+ peerTracker, tablesKey, afiSafiType, pathSelectionStrategy);
}
@SuppressWarnings("unchecked")
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
import org.opendaylight.protocol.bgp.mode.impl.base.BasePathSelectionModeFactory;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
import org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
private final YangInstanceIdentifier yangRibId;
private final RIBSupportContextRegistryImpl ribContextRegistry;
private final CodecsRegistryImpl codecsRegistry;
+ private final BGPTableTypeRegistryConsumer tableTypeRegistry;
@GuardedBy("this")
private ClusterSingletonServiceRegistration registration;
private final DOMDataBrokerExtension domService;
@GuardedBy("this")
private boolean isServiceInstantiated;
- public RIBImpl(final RibId ribId,
+ public RIBImpl(
+ final BGPTableTypeRegistryConsumer tableTypeRegistry,
+ final RibId ribId,
final AsNumber localAs,
final BgpId localBgpId,
final RIBExtensionConsumerContext extensions,
) {
super(InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(requireNonNull(ribId))),
localBgpId, localAs);
+ this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
this.localAs = requireNonNull(localAs);
this.bgpIdentifier = requireNonNull(localBgpId);
this.dispatcher = requireNonNull(dispatcher);
final LocRibWriter locRibWriter = LocRibWriter.create(
ribSupport,
key,
+ this.tableTypeRegistry.getAfiSafiType(key).get(),
txChain,
getInstanceIdentifier(),
this.localAs,
import static java.util.Objects.requireNonNull;
+import javax.annotation.Nonnull;
import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
import org.opendaylight.protocol.bgp.rib.spi.entry.RouteEntryDependenciesContainer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
private final TablesKey tablesKey;
private final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget;
private final BGPRibRoutingPolicy routingPolicies;
+ private final Class<? extends AfiSafiType> afiSafiType;
public RouteEntryDependenciesContainerImpl(
final RIBSupport ribSupport,
final BGPRibRoutingPolicy routingPolicies,
final TablesKey tablesKey,
+ final Class<? extends AfiSafiType> afiSafiType,
final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget) {
this.ribSupport = requireNonNull(ribSupport);
this.tablesKey = requireNonNull(tablesKey);
+ this.afiSafiType = requireNonNull(afiSafiType);
this.routingPolicies = requireNonNull(routingPolicies);
this.locRibTarget = requireNonNull(locRibTarget);
}
return this.tablesKey;
}
+ @Override
+ public Class<? extends AfiSafiType> getAfiSafType() {
+ return this.afiSafiType;
+ }
+
@Override
public KeyedInstanceIdentifier<Tables, TablesKey> getLocRibTableTarget() {
return this.locRibTarget;
"Previous peer instance was not closed.");
this.currentConfiguration = neighbor;
this.bgpAppPeerSingletonService = new BgpAppPeerSingletonService(rib, createAppRibId(neighbor),
- neighbor.getNeighborAddress().getIpv4Address());
+ neighbor.getNeighborAddress().getIpv4Address(), tableTypeRegistry);
}
@Override
@GuardedBy("this")
private boolean isServiceInstantiated;
- BgpAppPeerSingletonService(final RIB rib, final ApplicationRibId appRibId, final Ipv4Address neighborAddress) {
- this.applicationPeer = new ApplicationPeer(appRibId, neighborAddress, rib);
+ BgpAppPeerSingletonService(final RIB rib, final ApplicationRibId appRibId, final Ipv4Address neighborAddress,
+ final BGPTableTypeRegistryConsumer tableTypeRegistry) {
+ this.applicationPeer = new ApplicationPeer(tableTypeRegistry, appRibId, neighborAddress, rib);
this.appRibId = appRibId;
this.dataTreeChangeService = rib.getService();
}
neighborLocalAs = globalAs;
}
- this.bgpPeer = new BGPPeer(this.neighborAddress, peerGroupName, rib, role, clusterId, neighborLocalAs,
- BgpPeer.this.rpcRegistry, afiSafisAdvertized, Collections.emptySet());
+ this.bgpPeer = new BGPPeer(tableTypeRegistry, this.neighborAddress, peerGroupName, rib, role, clusterId,
+ neighborLocalAs, BgpPeer.this.rpcRegistry, afiSafisAdvertized, Collections.emptySet());
this.prefs = new BGPSessionPreferences(neighborLocalAs, hold, rib.getBgpIdentifier(),
neighborRemoteAs, bgpParameters, getPassword(keyMapping));
this.activeConnection = OpenConfigMappingUtil.isActive(neighbor, peerGroup);
this.extensions.getClassLoadingStrategy());
return new RIBImpl(
+ tableTypeRegistry,
new RibId(bgpInstanceName),
this.asNumber,
new BgpId(this.routerId),
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.protocol.bgp.inet.RIBActivator;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
import org.opendaylight.protocol.bgp.parser.impl.BGPActivator;
return connectPeer(peer, clientDispatcher);
}
- protected static BGPPeer configurePeer(final Ipv4Address peerAddress, final RIBImpl ribImpl,
- final BgpParameters bgpParameters, final PeerRole peerRole, final BGPPeerRegistry bgpPeerRegistry) {
+ protected static BGPPeer configurePeer(final BGPTableTypeRegistryConsumer tableRegistry, final Ipv4Address peerAddress, final RIBImpl ribImpl,
+ final BgpParameters bgpParameters, final PeerRole peerRole, final BGPPeerRegistry bgpPeerRegistry) {
final IpAddress ipAddress = new IpAddress(peerAddress);
- final BGPPeer bgpPeer = new BGPPeer(new IpAddress(peerAddress), ribImpl, peerRole, null,
+ final BGPPeer bgpPeer = new BGPPeer(tableRegistry, new IpAddress(peerAddress), ribImpl, peerRole, null,
AFI_SAFIS_ADVERTIZED, Collections.emptySet());
final List<BgpParameters> tlvs = Lists.newArrayList(bgpParameters);
bgpPeerRegistry.addPeer(ipAddress, bgpPeer,
mockedMethods();
doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider)
.registerClusterSingletonService(any(ClusterSingletonService.class));
- this.rib = new RIBImpl(new RibId("test"), new AsNumber(5L), RIB_ID, context,
+ this.rib = new RIBImpl(this.tableRegistry, new RibId("test"), new AsNumber(5L), RIB_ID, context,
this.dispatcher, codecsRegistry, this.dom, getDataBroker(), this.policies, this.peerTracker,
localTables, Collections.singletonMap(new TablesKey(AFI, SAFI),
BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker)));
final Map<TablesKey, PathSelectionMode> pathTables
= ImmutableMap.of(TABLES_KEY, new AllPathSelection(this.peerTracker));
- this.ribImpl = new RIBImpl(new RibId("test-rib"), AS_NUMBER, BGP_ID,
+ this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, BGP_ID,
this.ribExtension, this.serverDispatcher, this.codecsRegistry,
getDomBroker(), getDataBroker(), this.policies, this.peerTracker, TABLES_TYPE, pathTables);
final BgpParameters nonAddPathParams = createParameter(false);
final BgpParameters addPathParams = createParameter(true);
- final BGPPeer peer1 = configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+ final BGPPeer peer1 = configurePeer(this.tableRegistry, PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
- configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
- configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener());
final SimpleSessionListener listener4 = new SimpleSessionListener();
- final BGPPeer peer4 = configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+ final BGPPeer peer4 = configurePeer(this.tableRegistry, PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
BGPPeerState peer4State = peer4.getPeerState();
assertNull(peer4State.getGroupId());
final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
final SimpleSessionListener listener5 = new SimpleSessionListener();
- configurePeer(PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
final BGPSessionImpl session5 = createPeerSession(PEER5, addPathParams, listener5);
checkPeersPresentOnDataStore(5);
assertEquals(1L, ribState.getTotalPrefixesCount());
final SimpleSessionListener listener6 = new SimpleSessionListener();
- final BGPPeer peer6 = configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+ final BGPPeer peer6 = configurePeer(this.tableRegistry, PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
checkPeersPresentOnDataStore(6);
checkReceivedMessages(listener6, 1);
final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(tk,
BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker));
- this.ribImpl = new RIBImpl(new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension,
+ this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID),
+ this.ribExtension,
this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
this.peerTracker, TABLES_TYPE, pathTables);
this.ribImpl.instantiateServiceInstance();
public void testUseCase1() throws Exception {
final BgpParameters nonAddPathParams = createParameter(false);
- configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
- configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
- configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session3 = createPeerSession(PEER3,nonAddPathParams, new SimpleSessionListener());
final SimpleSessionListener listener4 = new SimpleSessionListener();
- configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
final SimpleSessionListener listener5 = new SimpleSessionListener();
- configurePeer(PEER5, this.ribImpl, nonAddPathParams, PeerRole.Ebgp, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER5, this.ribImpl, nonAddPathParams, PeerRole.Ebgp, this.serverRegistry);
final BGPSessionImpl session5 = createPeerSession(PEER5, nonAddPathParams, listener5);
checkPeersPresentOnDataStore(5);
assertEquals(UPD_NA_200_EBGP, listener5.getListMsg().get(1));
final SimpleSessionListener listener6 = new SimpleSessionListener();
- configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
checkPeersPresentOnDataStore(6);
final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(tk,
new AddPathBestNPathSelection(2L, this.peerTracker));
- this.ribImpl = new RIBImpl(new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension,
+ this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID),
+ this.ribExtension,
this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
this.peerTracker, TABLES_TYPE, pathTables);
final BgpParameters nonAddPathParams = createParameter(false);
final BgpParameters addPathParams = createParameter(true);
- configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
- configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
- configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener());
final SimpleSessionListener listener4 = new SimpleSessionListener();
- configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
final SimpleSessionListener listener5 = new SimpleSessionListener();
- configurePeer(PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
final BGPSessionImpl session5 = createPeerSession(PEER5, addPathParams, listener5);
checkPeersPresentOnDataStore(5);
assertEquals(UPD_100, listener5.getListMsg().get(0));
final SimpleSessionListener listener6 = new SimpleSessionListener();
- configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+ configurePeer(this.tableRegistry, PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
checkPeersPresentOnDataStore(6);
checkReceivedMessages(listener6, 1);
*/
package org.opendaylight.protocol.bgp.rib.impl;
+import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import java.util.Collections;
+import java.util.Optional;
import org.junit.Before;
import org.mockito.Mock;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.BGPRibRoutingPolicyFactoryImpl;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.BGPRibRoutingPolicyFactory;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.AbstractStatementRegistryConsumerTest;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.DefaultPolicyType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.apply.policy.group.apply.policy.Config;
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.rib.rev180329.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ClusterIdentifier;
protected BGPRibRoutingPolicy policies;
protected BGPRibRoutingPolicyFactory policyProvider;
@Mock
+ protected BGPTableTypeRegistryConsumer tableRegistry;
+ @Mock
private Config config;
@Before
doReturn(DefaultPolicyType.REJECTROUTE).when(this.config).getDefaultExportPolicy();
doReturn(Collections.singletonList("default-odl-import-policy")).when(this.config).getImportPolicy();
doReturn(Collections.singletonList("default-odl-export-policy")).when(this.config).getExportPolicy();
+ doReturn(Optional.of(IPV4UNICAST.class)).when(this.tableRegistry).getAfiSafiType(any(TablesKey.class));
this.policyProvider = new BGPRibRoutingPolicyFactoryImpl(getDataBroker(), this.statementRegistry);
this.policies = this.policyProvider.buildBGPRibPolicy(AS, this.bgpID, this.ci, this.config);
final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(LinkstateAddressFamily.class,
LinkstateSubsequentAddressFamily.class));
- final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2, this.dispatcher,
- this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, tables,
- Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
+ final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2,
+ this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker,
+ tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
.createBestPathSelectionStrategy(this.peerTracker)));
rib.instantiateServiceInstance();
assertTablesExists(tables);
rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
- final BGPPeer peer = new BGPPeer(this.localAddress, rib, PeerRole.Ibgp, null, Collections.emptySet(),
- Collections.emptySet());
+ final BGPPeer peer = new BGPPeer(this.tableRegistry, this.localAddress, rib, PeerRole.Ibgp, null,
+ Collections.emptySet(), Collections.emptySet());
peer.instantiateServiceInstance();
final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
reg.close();
public void testWithoutLinkstate() throws ReadFailedException {
final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class,
UnicastSubsequentAddressFamily.class));
- final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1, this.dispatcher,
- this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, tables,
- Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
- .createBestPathSelectionStrategy(this.peerTracker)));
+ final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1,
+ this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker,
+ tables, Collections.singletonMap(TABLE_KEY,
+ BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker)));
rib.instantiateServiceInstance();
rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
assertTablesExists(tables);
- final BGPPeer peer = new BGPPeer(this.localAddress, rib, PeerRole.Ibgp, null, Collections.emptySet(),
- Collections.emptySet());
+ final BGPPeer peer = new BGPPeer(this.tableRegistry, this.localAddress, rib, PeerRole.Ibgp, null,
+ Collections.emptySet(), Collections.emptySet());
peer.instantiateServiceInstance();
final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
reg.close();
final Ipv4Prefix first = new Ipv4Prefix("127.0.0.2/32");
final Ipv4Prefix second = new Ipv4Prefix("127.0.0.1/32");
final Ipv4Prefix third = new Ipv4Prefix("127.0.0.3/32");
- this.peer = new ApplicationPeer(new ApplicationRibId(this.neighborAddress.getIpv4Address().getValue()),
+ this.peer = new ApplicationPeer(this.tableRegistry,
+ new ApplicationRibId(this.neighborAddress.getIpv4Address().getValue()),
this.neighborAddress.getIpv4Address(), getRib());
this.peer.instantiateServiceInstance(null, null);
final YangInstanceIdentifier base = getRib().getYangRibId().node(LocRib.QNAME)
@Test
public void testClassicPeer() throws Exception {
- this.classic = new BGPPeer(this.neighborAddress, getRib(), PeerRole.Ibgp, null,
+ this.classic = new BGPPeer(this.tableRegistry, this.neighborAddress, getRib(), PeerRole.Ibgp, null,
Collections.emptySet(), Collections.emptySet());
this.classic.instantiateServiceInstance();
this.mockSession();
assertEquals(3, this.routes.size());
//create new peer so that it gets advertized routes from RIB
- final BGPPeer testingPeer = new BGPPeer(this.neighborAddress, getRib(), PeerRole.Ibgp, null,
+ final BGPPeer testingPeer = new BGPPeer(this.tableRegistry, this.neighborAddress, getRib(), PeerRole.Ibgp, null,
Collections.emptySet(), Collections.emptySet());
testingPeer.instantiateServiceInstance();
testingPeer.onSessionUp(this.session);
public void testHandleMessageAfterException() {
final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY,
BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker));
- final RIBImpl ribImpl = new RIBImpl( new RibId(RIB_ID), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension,
+ final RIBImpl ribImpl = new RIBImpl(this.tableRegistry, new RibId(RIB_ID), AS_NUMBER, new BgpId(RIB_ID),
+ this.ribExtension,
this.serverDispatcher, this.codecsRegistry, this.domBroker, getDataBroker(), this.policies,
this.peerTracker, ImmutableList.of(this.ipv4tt), pathTables);
ribImpl.instantiateServiceInstance();
ribImpl.onGlobalContextUpdated(this.schemaService.getGlobalContext());
- final BGPPeer bgpPeer = new BGPPeer(neighbor, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED,
- Collections.emptySet());
+ final BGPPeer bgpPeer = new BGPPeer(this.tableRegistry, neighbor, ribImpl, PeerRole.Ibgp, null,
+ AFI_SAFIS_ADVERTIZED, Collections.emptySet());
bgpPeer.instantiateServiceInstance();
final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen,
this.classicOpen.getHoldTimer(), null);
public void testUseCase1() {
final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY,
BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker));
- final RIBImpl ribImpl = new RIBImpl(new RibId(RIB_ID), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension,
+ final RIBImpl ribImpl = new RIBImpl(this.tableRegistry, new RibId(RIB_ID), AS_NUMBER, new BgpId(RIB_ID),
+ this.ribExtension,
this.serverDispatcher, this.codecsRegistry, this.domBroker, getDataBroker(), this.policies,
this.peerTracker, ImmutableList.of(this.ipv4tt), pathTables);
ribImpl.instantiateServiceInstance();
ribImpl.onGlobalContextUpdated(this.schemaService.getGlobalContext());
- final BGPPeer bgpPeer = new BGPPeer(neighbor, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED,
- Collections.emptySet());
+ final BGPPeer bgpPeer = new BGPPeer(this.tableRegistry, neighbor, ribImpl, PeerRole.Ibgp, null,
+ AFI_SAFIS_ADVERTIZED, Collections.emptySet());
bgpPeer.instantiateServiceInstance();
final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen,
this.classicOpen.getHoldTimer(), null);
<groupId>${project.groupId}</groupId>
<artifactId>bgp-rib-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.bgpcep</groupId>
+ <artifactId>bgp-openconfig-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>ietf-inet-types-2013-07-15</artifactId>
private final NodeIdentifier rdNid;
protected final BindingNormalizedNodeSerializer mappingService;
protected final YangInstanceIdentifier routeDefaultYii;
+ private final TablesKey tk;
/**
* Default constructor. Requires the QName of the container augmented under the routes choice
this.listClass = requireNonNull(listClass);
this.routeQname = BindingReflections.findQName(listClass).withModule(module);
this.routesListIdentifier = new NodeIdentifier(this.routeQname);
- final TablesKey tk = new TablesKey(afiClass, safiClass);
+ this.tk = new TablesKey(afiClass, safiClass);
//FIXME Use Route Case IId instead of Tables IId.
this.emptyRoutes = (ChoiceNode) ((MapEntryNode) this.mappingService
.toNormalizedNode(TABLES_II, new TablesBuilder().setKey(tk)
.node(this.routeQname).build();
}
+ @Override
+ public final TablesKey getTablesKey() {
+ return this.tk;
+ }
+
@Override
public final Class<C> routesCaseClass() {
return this.cazeClass;
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.bgp.rib.spi;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-
-/**
- * Interface implemented to be extended by RibSupport.
- * This interface exposes methods to access to Add Path information
- * By default we implement non supported Multiple Path therefore
- * 0 Path Id is returned and null PathArgument
- * Deprecated: All families should support additional path
- */
-@Deprecated
-interface AddPathRibSupport {
- /**
- * Construct a PathArgument to an AddPathRoute.
- *
- * @param pathId The path identifier
- * @param routeId PathArgument leaf path
- * @return routeId PathArgument + pathId or Null in case Add-path is not supported
- */
- @Deprecated
- @Nullable
- default PathArgument getRouteIdAddPath(long pathId, @Nonnull PathArgument routeId) {
- return null;
- }
-
- /**
- * Create a new Path Argument for route Key removing remove Path Id from key.
- * For extension which do not support Multiple Path this step is not required.
- *
- * @param routeKey routeKey Path Argument
- * @return new route Key
- */
- @Deprecated
- default NodeIdentifierWithPredicates createRouteKeyPathArgument(@Nonnull NodeIdentifierWithPredicates routeKey) {
- return null;
- }
-}
@Nonnull
R createRoute(@Nullable R route, String routeKey, @Nullable long pathId, @Nonnull Attributes attributes);
+ /**
+ * Returns TablesKey which we are providing support.
+ *
+ * @return TablesKey
+ */
+ TablesKey getTablesKey();
+
interface ApplyRoute {
void apply(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier base,
@Nonnull NodeIdentifierWithPredicates routeKey,
import javax.annotation.Nonnull;
import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
@Nonnull
TablesKey getLocalTablesKey();
+ /**
+ * Returns the AfiSafiType(AFI/SAFI) corresponding to the Route Entry.
+ *
+ * @return TablesKey
+ */
+ @Nonnull
+ Class<? extends AfiSafiType> getAfiSafType();
+
/**
* Returns the loc-rib table to be updated and to which corresponds this Route Entry.
import java.util.Optional;
import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
/**
*
* @param policyParameters containing attributes and sender peer information
* @param attributes Route attributes
+ * @param afiSafType Afi Safi Type
* @return modified route attributes after apply policies
*/
@Nonnull
Optional<Attributes> applyImportPolicies(
@Nonnull BGPRouteEntryImportParameters policyParameters,
- @Nonnull Attributes attributes
+ @Nonnull Attributes attributes,
+ @Nonnull Class<? extends AfiSafiType> afiSafType
);
/**
*
* @param policyParameters containing attributes and sender/receiver peer information
* @param attributes Route attributes
+ * @param afiSafType Afi Safi Type
* @return modified route attributes after apply policies
*/
@Nonnull
Optional<Attributes> applyExportPolicies(
@Nonnull BGPRouteEntryExportParameters policyParameters,
- @Nonnull Attributes attributes
+ @Nonnull Attributes attributes,
+ @Nonnull Class<? extends AfiSafiType> afiSafType
);
}