Search in sources :

Example 6 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.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 7 with ClusterId

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

the class ExportAttributeTestUtil method createClusterIdInput.

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

Example 8 with ClusterId

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

the class SetClusterIdPrependHandler method prependClusterId.

private Attributes prependClusterId(final Attributes attributes, final ClusterIdentifier clusterId) {
    final AttributesBuilder newAtt = new AttributesBuilder(attributes);
    final List<ClusterIdentifier> newClusterList = new ArrayList<>();
    newClusterList.add(clusterId);
    if (attributes.getClusterId() != null && !attributes.getClusterId().getCluster().isEmpty()) {
        final List<ClusterIdentifier> oldList = attributes.getClusterId().getCluster();
        newClusterList.addAll(oldList);
    }
    return newAtt.setClusterId(new ClusterIdBuilder().setCluster(newClusterList).build()).build();
}
Also used : ArrayList(java.util.ArrayList) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterIdBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)

Example 9 with ClusterId

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

the class ClusterIdAttributeParserTest method testParseEmptyAttribute.

@Test
public void testParseEmptyAttribute() {
    final Attributes clusterId = new AttributesBuilder().setClusterId(new ClusterIdBuilder().build()).build();
    final ByteBuf output = Unpooled.buffer();
    this.parser.serializeAttribute(clusterId, output);
    assertEquals(Unpooled.buffer(), output);
}
Also used : Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterIdBuilder) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Aggregations

ClusterIdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterIdBuilder)7 ClusterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier)7 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)5 ByteBuf (io.netty.buffer.ByteBuf)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)4 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 MatchSetOptionsType (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsType)1 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)1 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder)1 ClusterId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterId)1 LocalPrefBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.LocalPrefBuilder)1 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginBuilder)1 OriginatorIdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginatorIdBuilder)1 ClusterIdSet (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.cluster.id.set.ClusterIdSet)1