use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class NonTransitiveAttributesFilterHandler method filterAttributes.
private Attributes filterAttributes(final Attributes attributes) {
final AttributesBuilder builder = new AttributesBuilder();
builder.setCNextHop(attributes.getCNextHop());
builder.setOrigin(attributes.getOrigin());
builder.setAsPath(attributes.getAsPath());
builder.setCommunities(attributes.getCommunities());
final List<UnrecognizedAttributes> oldAtt = attributes.getUnrecognizedAttributes();
if (oldAtt != null) {
builder.setUnrecognizedAttributes(attributes.getUnrecognizedAttributes().stream().filter(UnrecognizedAttributes::isTransitive).collect(Collectors.toList()));
}
final List<ExtendedCommunities> oldExt = attributes.getExtendedCommunities();
if (oldExt != null) {
builder.setExtendedCommunities(oldExt.stream().filter(ExtendedCommunity::isTransitive).collect(Collectors.toList()));
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class ActionsRegistryImpl method applyExportAction.
@SuppressWarnings("unchecked")
Attributes applyExportAction(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryExportParameters routeEntryExportParameters, final Attributes attributes, final Actions actions) {
requireNonNull(attributes);
if (actions.getRouteDisposition() instanceof RejectRoute) {
return null;
}
Attributes attributesUpdated = attributes;
final Actions1 augmentation = actions.getAugmentation(Actions1.class);
if (augmentation != null && augmentation.getBgpActions() != null) {
final BgpActions bgpAction = augmentation.getBgpActions();
final SetAsPathPrepend asPrependAction = bgpAction.getSetAsPathPrepend();
final Long localPrefPrependAction = bgpAction.getSetLocalPref();
final BgpOriginAttrType localOriginAction = bgpAction.getSetRouteOrigin();
final BgpSetMedType medAction = bgpAction.getSetMed();
final BgpNextHopType nhAction = bgpAction.getSetNextHop();
final SetCommunity setCommunityAction = bgpAction.getSetCommunity();
final SetExtCommunity setExtCommunityAction = bgpAction.getSetExtCommunity();
if (asPrependAction != null) {
attributesUpdated = this.bgpActions.get(SetAsPathPrepend.class).applyExportAction(routeEntryInfo, routeEntryExportParameters, attributesUpdated, asPrependAction);
}
if (attributesUpdated == null) {
return null;
}
if (setCommunityAction != null) {
attributesUpdated = this.bgpActions.get(SetCommunity.class).applyExportAction(routeEntryInfo, routeEntryExportParameters, attributesUpdated, setCommunityAction);
}
if (attributesUpdated == null) {
return null;
}
if (setExtCommunityAction != null) {
attributesUpdated = this.bgpActions.get(SetExtCommunity.class).applyExportAction(routeEntryInfo, routeEntryExportParameters, attributesUpdated, setExtCommunityAction);
}
boolean updated = false;
if (localPrefPrependAction != null || localOriginAction != null || medAction != null || nhAction != null) {
updated = true;
}
if (updated) {
final AttributesBuilder attributesUpdatedBuilder = new AttributesBuilder(attributes);
if (localPrefPrependAction != null) {
attributesUpdatedBuilder.setLocalPref(new LocalPrefBuilder().setPref(localPrefPrependAction).build());
}
if (localOriginAction != null) {
attributesUpdatedBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.forValue(localOriginAction.getIntValue())).build());
}
if (medAction != null) {
attributesUpdatedBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(medAction.getUint32()).build());
}
if (nhAction != null) {
final IpAddress address = nhAction.getIpAddress();
if (address != null) {
CNextHop nhNew;
if (address.getIpv4Address() != null) {
nhNew = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(address.getIpv4Address()).build()).build();
} else {
nhNew = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(address.getIpv6Address()).build()).build();
}
attributesUpdatedBuilder.setCNextHop(nhNew);
}
}
attributesUpdated = attributesUpdatedBuilder.build();
}
final Map<Class<? extends Augmentation<?>>, Augmentation<?>> bgpConditionsAug = BindingReflections.getAugmentations(bgpAction);
if (bgpConditionsAug != null) {
for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry : bgpConditionsAug.entrySet()) {
final BgpActionAugPolicy handler = this.bgpAugActionsRegistry.get(entry.getKey());
if (handler == null) {
continue;
} else if (attributesUpdated == null) {
return null;
}
attributesUpdated = handler.applyExportAction(routeEntryInfo, routeEntryExportParameters, attributesUpdated, entry.getValue());
}
}
}
if (attributesUpdated == null) {
return null;
}
// Export Actions Aug
final Map<Class<? extends Augmentation<?>>, Augmentation<?>> conditionsAug = BindingReflections.getAugmentations(actions);
if (conditionsAug == null) {
return attributes;
}
for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry : conditionsAug.entrySet()) {
final ActionsAugPolicy handler = this.actionsRegistry.get(entry.getKey());
if (attributesUpdated == null) {
return null;
} else if (handler == null) {
continue;
}
attributesUpdated = handler.applyExportAction(routeEntryInfo, routeEntryExportParameters, attributesUpdated, (Augmentation<Actions>) entry.getValue());
}
return attributesUpdated;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class ActionsRegistryImpl method applyImportAction.
@SuppressWarnings("unchecked")
Attributes applyImportAction(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryImportParameters routeParameters, final Attributes attributes, final Actions actions) {
if (actions.getRouteDisposition() instanceof RejectRoute) {
return null;
}
Attributes attributesUpdated = attributes;
final Actions1 augmentation = actions.getAugmentation(Actions1.class);
if (augmentation != null && augmentation.getBgpActions() != null) {
final BgpActions bgpAction = augmentation.getBgpActions();
final SetCommunity setCommunityAction = bgpAction.getSetCommunity();
final SetExtCommunity setExtCommunityAction = bgpAction.getSetExtCommunity();
final SetAsPathPrepend asPrependAction = bgpAction.getSetAsPathPrepend();
if (asPrependAction != null) {
attributesUpdated = this.bgpActions.get(asPrependAction.getClass()).applyImportAction(routeEntryInfo, routeParameters, attributesUpdated, asPrependAction);
}
if (attributesUpdated == null) {
return null;
}
if (setCommunityAction != null) {
attributesUpdated = this.bgpActions.get(SetCommunity.class).applyImportAction(routeEntryInfo, routeParameters, attributesUpdated, setCommunityAction);
}
if (attributesUpdated == null) {
return null;
}
if (setExtCommunityAction != null) {
attributesUpdated = this.bgpActions.get(SetExtCommunity.class).applyImportAction(routeEntryInfo, routeParameters, attributesUpdated, setExtCommunityAction);
}
if (attributesUpdated == null) {
return null;
}
final Map<Class<? extends Augmentation<?>>, Augmentation<?>> bgpConditionsAug = BindingReflections.getAugmentations(bgpAction);
if (bgpConditionsAug == null) {
return attributes;
}
for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry : bgpConditionsAug.entrySet()) {
final BgpActionAugPolicy handler = this.bgpAugActionsRegistry.get(entry.getKey());
if (handler == null) {
continue;
} else if (attributesUpdated == null) {
return null;
}
attributesUpdated = handler.applyImportAction(routeEntryInfo, routeParameters, attributesUpdated, entry.getValue());
}
if (attributesUpdated == null) {
return null;
}
}
// Augmented Actions
final Map<Class<? extends Augmentation<?>>, Augmentation<?>> conditionsAug = BindingReflections.getAugmentations(actions);
if (conditionsAug == null) {
return attributesUpdated;
}
for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry : conditionsAug.entrySet()) {
final ActionsAugPolicy handler = this.actionsRegistry.get(entry.getKey());
if (handler == null) {
continue;
} else if (attributesUpdated == null) {
return null;
}
attributesUpdated = handler.applyImportAction(routeEntryInfo, routeParameters, attributesUpdated, (Augmentation<Actions>) entry.getValue());
}
return attributesUpdated;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class BgpConditionsRegistry method matchImportConditions.
public boolean matchImportConditions(final RouteEntryBaseAttributes entryInfo, final BGPRouteEntryImportParameters routeEntryImportParameters, final Attributes attributes, final Conditions conditions) {
final Conditions1 bgpConditionsAug = conditions.getAugmentation(Conditions1.class);
if (bgpConditionsAug != null) {
final BgpConditions bgpConditions = bgpConditionsAug.getBgpConditions();
synchronized (this) {
if (!matchImportCondition(entryInfo, routeEntryImportParameters, attributes, bgpConditions)) {
return false;
}
}
final Map<Class<? extends Augmentation<?>>, Augmentation<?>> bgpAug = BindingReflections.getAugmentations(bgpConditions);
for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry : bgpAug.entrySet()) {
final BgpConditionsAugmentationPolicy handler = this.bgpConditionsAugRegistry.get(entry.getKey());
if (handler == null) {
continue;
}
if (!handler.matchImportCondition(entryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), entry.getValue())) {
return false;
}
}
}
return true;
}
Aggregations