Search in sources :

Example 1 with BgpSetCommunityOptionType

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpSetCommunityOptionType 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 BgpSetCommunityOptionType

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpSetCommunityOptionType in project bgpcep by opendaylight.

the class SetCommunityHandler method inlineSetComm.

private Attributes inlineSetComm(final Attributes attributes, final List<Communities> actionCommunities, final BgpSetCommunityOptionType options) {
    final AttributesBuilder newAtt = new AttributesBuilder(attributes);
    if (options.equals(BgpSetCommunityOptionType.REPLACE)) {
        return newAtt.setCommunities(actionCommunities).build();
    }
    final List<Communities> actualComm;
    if (attributes.getCommunities() != null) {
        actualComm = new ArrayList<>(attributes.getCommunities());
    } else {
        actualComm = new ArrayList<>();
    }
    switch(options) {
        case ADD:
            actualComm.addAll(actionCommunities);
            break;
        case REMOVE:
            actualComm.removeAll(actionCommunities);
            break;
        default:
            throw new IllegalArgumentException("Option Type not Recognized!");
    }
    return newAtt.setCommunities(actualComm).build();
}
Also used : Communities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Communities) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)

Example 3 with BgpSetCommunityOptionType

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpSetCommunityOptionType 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 4 with BgpSetCommunityOptionType

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpSetCommunityOptionType in project bgpcep by opendaylight.

the class SetExtCommunityHandler method inlineSetExtComm.

private 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();
}
Also used : ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)

Aggregations

AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)4 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 Communities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Communities)2 ExtendedCommunities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities)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 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)1