Search in sources :

Example 6 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.

the class ClusterIdAttributeParserTest method testParserAttribute.

@Test
public void testParserAttribute() throws Exception {
    final List<ClusterIdentifier> list = new ArrayList<>();
    final Ipv4AddressNoZone ip1 = new Ipv4AddressNoZone("192.168.1.1");
    final Ipv4AddressNoZone ip2 = new Ipv4AddressNoZone("192.168.1.2");
    list.add(new ClusterIdentifier(ip1));
    list.add(new ClusterIdentifier(ip2));
    final Attributes clusterId = new AttributesBuilder().setClusterId(new ClusterIdBuilder().setCluster(list).build()).build();
    final ByteBuf output = Unpooled.buffer();
    this.parser.serializeAttribute(clusterId, output);
    assertArrayEquals(CLUSTER_ID_BYTES, ByteArray.getAllBytes(output));
    AttributesBuilder clusterIdOutput = new AttributesBuilder();
    this.parser.parseAttribute(Unpooled.wrappedBuffer(ByteArray.cutBytes(CLUSTER_ID_BYTES, 3)), clusterIdOutput, null);
    assertEquals(clusterId, clusterIdOutput.build());
}
Also used : Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) ArrayList(java.util.ArrayList) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 7 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.

the class AbstractAddPathTest method createSimpleUpdate.

private static Update createSimpleUpdate(final Ipv4Prefix prefix, final PathId pathId, final ClusterIdentifier clusterId, final long localPreference) {
    final AttributesBuilder attBuilder = new AttributesBuilder();
    attBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(localPreference)).build());
    attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
    attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
    attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.ZERO).build());
    if (clusterId != null) {
        attBuilder.setClusterId(new ClusterIdBuilder().setCluster(Collections.singletonList(clusterId)).build());
        attBuilder.setOriginatorId(new OriginatorIdBuilder().setOriginator(new Ipv4AddressNoZone(clusterId)).build());
    }
    addAttributeAugmentation(attBuilder, prefix, pathId);
    return new UpdateBuilder().setAttributes(attBuilder.build()).build();
}
Also used : LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder) AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) OriginBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder) MultiExitDiscBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.MultiExitDiscBuilder) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) OriginatorIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginatorIdBuilder)

Example 8 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.

the class MatchClusterIdSetHandler method matchClusterIdCondition.

private boolean matchClusterIdCondition(final ClusterIdentifier localClusterId, final ClusterId clusterId, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.match.cluster.id.set.condition.grouping.MatchClusterIdSetCondition matchClusterIdSetCondition) {
    final ClusterIdSet clusterIdSet = this.sets.getUnchecked(StringUtils.substringBetween(matchClusterIdSetCondition.getClusterIdSet(), "=\"", "\""));
    if (clusterIdSet == null) {
        return false;
    }
    final MatchSetOptionsType matchOption = matchClusterIdSetCondition.getMatchSetOptions();
    if (clusterId != null) {
        List<ClusterIdentifier> newList = new ArrayList<>();
        if (clusterIdSet.getClusterId() != null) {
            newList.addAll(clusterIdSet.getClusterId());
        }
        if (clusterIdSet.getLocal() != null) {
            newList.add(localClusterId);
        }
        final List<ClusterIdentifier> matchClusterList = clusterId.getCluster();
        if (matchOption.equals(MatchSetOptionsType.ALL)) {
            return matchClusterList.containsAll(newList) && newList.containsAll(matchClusterList);
        }
        final boolean noneInCommon = Collections.disjoint(matchClusterList, newList);
        if (matchOption.equals(MatchSetOptionsType.ANY)) {
            return !noneInCommon;
        } else if (matchOption.equals(MatchSetOptionsType.INVERT)) {
            return noneInCommon;
        }
    } else if (matchOption.equals(MatchSetOptionsType.INVERT)) {
        return true;
    }
    return false;
}
Also used : MatchSetOptionsType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsType) ArrayList(java.util.ArrayList) ClusterIdSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.cluster.id.set.ClusterIdSet) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier)

Example 9 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.

the class RibImpl method createRib.

private synchronized RIBImpl createRib(final Global global, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
    afiSafi = getAfiSafiWithDefault(global.getAfiSafis(), true).values();
    final Config globalConfig = global.getConfig();
    asNumber = globalConfig.getAs();
    routerId = IetfInetUtil.INSTANCE.ipv4AddressNoZoneFor(globalConfig.getRouterId());
    clusterId = getGlobalClusterIdentifier(globalConfig);
    final Map<TablesKey, PathSelectionMode> pathSelectionModes = OpenConfigMappingUtil.toPathSelectionMode(afiSafi, tableTypeRegistry).entrySet().stream().collect(Collectors.toMap(entry -> new TablesKey(entry.getKey().getAfi(), entry.getKey().getSafi()), Map.Entry::getValue));
    final BGPRibRoutingPolicy ribPolicy = policyProvider.buildBGPRibPolicy(asNumber.getValue().toJava(), routerId, clusterId, RoutingPolicyUtil.getApplyPolicy(global.getApplyPolicy()));
    return new RIBImpl(tableTypeRegistry, ribId, asNumber, new BgpId(routerId), extensionProvider, dispatcher, codecsRegistry, domBroker, ribPolicy, toTableTypes(afiSafi, tableTypeRegistry), pathSelectionModes);
}
Also used : OpenConfigMappingUtil.getGlobalClusterIdentifier(org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getGlobalClusterIdentifier) LoggerFactory(org.slf4j.LoggerFactory) BGPDispatcher(org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher) BGPStateProviderRegistry(org.opendaylight.protocol.bgp.rib.spi.state.BGPStateProviderRegistry) IetfInetUtil(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) Map(java.util.Map) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) RIBImpl(org.opendaylight.protocol.bgp.rib.impl.RIBImpl) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) OpenConfigMappingUtil.toTableTypes(org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.toTableTypes) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Collection(java.util.Collection) Set(java.util.Set) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId) Collectors(java.util.stream.Collectors) Preconditions.checkState(com.google.common.base.Preconditions.checkState) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) GuardedBy(org.checkerframework.checker.lock.qual.GuardedBy) DOMTransactionChain(org.opendaylight.mdsal.dom.api.DOMTransactionChain) BGPRibRoutingPolicyFactory(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.BGPRibRoutingPolicyFactory) Registration(org.opendaylight.yangtools.concepts.Registration) BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) RIB(org.opendaylight.protocol.bgp.rib.impl.spi.RIB) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DOMTransactionChainListener(org.opendaylight.mdsal.dom.api.DOMTransactionChainListener) Config(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) BGPRibRoutingPolicy(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpId) Objects.requireNonNull(java.util.Objects.requireNonNull) RIBSupportContextRegistry(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry) CodecsRegistry(org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry) BGPPeerTracker(org.opendaylight.protocol.bgp.rib.spi.BGPPeerTracker) Global(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global) Rib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.Rib) Logger(org.slf4j.Logger) BGPRibState(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) RibKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.RibKey) DOMDataTreeChangeService(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService) Futures(com.google.common.util.concurrent.Futures) OpenConfigMappingUtil.getAfiSafiWithDefault(org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getAfiSafiWithDefault) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) BGPTableTypeRegistryConsumer(org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId) RIBExtensionConsumerContext(org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext) BGPRibStateProvider(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibStateProvider) FluentFuture(com.google.common.util.concurrent.FluentFuture) BGPRibRoutingPolicy(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpId) Config(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) Map(java.util.Map) RIBImpl(org.opendaylight.protocol.bgp.rib.impl.RIBImpl)

Example 10 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.

the class ExportAttributeTestUtil method createClusterIdInput.

private static ClusterId createClusterIdInput() {
    final ClusterIdentifier cluster1 = new ClusterIdentifier(new Ipv4AddressNoZone("1.1.1.1"));
    final ClusterIdentifier cluster2 = new ClusterIdentifier(new Ipv4AddressNoZone("1.1.1.2"));
    return new ClusterIdBuilder().setCluster(Arrays.asList(cluster1, cluster2)).build();
}
Also used : Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder)

Aggregations

ClusterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier)8 ClusterIdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder)7 ByteBuf (io.netty.buffer.ByteBuf)5 ArrayList (java.util.ArrayList)5 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)5 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)5 Test (org.junit.Test)3 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 FluentFuture (com.google.common.util.concurrent.FluentFuture)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Collection (java.util.Collection)1 Map (java.util.Map)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 GuardedBy (org.checkerframework.checker.lock.qual.GuardedBy)1 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)1 DOMDataBroker (org.opendaylight.mdsal.dom.api.DOMDataBroker)1