use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class MatchBgpNeighborSetTest method testMatchFromBgpNeighborInvert.
@Test
public void testMatchFromBgpNeighborInvert() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("reject-from-neighbor-invert-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
doReturn(new PeerId("bgp://42.42.42.42")).when(this.exportParameters).getFromPeerId();
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getFromPeerId();
result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class MatchBgpNeighborSetTest method testMatchToBgpNeighborInvert.
@Test
public void testMatchToBgpNeighborInvert() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("reject-to-neighbor-invert-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
doReturn(new PeerId("bgp://127.0.0.2")).when(this.exportParameters).getFromPeerId();
doReturn(new PeerId("bgp://42.42.42.42")).when(this.exportParameters).getToPeerId();
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getToPeerId();
result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class SetExtCommunityHandler method inlineSetExtComm.
private static Attributes inlineSetExtComm(final Attributes attributes, final List<ExtendedCommunities> actionExtCommunities, final BgpSetCommunityOptionType options) {
final AttributesBuilder newAtt = new AttributesBuilder(attributes);
if (options.equals(BgpSetCommunityOptionType.REPLACE)) {
return newAtt.setExtendedCommunities(actionExtCommunities).build();
}
final List<ExtendedCommunities> actualComm;
if (attributes.getCommunities() != null) {
actualComm = new ArrayList<>(attributes.getExtendedCommunities());
} else {
actualComm = new ArrayList<>();
}
switch(options) {
case ADD:
actualComm.addAll(actionExtCommunities);
break;
case REMOVE:
actualComm.removeAll(actionExtCommunities);
break;
default:
throw new IllegalArgumentException("Option Type not Recognized!");
}
return newAtt.setExtendedCommunities(actualComm).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class MatchExtComTest method testExtComAll.
@Test
public void testExtComAll() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("ext-community-all-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setExtendedCommunities(Arrays.asList(new ExtendedCommunitiesBuilder().setExtendedCommunity(new As4RouteOriginExtendedCommunityCaseBuilder().setAs4RouteOriginExtendedCommunity(new As4RouteOriginExtendedCommunityBuilder().setAs4SpecificCommon(new As4SpecificCommonBuilder().setAsNumber(AsNumber.getDefaultInstance("65000")).setLocalAdministrator(Uint16.valueOf(123)).build()).build()).build()).build(), new ExtendedCommunitiesBuilder().setExtendedCommunity(new EncapsulationCaseBuilder().setEncapsulationExtendedCommunity(new EncapsulationExtendedCommunityBuilder().setTunnelType(Vxlan).build()).build()).build())).build());
result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class MatchExtComTest method testExtComAny.
@Test
public void testExtComAny() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("ext-community-any-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setExtendedCommunities(Collections.singletonList(new ExtendedCommunitiesBuilder().setExtendedCommunity(new As4RouteOriginExtendedCommunityCaseBuilder().setAs4RouteOriginExtendedCommunity(new As4RouteOriginExtendedCommunityBuilder().setAs4SpecificCommon(new As4SpecificCommonBuilder().setAsNumber(AsNumber.getDefaultInstance("65000")).setLocalAdministrator(Uint16.valueOf(123)).build()).build()).build()).build())).build());
result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
}
Aggregations