X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=bgp%2Frib-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fbgp%2Frib%2Fimpl%2FPeerUtil.java;h=527aa4c8ff34d9c7300df38686a4eae3529b1e0e;hb=0fdeddbe3d072a88428599421191f0f60b2864e4;hp=a30eb07b8385b2db2b902d71568793cbf508982c;hpb=ac35f5db1582e2319c88976ddaa56ec17397d4db;p=bgpcep.git diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerUtil.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerUtil.java index a30eb07b83..527aa4c8ff 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerUtil.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerUtil.java @@ -11,7 +11,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; @@ -21,22 +22,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv6.prefixes.destination.ipv6.Ipv6PrefixesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv6CaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Update; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.UpdateBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.BgpParameters; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.BgpParametersBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.bgp.parameters.OptionalCapabilities; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.bgp.parameters.OptionalCapabilitiesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.bgp.parameters.optional.capabilities.CParametersBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.AsPath; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.AsPathBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPref; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPrefBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.Origin; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.OriginBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.as.path.Segments; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParametersBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilitiesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPath; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.as.path.Segments; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes2; @@ -55,51 +55,50 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlri; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlriBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlri; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlriBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpOrigin; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.CNextHop; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv6NextHopCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv6.next.hop._case.Ipv6NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.AddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpOrigin; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.CNextHop; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv6NextHopCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv6.next.hop._case.Ipv6NextHopBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; final class PeerUtil { - private PeerUtil() { - throw new UnsupportedOperationException(); + // Hidden on purpose } - static MpReachNlri createMpReachNlri(final IpAddress nextHop, final long pathId, final List prefixes) { + static MpReachNlri createMpReachNlri(final IpAddressNoZone nextHop, final List prefixes) { final Class afi; final CNextHop cNextHop; final DestinationType destinationType; - if (nextHop.getIpv4Address() != null) { + if (nextHop.getIpv4AddressNoZone() != null) { afi = Ipv4AddressFamily.class; cNextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder() - .setGlobal(nextHop.getIpv4Address()) + .setGlobal(nextHop.getIpv4AddressNoZone()) .build()).build(); destinationType = new DestinationIpv4CaseBuilder().setDestinationIpv4( new DestinationIpv4Builder().setIpv4Prefixes(prefixes.stream() .map(prefix -> new Ipv4PrefixesBuilder() - .setPathId(new PathId(pathId)) + .setPathId(PathIdUtil.NON_PATH_ID) .setPrefix(new Ipv4Prefix(prefix.getIpv4Prefix())).build()) .collect(Collectors.toList())) .build()).build(); } else { afi = Ipv6AddressFamily.class; cNextHop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder() - .setGlobal(nextHop.getIpv6Address()) + .setGlobal(nextHop.getIpv6AddressNoZone()) .build()).build(); destinationType = new DestinationIpv6CaseBuilder().setDestinationIpv6( new DestinationIpv6Builder().setIpv6Prefixes(prefixes.stream() .map(prefix -> new Ipv6PrefixesBuilder() - .setPathId(new PathId(pathId)) + .setPathId(PathIdUtil.NON_PATH_ID) .setPrefix(new Ipv6Prefix(prefix.getIpv6Prefix())).build()) .collect(Collectors.toList())) .build()).build(); @@ -115,12 +114,13 @@ final class PeerUtil { static Update createUpdate(final BgpOrigin bgpOrigin, final List pathSegments, + // FIXME: consider using Uint32 final long preference, final MpReachNlri mpReach, final MpUnreachNlri mpUnreach) { final Origin origin = new OriginBuilder().setValue(bgpOrigin).build(); final AsPath asPath = new AsPathBuilder().setSegments(pathSegments).build(); - final LocalPref localPref = new LocalPrefBuilder().setPref(preference).build(); + final LocalPref localPref = new LocalPrefBuilder().setPref(Uint32.valueOf(preference)).build(); final AttributesBuilder attributeBuilder = new AttributesBuilder() .setOrigin(origin).setAsPath(asPath).setLocalPref(localPref); @@ -147,17 +147,6 @@ final class PeerUtil { .build()).build(); } - static Update createEndOfRib(final TablesKey key) { - return key.getAfi() == Ipv4AddressFamily.class ? new UpdateBuilder().build() : - new UpdateBuilder() - .setAttributes(new AttributesBuilder() - .addAugmentation(Attributes2.class, new Attributes2Builder() - .setMpUnreachNlri(new MpUnreachNlriBuilder() - .setAfi(key.getAfi()) - .setSafi(key.getSafi()) - .build()).build()).build()).build(); - } - static BgpParameters createBgpParameters(final List advertisedTables, final List addPathTables, final Map gracefulTabes, @@ -175,31 +164,30 @@ final class PeerUtil { private static OptionalCapabilities createMultiprotocolCapability(final TablesKey key) { return new OptionalCapabilitiesBuilder().setCParameters( - new CParametersBuilder().addAugmentation( - CParameters1.class, new CParameters1Builder().setMultiprotocolCapability( - new MultiprotocolCapabilityBuilder() - .setAfi(key.getAfi()) - .setSafi(key.getSafi()) - .build()).build()).build()).build(); + new CParametersBuilder().addAugmentation( + CParameters1.class, new CParameters1Builder().setMultiprotocolCapability( + new MultiprotocolCapabilityBuilder() + .setAfi(key.getAfi()) + .setSafi(key.getSafi()) + .build()).build()).build()).build(); } private static OptionalCapabilities createGracefulRestartCapability(final Map gracefulTables, final int restartTime) { return new OptionalCapabilitiesBuilder().setCParameters( - new CParametersBuilder().addAugmentation( - CParameters1.class, new CParameters1Builder() - .setGracefulRestartCapability(new GracefulRestartCapabilityBuilder() - .setRestartFlags(new GracefulRestartCapability.RestartFlags(false)) - .setRestartTime(restartTime) - .setTables( - gracefulTables.keySet().stream() - .map(key -> new TablesBuilder() - .setAfi(key.getAfi()) - .setSafi(key.getSafi()) - .setAfiFlags(new Tables.AfiFlags(gracefulTables.get(key))) - .build()) - .collect(Collectors.toList())) - .build()).build()).build()).build(); + new CParametersBuilder().addAugmentation( + CParameters1.class, new CParameters1Builder() + .setGracefulRestartCapability(new GracefulRestartCapabilityBuilder() + .setRestartFlags(new GracefulRestartCapability.RestartFlags(false)) + .setRestartTime(restartTime) + .setTables(gracefulTables.keySet().stream() + .map(key -> new TablesBuilder() + .setAfi(key.getAfi()) + .setSafi(key.getSafi()) + .setAfiFlags(new Tables.AfiFlags(gracefulTables.get(key))) + .build()) + .collect(Collectors.toList())) + .build()).build()).build()).build(); } private static OptionalCapabilities createAddPathCapability(final List keys) {