use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder in project bgpcep by opendaylight.
the class AppendActionTest method testAppend.
@Test
public void testAppend() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("multiple-append-test")).findFirst().get();
final RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
final Attributes expected = new AttributesBuilder().setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build()).setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("4.5.6.7")).build()).build()).setLocalPref(new LocalPrefBuilder().setPref(100L).build()).setMultiExitDisc(new MultiExitDiscBuilder().setMed(15L).build()).build();
assertEquals(expected, result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder in project bgpcep by opendaylight.
the class PcepStateUtilsTest method createPcepSessionState.
private PcepSessionState createPcepSessionState() {
final LocalPref pref = new LocalPrefBuilder().setKeepalive((short) 30).setDeadtimer((short) 120).setIpAddress(IP_ADDRESS).setSessionId(0).addAugmentation(PcepEntityIdStatsAug.class, new PcepEntityIdStatsAugBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build()).build();
final PeerCapabilities capa = new PeerCapabilitiesBuilder().addAugmentation(StatefulCapabilitiesStatsAug.class, new StatefulCapabilitiesStatsAugBuilder().setStateful(true).setInstantiation(true).setActive(true).build()).build();
final ReplyTime reply = new ReplyTimeBuilder().setAverageTime(1L).setMaxTime(3L).setMinTime(2L).build();
final ErrorMessages errorMsg = new ErrorMessagesBuilder().setReceivedErrorMsgCount(1L).setSentErrorMsgCount(2L).build();
final StatefulMessagesStatsAug statefulMsg = new StatefulMessagesStatsAugBuilder().setLastReceivedRptMsgTimestamp(1512043769L).setSentUpdMsgCount(1L).setReceivedRptMsgCount(2L).setSentInitMsgCount(3L).build();
final Messages messages = new MessagesBuilder().setLastSentMsgTimestamp(1512043828L).setUnknownMsgReceived(1).setSentMsgCount(5L).setReceivedMsgCount(4L).setReplyTime(reply).setErrorMessages(errorMsg).addAugmentation(StatefulMessagesStatsAug.class, statefulMsg).build();
return new PcepSessionStateBuilder().setSynchronized(true).setSessionDuration("0:00:01:26").setDelegatedLspsCount(1).setLocalPref(pref).setPeerPref(new PeerPrefBuilder(pref).build()).setPeerCapabilities(capa).setMessages(messages).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder in project bgpcep by opendaylight.
the class TopologyStatsRpcServiceImplTest method createTopologySessionState.
private static PcepSessionState createTopologySessionState() {
final ReplyTime replyTime = new ReplyTimeBuilder().setAverageTime(Uint32.ONE).setMaxTime(Uint32.valueOf(3)).setMinTime(Uint32.TWO).build();
final ErrorMessages errorMsg = new ErrorMessagesBuilder().setReceivedErrorMsgCount(Uint32.ONE).setSentErrorMsgCount(Uint32.valueOf(2)).build();
final StatefulMessagesStatsAug statefulMsg = new StatefulMessagesStatsAugBuilder().setLastReceivedRptMsgTimestamp(Uint32.valueOf(1553183614L)).setSentUpdMsgCount(Uint32.ONE).setReceivedRptMsgCount(Uint32.TWO).setSentInitMsgCount(Uint32.valueOf(3)).build();
final Messages messages = new MessagesBuilder().setLastSentMsgTimestamp(Uint32.valueOf(1553183734L)).setUnknownMsgReceived(Uint16.ONE).setSentMsgCount(Uint32.valueOf(5)).setReceivedMsgCount(Uint32.valueOf(4)).setReplyTime(replyTime).setErrorMessages(errorMsg).addAugmentation(statefulMsg).build();
final PeerCapabilities capabilities = new PeerCapabilitiesBuilder().addAugmentation(new StatefulCapabilitiesStatsAugBuilder().setStateful(true).setInstantiation(true).setActive(true).build()).build();
final LocalPref localPref = new LocalPrefBuilder().setKeepalive(Uint8.valueOf(30)).setDeadtimer(Uint8.valueOf(120)).setIpAddress("127.0.0.1").setSessionId(Uint16.ZERO).addAugmentation(new PcepEntityIdStatsAugBuilder().setSpeakerEntityIdValue(new byte[] { 0x01, 0x02, 0x03, 0x04 }).build()).build();
return new PcepSessionStateBuilder().setSynchronized(true).setSessionDuration("0:00:05:18").setDelegatedLspsCount(Uint16.ONE).setLocalPref(localPref).setPeerPref(new PeerPrefBuilder(localPref).build()).setPeerCapabilities(capabilities).setMessages(messages).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder 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.augmentation(Actions1.class);
if (augmentation != null && augmentation.getBgpActions() != null) {
final BgpActions bgpAction = augmentation.getBgpActions();
final SetAsPathPrepend asPrependAction = bgpAction.getSetAsPathPrepend();
final Uint32 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();
CNextHop nhNew;
if (address != null) {
if (address.getIpv4Address() != null) {
nhNew = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(IetfInetUtil.INSTANCE.ipv4AddressNoZoneFor(address.getIpv4Address())).build()).build();
} else {
nhNew = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(IetfInetUtil.INSTANCE.ipv6AddressNoZoneFor(address.getIpv6Address())).build()).build();
}
attributesUpdatedBuilder.setCNextHop(nhNew);
} else if (nhAction.getEnumeration() != null && BgpNextHopType.Enumeration.SELF == nhAction.getEnumeration()) {
nhNew = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(routeEntryInfo.getOriginatorId()).build()).build();
attributesUpdatedBuilder.setCNextHop(nhNew);
}
}
attributesUpdated = attributesUpdatedBuilder.build();
}
for (final Augmentation<BgpActions> action : bgpAction.augmentations().values()) {
final BgpActionAugPolicy handler = this.bgpAugActionsRegistry.get(action.implementedInterface());
if (handler == null) {
continue;
} else if (attributesUpdated == null) {
return null;
}
attributesUpdated = handler.applyExportAction(routeEntryInfo, routeEntryExportParameters, attributesUpdated, action);
}
}
if (attributesUpdated == null) {
return null;
}
// Export Actions Aug
for (final Augmentation<Actions> entry : actions.augmentations().values()) {
final ActionsAugPolicy handler = this.actionsRegistry.get(entry.implementedInterface());
if (attributesUpdated == null) {
return null;
} else if (handler == null) {
continue;
}
attributesUpdated = handler.applyExportAction(routeEntryInfo, routeEntryExportParameters, attributesUpdated, entry);
}
return attributesUpdated;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder in project bgpcep by opendaylight.
the class AppendActionTest method testMultipleAppend.
@Test
public void testMultipleAppend() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("multiple-append-test")).findFirst().get();
final RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
final Attributes expected = new AttributesBuilder().setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build()).setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4AddressNoZone("4.5.6.7")).build()).build()).setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build()).setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.valueOf(15)).build()).build();
assertEquals(expected, result.getAttributes());
}
Aggregations