Search in sources :

Example 1 with Inline

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Inline in project bgpcep by opendaylight.

the class SetCommunityHandler method setComm.

private Attributes setComm(final Attributes attributes, final SetCommunityMethod setCommunityMethod, final BgpSetCommunityOptionType options) {
    if (setCommunityMethod instanceof Inline) {
        final Inline inline = (Inline) setCommunityMethod;
        final List<Communities> list = inline.getCommunities().stream().map(ge -> new CommunitiesBuilder().setAsNumber(ge.getAsNumber()).setSemantics(ge.getSemantics()).build()).collect(Collectors.toList());
        return inlineSetComm(attributes, list, options);
    }
    return referenceSetComm(attributes, ((Reference) setCommunityMethod).getCommunitySetRef(), options);
}
Also used : Communities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Communities) BGPRouteEntryExportParameters(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters) SetCommunity(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.SetCommunity) BgpActionPolicy(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionPolicy) AbstractCommunityHandler(org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.AbstractCommunityHandler) BgpSetCommunityOptionType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpSetCommunityOptionType) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) ArrayList(java.util.ArrayList) SetCommunityMethod(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.SetCommunityMethod) List(java.util.List) Inline(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method.Inline) BGPRouteEntryImportParameters(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters) RouteEntryBaseAttributes(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes) Reference(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method.Reference) CommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.CommunitiesBuilder) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) CommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.CommunitiesBuilder) Communities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Communities) Inline(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method.Inline)

Example 2 with Inline

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Inline in project bgpcep by opendaylight.

the class SetExtCommunityHandler method setExtComm.

private Attributes setExtComm(final Attributes attributes, final SetExtCommunityMethod setExtCommunityMethod, final BgpSetCommunityOptionType options) {
    if (setExtCommunityMethod instanceof Inline) {
        final Inline inline = (Inline) setExtCommunityMethod;
        final List<ExtendedCommunities> list = inline.getExtCommunityMember().stream().map(ge -> new ExtendedCommunitiesBuilder().setExtendedCommunity(ge.getExtendedCommunity()).setTransitive(ge.isTransitive()).build()).collect(Collectors.toList());
        return inlineSetExtComm(attributes, list, options);
    }
    return referenceSetExtComm(attributes, ((Reference) setExtCommunityMethod).getExtCommunitySetRef(), options);
}
Also used : BGPRouteEntryExportParameters(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters) Inline(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Inline) BgpActionPolicy(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionPolicy) ExtendedCommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder) BgpSetCommunityOptionType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpSetCommunityOptionType) SetExtCommunity(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.SetExtCommunity) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) ArrayList(java.util.ArrayList) Reference(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference) ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) List(java.util.List) AbstractExtCommunityHandler(org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.AbstractExtCommunityHandler) SetExtCommunityMethod(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.SetExtCommunityMethod) BGPRouteEntryImportParameters(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters) RouteEntryBaseAttributes(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) Inline(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Inline) ExtendedCommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder)

Example 3 with Inline

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Inline in project bgpcep by opendaylight.

the class SetCommunityTest method testInlineReplace.

@Test
public void testInlineReplace() {
    Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("set-community-inline-replace-test")).findFirst().get();
    RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
    RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
    assertEquals(this.multipleCom, result.getAttributes());
}
Also used : Statement(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement) RouteAttributeContainer(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 4 with Inline

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Inline in project bgpcep by opendaylight.

the class SetCommunityTest method testInlineAdd.

@Test
public void testInlineAdd() {
    Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("set-community-inline-add-test")).findFirst().get();
    RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
    RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
    assertEquals(this.multipleCom, result.getAttributes());
}
Also used : Statement(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement) RouteAttributeContainer(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 5 with Inline

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Inline in project bgpcep by opendaylight.

the class SetExtCommunityTest method testInlineAdd.

@Test
public void testInlineAdd() {
    Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("set-ext-community-inline-add-test")).findFirst().get();
    RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
    RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
    assertEquals(this.multipleExtCom, result.getAttributes());
}
Also used : Statement(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement) RouteAttributeContainer(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)6 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)6 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)6 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 StringUtils (org.apache.commons.lang3.StringUtils)2 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)2 RouteEntryBaseAttributes (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes)2 BgpActionPolicy (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionPolicy)2 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)2 BGPRouteEntryImportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters)2 BgpSetCommunityOptionType (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpSetCommunityOptionType)2 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)2 AbstractCommunityHandler (org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.AbstractCommunityHandler)1 AbstractExtCommunityHandler (org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.AbstractExtCommunityHandler)1 SetCommunity (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.SetCommunity)1 SetExtCommunity (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.SetExtCommunity)1 SetCommunityMethod (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.SetCommunityMethod)1