From 8f9fe3ca424abc56d212a96af4ec5750a29e7673 Mon Sep 17 00:00:00 2001 From: Michal Cmarada Date: Fri, 4 May 2018 16:13:09 +0200 Subject: HC2VPP-253 - Bump routing models This patch updates (for support of SRv6 and MPLS) routing models to: - hc2vpp-ietf-routing@2018-03-13.yang (RFC 8349, https://tools.ietf.org/html/rfc8349) - hc2vpp-ietf-ipv4-unicast-routing@2018-03-13.yang (RFC 8349) - hc2vpp-ietf-ipv6-unicast-routing@2018-03-13.yang (RFC 8349) - hc2vpp-ietf-ipv6-router-advertisements@2018-03-13 (RFC 8349) - hc2vpp-ietf-routing-types@2017-12-04 (RFC 8294 ,https://tools.ietf.org/html/rfc8294) Due to odl bugs these models were changed, see HC2VPP-298 for more details. Significant changes in updated models: - Routing instance was removed, we used vpp-routing-instance as single instance before, which is no longer needed. - Routing-protocol and Routing-protocols were refactored to Control-plane-protocol/s. Control-protocol now uses type and name as key - Route Key was changed from id to ipPrefix - Next-hop and Next-Hop-list were refactored See attached routing_postman_collection.json for updated data structures and examples for both IPv4 and IPv6 routes. For router advertisements see routing_advertisments_postman_collection.json Another fixes in this patch: - fixes in MPLS module due to Routing model updates - fixes doc module due to changes in Routing model Change-Id: I33704a50061aef97dfbd73a7701ff6fe5274d6f0 Signed-off-by: Michal Cmarada --- .../yang/hc2vpp-ietf-mpls-static@2017-03-10.yang | 8 +- .../src/main/yang/hc2vpp-ietf-mpls@2017-07-02.yang | 22 +- mpls/api/src/main/yang/vpp-mpls@2017-11-20.yang | 4 +- .../io/fd/hc2vpp/mpls/ImposeAndForwardWriter.java | 2 +- .../java/io/fd/hc2vpp/mpls/MplsSwapWriter.java | 2 +- .../java/io/fd/hc2vpp/mpls/MplsWriterFactory.java | 2 +- .../io/fd/hc2vpp/mpls/ImposeAndForwardTest.java | 4 +- .../hc2vpp/mpls/MplsInterfaceCustomizerTest.java | 4 +- .../io/fd/hc2vpp/mpls/PopAndIpv4LookupTest.java | 4 +- .../io/fd/hc2vpp/mpls/PopAndMplsLookupTest.java | 4 +- .../java/io/fd/hc2vpp/mpls/SwapAndForwardTest.java | 4 +- ...c2vpp-ietf-ipv4-unicast-routing@2017-09-17.yang | 446 -------- ...c2vpp-ietf-ipv4-unicast-routing@2018-03-13.yang | 395 +++++++ ...ietf-ipv6-router-advertisements@2018-03-13.yang | 501 +++++++++ ...c2vpp-ietf-ipv6-unicast-routing@2017-09-17.yang | 848 --------------- ...c2vpp-ietf-ipv6-unicast-routing@2018-03-13.yang | 420 ++++++++ .../yang/hc2vpp-ietf-routing-types@2017-02-27.yang | 725 ------------- .../yang/hc2vpp-ietf-routing-types@2017-12-04.yang | 793 +++++++++++++++ .../main/yang/hc2vpp-ietf-routing@2014-05-24.yang | 1035 ------------------- .../main/yang/hc2vpp-ietf-routing@2018-03-13.yang | 740 ++++++++++++++ .../yang/vpp-ipv4-unicast-routing@2018-03-19.yang | 78 ++ .../yang/vpp-ipv6-unicast-routing@2018-03-19.yang | 78 ++ .../src/main/yang/vpp-routing-ra@2017-05-02.yang | 132 --- .../src/main/yang/vpp-routing-ra@2018-03-19.yang | 145 +++ .../yang/vpp-routing-table-lookup@2017-09-17.yang | 49 - .../main/yang/vpp-routing-types@2018-04-06.yang | 60 ++ .../src/main/yang/vpp-routing@2017-09-17.yang | 89 -- .../src/main/yang/vpp-routing@2018-03-19.yang | 86 ++ .../io/fd/hc2vpp/routing/Ipv4RoutingNodes.java | 51 + .../io/fd/hc2vpp/routing/Ipv6RoutingNodes.java | 56 + .../io/fd/hc2vpp/routing/RoutingConfiguration.java | 7 - .../java/io/fd/hc2vpp/routing/RoutingIIds.java | 64 ++ .../java/io/fd/hc2vpp/routing/RoutingModule.java | 20 +- .../routing/naming/Ipv4RouteNamesFactory.java | 46 +- .../routing/naming/Ipv6RouteNamesFactory.java | 41 +- .../read/ControlPlaneProtocolCustomizer.java | 140 +++ .../hc2vpp/routing/read/Ipv4ReadRoutingNodes.java | 99 -- .../hc2vpp/routing/read/Ipv4RouteCustomizer.java | 60 +- .../hc2vpp/routing/read/Ipv6ReadRoutingNodes.java | 97 -- .../hc2vpp/routing/read/Ipv6RouteCustomizer.java | 57 +- .../routing/read/RoutingInstanceCustomizer.java | 73 -- .../routing/read/RoutingProtocolCustomizer.java | 134 --- .../hc2vpp/routing/read/RoutingReaderFactory.java | 177 ++++ .../routing/read/RoutingStateCustomizer.java | 149 --- .../routing/read/RoutingStateReaderFactory.java | 136 --- .../hc2vpp/routing/trait/Ipv4RoutePathParser.java | 127 ++- .../hc2vpp/routing/trait/Ipv6RoutePathParser.java | 110 +- .../io/fd/hc2vpp/routing/trait/RouteMapper.java | 15 +- .../write/ControlPlaneProtocolCustomizer.java | 97 ++ .../hc2vpp/routing/write/Ipv4RouteCustomizer.java | 88 +- .../routing/write/Ipv4WriteRoutingNodes.java | 179 ---- .../hc2vpp/routing/write/Ipv6RouteCustomizer.java | 85 +- .../routing/write/Ipv6WriteRoutingNodes.java | 180 ---- .../fd/hc2vpp/routing/write/PrefixCustomizer.java | 14 +- .../write/RouterAdvertisementsCustomizer.java | 6 +- .../fd/hc2vpp/routing/write/RoutingCustomizer.java | 12 +- .../routing/write/RoutingInstanceCustomizer.java | 66 -- .../routing/write/RoutingInterfaceCustomizer.java | 73 -- .../routing/write/RoutingProtocolCustomizer.java | 97 -- .../hc2vpp/routing/write/RoutingWriterFactory.java | 104 +- .../write/factory/MultipathHopRequestFactory.java | 45 +- .../write/factory/SimpleHopRequestFactory.java | 63 +- .../factory/SpecialNextHopRequestFactory.java | 20 +- .../write/factory/TableLookupRequestFactory.java | 52 +- .../routing/write/trait/RouteRequestProducer.java | 2 +- .../config/routing.json | 3 +- .../hc2vpp/routing/Ipv4RouteNamesFactoryTest.java | 33 +- .../java/io/fd/hc2vpp/routing/Ipv6RouteData.java | 4 +- .../hc2vpp/routing/Ipv6RouteNamesFactoryTest.java | 37 +- .../io/fd/hc2vpp/routing/RoutingModuleTest.java | 4 +- .../routing/helpers/RoutingRequestTestHelper.java | 45 +- .../routing/helpers/SchemaContextTestHelper.java | 35 +- .../read/ControlPlaneProtocolCustomizerTest.java | 226 ++++ .../routing/read/Ipv4RouteCustomizerTest.java | 135 +-- .../routing/read/Ipv6RouteCustomizerTest.java | 117 ++- .../read/RoutingProtocolCustomizerTest.java | 225 ---- .../routing/read/RoutingStateCustomizerTest.java | 64 -- .../write/ControlPlaneProtocolCustomizerTest.java | 132 +++ .../routing/write/Ipv4RouteCustomizerTest.java | 96 +- .../routing/write/Ipv6RouteCustomizerTest.java | 72 +- .../hc2vpp/routing/write/PrefixCustomizerTest.java | 53 +- .../write/RouterAdvertisementsCustomizerTest.java | 42 +- .../write/RoutingInstanceCustomizerTest.java | 87 -- .../write/RoutingInterfaceCustomizerTest.java | 91 -- .../write/RoutingProtocolCustomizerTest.java | 132 --- .../MultipathHopRequestFactoryIpv4Test.java | 40 +- .../MultipathHopRequestFactoryIpv6Test.java | 29 +- .../factory/SimpleHopRequestFactoryIpv4Test.java | 15 +- .../factory/SimpleHopRequestFactoryIpv6Test.java | 4 +- .../SpecialNextHopRequestFactoryIpv4Test.java | 52 +- .../SpecialNextHopRequestFactoryIpv6Test.java | 58 +- .../ipv4/multihop/multiHopRouteWithClassifier.json | 37 +- .../multihop/multiHopRouteWithNoRouteAttrs.json | 35 +- .../multihop/multiHopRouteWithoutClassifier.json | 37 +- .../ipv4/simplehop/simpleHopRouteNoRouteAttrs.json | 7 +- .../simplehop/simpleHopRouteWithClassifier.json | 11 +- .../simplehop/simpleHopRouteWithoutClassifier.json | 9 +- .../ipv4/specialhop/specialHopRouteBlackhole.json | 5 +- .../ipv4/specialhop/specialHopRouteProhibited.json | 5 +- .../ipv4/specialhop/specialHopRouteReceive.json | 5 +- .../specialhop/specialHopRouteUnreachable.json | 7 +- .../ipv6/multihop/multiHopRouteWithClassifier.json | 35 +- .../multihop/multiHopRouteWithoutClassifier.json | 35 +- .../multihop/multiHopRouteWithoutRouteAttrs.json | 35 +- .../simplehop/simpleHopRouteWithClassifier.json | 13 +- .../simplehop/simpleHopRouteWithoutClassifier.json | 11 +- .../simplehop/simpleHopRouteWithoutRouteAttrs.json | 9 +- .../ipv6/specialhop/specialHopRouteBlackhole.json | 7 +- .../ipv6/specialhop/specialHopRouteProhibited.json | 7 +- .../ipv6/specialhop/specialHopRouteReceive.json | 7 +- .../specialhop/specialHopRouteUnreachable.json | 9 +- .../src/test/resources/ra/complexRa.json | 18 +- .../src/test/resources/ra/simpleRa.json | 8 +- .../routing-impl/src/test/resources/routing.json | 4 +- routing/routing_adv_postman_collection.json | 201 ---- .../routing_advertisements_postman_collection.json | 409 ++++++++ routing/routing_postman_collection.json | 1075 ++++++++++++++++---- .../scripts/src/main/resources/routing.json | 3 +- 118 files changed, 6750 insertions(+), 6647 deletions(-) delete mode 100644 routing/routing-api/src/main/yang/hc2vpp-ietf-ipv4-unicast-routing@2017-09-17.yang create mode 100755 routing/routing-api/src/main/yang/hc2vpp-ietf-ipv4-unicast-routing@2018-03-13.yang create mode 100755 routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-router-advertisements@2018-03-13.yang delete mode 100644 routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-unicast-routing@2017-09-17.yang create mode 100755 routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-unicast-routing@2018-03-13.yang delete mode 100644 routing/routing-api/src/main/yang/hc2vpp-ietf-routing-types@2017-02-27.yang create mode 100755 routing/routing-api/src/main/yang/hc2vpp-ietf-routing-types@2017-12-04.yang delete mode 100644 routing/routing-api/src/main/yang/hc2vpp-ietf-routing@2014-05-24.yang create mode 100755 routing/routing-api/src/main/yang/hc2vpp-ietf-routing@2018-03-13.yang create mode 100644 routing/routing-api/src/main/yang/vpp-ipv4-unicast-routing@2018-03-19.yang create mode 100644 routing/routing-api/src/main/yang/vpp-ipv6-unicast-routing@2018-03-19.yang delete mode 100644 routing/routing-api/src/main/yang/vpp-routing-ra@2017-05-02.yang create mode 100644 routing/routing-api/src/main/yang/vpp-routing-ra@2018-03-19.yang delete mode 100644 routing/routing-api/src/main/yang/vpp-routing-table-lookup@2017-09-17.yang create mode 100644 routing/routing-api/src/main/yang/vpp-routing-types@2018-04-06.yang delete mode 100644 routing/routing-api/src/main/yang/vpp-routing@2017-09-17.yang create mode 100644 routing/routing-api/src/main/yang/vpp-routing@2018-03-19.yang create mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/Ipv4RoutingNodes.java create mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/Ipv6RoutingNodes.java create mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingIIds.java create mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/ControlPlaneProtocolCustomizer.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv4ReadRoutingNodes.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv6ReadRoutingNodes.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingInstanceCustomizer.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizer.java create mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingReaderFactory.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizer.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingStateReaderFactory.java create mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizer.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4WriteRoutingNodes.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6WriteRoutingNodes.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizer.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizer.java delete mode 100644 routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizer.java create mode 100644 routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/ControlPlaneProtocolCustomizerTest.java delete mode 100644 routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizerTest.java delete mode 100644 routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java create mode 100644 routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java delete mode 100644 routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java delete mode 100644 routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizerTest.java delete mode 100644 routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java delete mode 100644 routing/routing_adv_postman_collection.json create mode 100755 routing/routing_advertisements_postman_collection.json mode change 100644 => 100755 routing/routing_postman_collection.json diff --git a/mpls/api/src/main/yang/hc2vpp-ietf-mpls-static@2017-03-10.yang b/mpls/api/src/main/yang/hc2vpp-ietf-mpls-static@2017-03-10.yang index 143d87022..ae8688bbd 100644 --- a/mpls/api/src/main/yang/hc2vpp-ietf-mpls-static@2017-03-10.yang +++ b/mpls/api/src/main/yang/hc2vpp-ietf-mpls-static@2017-03-10.yang @@ -91,10 +91,10 @@ module hc2vpp-ietf-mpls-static { "This YANG module augments the 'ietf-routing' module with basic configuration and operational state data for MPLS static"; -/* -TODO: 2017-07-02 defines grouping in-segment but does not use it. -Bump to newer version after the issue is resolved. -*/ + /* + TODO: 2017-07-02 defines grouping in-segment but does not use it. + Bump to newer version after the issue is resolved. + */ revision "2017-03-10" { description "Latest revision: diff --git a/mpls/api/src/main/yang/hc2vpp-ietf-mpls@2017-07-02.yang b/mpls/api/src/main/yang/hc2vpp-ietf-mpls@2017-07-02.yang index 7aa1a5c35..16ac32cb9 100644 --- a/mpls/api/src/main/yang/hc2vpp-ietf-mpls@2017-07-02.yang +++ b/mpls/api/src/main/yang/hc2vpp-ietf-mpls@2017-07-02.yang @@ -78,9 +78,13 @@ module hc2vpp-ietf-mpls { } /* Identities */ - + /* + added "-identity" to resolve class naming conflicts + bug in mdsal reported here: https://jira.opendaylight.org/browse/MDSAL-332 + TODO(HC2VPP-298): remove "-identity" postfix when resolved + */ identity mpls { - base rt:address-family; + base rt:address-family-identity; description "This identity represents the MPLS address family."; } @@ -350,9 +354,6 @@ module hc2vpp-ietf-mpls { "MPLS local label."; } } -/* - TODO: we use older routing model which does not define next-hop container under route. - Uncomment following augmentation after HC2VPP-253 is resolved. augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route/" + "rt:next-hop/rt:next-hop-options/rt:simple-next-hop" { @@ -370,13 +371,10 @@ module hc2vpp-ietf-mpls { uses nhlfe-contents; } - */ - -/* - TODO(HC2VPP-253): we use older routing model which does not define active-route - as action but as an RPC. - Even after bump to ietf-routing@2016-08-18, we would fail due to - https://jira.opendaylight.org/browse/YANGTOOLS-822 + /* + TODO(HC2VPP-298): + needed to comment out action augmentations which caused problems. probapby simmilar to: + https://jira.opendaylight.org/browse/YANGTOOLS-841 augment "/rt:routing-state/rt:ribs/rt:rib/rt:active-route/rt:input" { diff --git a/mpls/api/src/main/yang/vpp-mpls@2017-11-20.yang b/mpls/api/src/main/yang/vpp-mpls@2017-11-20.yang index c58478102..c417046c0 100644 --- a/mpls/api/src/main/yang/vpp-mpls@2017-11-20.yang +++ b/mpls/api/src/main/yang/vpp-mpls@2017-11-20.yang @@ -10,7 +10,7 @@ module vpp-mpls { import hc2vpp-ietf-routing { prefix "rt"; - revision-date 2014-05-24; + revision-date 2018-03-13; } import hc2vpp-ietf-mpls-static { @@ -110,4 +110,4 @@ module vpp-mpls { description "Augments static-lsp list entry with lookup options available in VPP."; } -} \ No newline at end of file +} diff --git a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/ImposeAndForwardWriter.java b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/ImposeAndForwardWriter.java index 40efd75d6..5e384305c 100644 --- a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/ImposeAndForwardWriter.java +++ b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/ImposeAndForwardWriter.java @@ -41,7 +41,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._stati import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310._static.lsp_config.out.segment.SimplePath; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310._static.lsp_config.out.segment.path.list.Paths; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.routing.mpls._static.lsps.StaticLsp; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev170227.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.MplsLabel; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** diff --git a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsSwapWriter.java b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsSwapWriter.java index 28aba7aa8..72d9c65ae 100644 --- a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsSwapWriter.java +++ b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsSwapWriter.java @@ -34,7 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._stati import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310._static.lsp_config.OutSegment; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310._static.lsp_config.out.segment.SimplePath; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.routing.mpls._static.lsps.StaticLsp; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev170227.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.MplsLabel; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** diff --git a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsWriterFactory.java b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsWriterFactory.java index 918cc5cc6..d81d6fae3 100644 --- a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsWriterFactory.java +++ b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsWriterFactory.java @@ -36,7 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._stati import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.Routing1; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.interfaces.mpls.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.routing.Mpls; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Routing; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.mpls.rev171120.StaticLspVppLookupAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.mpls.rev171120.vpp.label.lookup.attributes.LabelLookup; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java index 6eb559da8..ca687b502 100644 --- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java +++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java @@ -50,8 +50,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._stati import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.routing.mpls._static.lsps.StaticLspKey; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.Routing1; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.routing.Mpls; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev170227.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Routing; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.MplsLabel; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDataTranslator, MplsLabelTranslator { diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/MplsInterfaceCustomizerTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/MplsInterfaceCustomizerTest.java index 21551292b..1a86102cc 100644 --- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/MplsInterfaceCustomizerTest.java +++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/MplsInterfaceCustomizerTest.java @@ -37,7 +37,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.interfaces.mpls.InterfaceKey; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.interfaces.mpls._interface.ConfigBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.routing.Mpls; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Routing; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class MplsInterfaceCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator { @@ -107,4 +107,4 @@ public class MplsInterfaceCustomizerTest extends WriterCustomizerTest implements request.swIfIndex = IF_INDEX; return request; } -} \ No newline at end of file +} diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndIpv4LookupTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndIpv4LookupTest.java index 61e1c6d58..434f3b91d 100644 --- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndIpv4LookupTest.java +++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndIpv4LookupTest.java @@ -41,8 +41,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._stati import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.routing.mpls._static.lsps.StaticLspKey; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.Routing1; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.routing.Mpls; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev170227.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Routing; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.MplsLabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.mpls.rev171120.LookupType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.mpls.rev171120.StaticLspVppLookupAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.mpls.rev171120.StaticLspVppLookupAugmentationBuilder; diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndMplsLookupTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndMplsLookupTest.java index f5a76974a..a6bc3432a 100644 --- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndMplsLookupTest.java +++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndMplsLookupTest.java @@ -41,8 +41,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._stati import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.routing.mpls._static.lsps.StaticLspKey; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.Routing1; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.routing.Mpls; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev170227.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Routing; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.MplsLabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.mpls.rev171120.LookupType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.mpls.rev171120.StaticLspVppLookupAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.mpls.rev171120.StaticLspVppLookupAugmentationBuilder; diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/SwapAndForwardTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/SwapAndForwardTest.java index 5b0e124f0..4a962dd9f 100644 --- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/SwapAndForwardTest.java +++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/SwapAndForwardTest.java @@ -44,8 +44,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._stati import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.routing.mpls._static.lsps.StaticLspKey; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.Routing1; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls.rev170702.routing.Mpls; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev170227.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Routing; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.MplsLabel; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class SwapAndForwardTest extends WriterCustomizerTest implements ByteDataTranslator, MplsLabelTranslator { diff --git a/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv4-unicast-routing@2017-09-17.yang b/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv4-unicast-routing@2017-09-17.yang deleted file mode 100644 index 5357d1544..000000000 --- a/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv4-unicast-routing@2017-09-17.yang +++ /dev/null @@ -1,446 +0,0 @@ -module hc2vpp-ietf-ipv4-unicast-routing { - - namespace "urn:ietf:params:xml:ns:yang:ietf-ipv4-unicast-routing"; - - prefix "v4ur"; - - import vpp-routing-table-lookup { - prefix "vpp-tl"; - } - - import hc2vpp-ietf-routing { - prefix "rt"; - revision-date 2014-05-24; - } - - import ietf-inet-types { - prefix "inet"; - } - - //TODO modification needed because of yangtools bug(unable to proceed augmentation in separate model of augmentation in this model) - import vpp-routing { - prefix vpp-r; - } - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: Thomas Nadeau - - - WG Chair: Juergen Schoenwaelder - - - Editor: Ladislav Lhotka - "; - - description - "This YANG module augments the 'ietf-routing' module with basic - configuration and operational state data for IPv4 unicast - routing. - - Copyright (c) 2014 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject to - the license terms contained in, the Simplified BSD License set - forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see the - RFC itself for full legal notices."; - - revision 2017-09-17 { - description - "Table lookup support"; - } - - revision 2014-05-24 { - description - "Initial revision."; - reference - "RFC XXXX: A YANG Data Model for Routing Management"; - } - - /* Identities */ - - identity ipv4-unicast { - base rt:ipv4; - description - "This identity represents the IPv4 unicast address family."; - } - - /* Operational state data */ - - augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route" { - when "../../rt:address-family = 'v4ur:ipv4-unicast'" { - description - "This augment is valid only for IPv4 unicast."; - } - description - "This leaf augments an IPv4 unicast route."; - leaf destination-prefix { - type inet:ipv4-prefix; - description - "IPv4 destination prefix."; - } - } - - augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route/" - + "rt:next-hop-options/rt:simple-next-hop" { - when "../../rt:address-family = 'v4ur:ipv4-unicast'" { - description - "This augment is valid only for IPv4 unicast."; - } - description - "This leaf augments the 'simple-next-hop' case of IPv4 unicast - routes."; - leaf next-hop { - type inet:ipv4-address; - description - "IPv4 address of the next-hop."; - } - } - - augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route/" - + "rt:next-hop-options/rt:next-hop-list/rt:next-hop-list/" - + "rt:next-hop" { - when "../../../../rt:address-family = 'v4ur:ipv4-unicast'" { - description - "This augment is valid only for IPv4 unicast."; - } - if-feature rt:multipath-routes; - description - "This leaf augments the 'next-hop-list' case of IPv4 unicast - routes."; - leaf address { - type inet:ipv4-address; - description - "IPv4 address of the next-hop."; - } - } - - //NODE Added same augmentation for operation state - augment "/rt:routing-state/rt:routing-instance/rt:routing-protocols/rt:routing-protocol/rt:static-routes" { - description - "This augment defines the configuration of the 'static' - pseudo-protocol with data specific to IPv4 unicast."; - container ipv4 { - description - "Configuration of a 'static' pseudo-protocol instance - consists of a list of routes."; - list route { - key "id"; - ordered-by "user"; - description - "A user-ordered list of static routes."; - leaf id { - type uint32 { - //WARNING - range changed from 1..max to be mappable on vpp table ids - range "0..max"; - } - description - "Unique numeric identifier of the route. - - This value is unrelated to system-assigned 'id' - parameters of routes in RIBs."; - } - leaf description { - type string; - description - "Textual description of the route."; - } - leaf destination-prefix { - type inet:ipv4-prefix; - mandatory "true"; - description - "IPv4 destination prefix."; - } - choice next-hop-options { - mandatory "true"; - description - "Options for expressing the next-hop in static routes."; - case special-next-hop { - uses rt:special-next-hop-grouping; - } - // TODO - HONEYCOMB-398/HC2VPP-237 - case table-lookup { - container table-lookup-params { - uses vpp-tl:table-lookup-case-params; - } - } - - case simple-next-hop { - leaf next-hop { - type inet:ipv4-address; - description - "IPv4 address of the next-hop."; - } - - //TODO - temporarily set to absolute path until https://bugs.opendaylight.org/show_bug.cgi?id=6881 is resolved - leaf outgoing-interface { - type leafref { - path "/rt:routing/rt:routing-instance/rt:interfaces/rt:interface/" - + "rt:name"; - } - description - "Name of the outgoing interface. - - Only interfaces configured for the ancestor routing - instance can be given."; - } - } - case next-hop-list { - if-feature rt:multipath-routes; - container next-hop-list { - description - "Configuration of multiple next-hops."; - list next-hop { - key "id"; - description - "An entry of a next-hop list."; - leaf id { - type uint32; - description - "Unique numeric identifier of the entry. - - This value is unrelated to system-assigned 'id' - parameters of next-hops in RIBs."; - } - leaf address { - type inet:ipv4-address; - description - "IPv4 address of the next-hop."; - } - //TODO - temporarily set to absolute path until https://bugs.opendaylight.org/show_bug.cgi?id=6881 is resolved - leaf outgoing-interface { - type leafref { - path "/rt:routing/rt:routing-instance/rt:interfaces/" - + "rt:interface/rt:name"; - } - description - "Name of the outgoing interface. - - Only interfaces configured for the ancestor - routing instance can be given."; - } - uses rt:next-hop-classifiers { - refine "priority" { - default "primary"; - } - refine "weight" { - default "0"; - } - } - } - } - } - } - - //TODO modification needed because of yangtools bug(unable to proceed augmentation in separate model of augmentation in this model) - container vpp-ipv4-route-state{ - uses vpp-r:vpp-route-attributes; - } - } - } - } - - - /* Configuration data */ - - augment "/rt:routing/rt:routing-instance/rt:routing-protocols/rt:routing-protocol/rt:static-routes" { - description - "This augment defines the configuration of the 'static' - pseudo-protocol with data specific to IPv4 unicast."; - container ipv4 { - description - "Configuration of a 'static' pseudo-protocol instance - consists of a list of routes."; - list route { - key "id"; - ordered-by "user"; - description - "A user-ordered list of static routes."; - leaf id { - type uint32 { - //WARNING - range changed from 1..max to be mappable on vpp table ids - range "0..max"; - } - description - "Unique numeric identifier of the route. - - This value is unrelated to system-assigned 'id' - parameters of routes in RIBs."; - } - leaf description { - type string; - description - "Textual description of the route."; - } - leaf destination-prefix { - type inet:ipv4-prefix; - mandatory "true"; - description - "IPv4 destination prefix."; - } - choice next-hop-options { - mandatory "true"; - description - "Options for expressing the next-hop in static routes."; - case special-next-hop { - uses rt:special-next-hop-grouping; - } - case simple-next-hop { - leaf next-hop { - type inet:ipv4-address; - description - "IPv4 address of the next-hop."; - } - - //TODO - temporarily set to absolute path until https://bugs.opendaylight.org/show_bug.cgi?id=6881 is resolved - leaf outgoing-interface { - type leafref { - path "/rt:routing/rt:routing-instance/rt:interfaces/rt:interface/" - + "rt:name"; - } - description - "Name of the outgoing interface. - - Only interfaces configured for the ancestor routing - instance can be given."; - } - } - - // TODO - HONEYCOMB-398/HC2VPP-237 - case table-lookup { - container table-lookup-params { - uses vpp-tl:table-lookup-case-params; - } - } - - case next-hop-list { - if-feature rt:multipath-routes; - container next-hop-list { - description - "Configuration of multiple next-hops."; - list next-hop { - key "id"; - description - "An entry of a next-hop list."; - leaf id { - type uint32; - description - "Unique numeric identifier of the entry. - - This value is unrelated to system-assigned 'id' - parameters of next-hops in RIBs."; - } - leaf address { - type inet:ipv4-address; - description - "IPv4 address of the next-hop."; - } - //TODO - temporarily set to absolute path until https://bugs.opendaylight.org/show_bug.cgi?id=6881 is resolved - leaf outgoing-interface { - type leafref { - path "/rt:routing/rt:routing-instance/rt:interfaces/" - + "rt:interface/rt:name"; - } - description - "Name of the outgoing interface. - - Only interfaces configured for the ancestor - routing instance can be given."; - } - uses rt:next-hop-classifiers { - refine "priority" { - default "primary"; - } - refine "weight" { - default "0"; - } - } - } - } - } - } - - //TODO modification needed because of yangtools bug(unable to proceed augmentation in separate model of augmentation in this model) - container vpp-ipv4-route{ - uses vpp-r:vpp-route-attributes; - } - } - } - } - - /* RPC methods */ - - augment "/rt:active-route/rt:input/rt:destination-address" { - when "rt:address-family='v4ur:ipv4-unicast'" { - description - "This augment is valid only for IPv4 unicast."; - } - description - "This leaf augments the 'rt:destination-address' parameter of - the 'rt:active-route' operation."; - leaf address { - type inet:ipv4-address; - description - "IPv4 destination address."; - } - } - - augment "/rt:active-route/rt:output/rt:route" { - when "rt:address-family='v4ur:ipv4-unicast'" { - description - "This augment is valid only for IPv4 unicast."; - } - description - "This leaf augments the reply to the 'rt:active-route' - operation."; - leaf destination-prefix { - type inet:ipv4-prefix; - description - "IPv4 destination prefix."; - } - } - - augment "/rt:active-route/rt:output/rt:route/rt:next-hop-options/" - + "rt:simple-next-hop" { - when "rt:address-family='v4ur:ipv4-unicast'" { - description - "This augment is valid only for IPv4 unicast."; - } - description - "This leaf augments the 'simple-next-hop' case in the reply to - the 'rt:active-route' operation."; - leaf next-hop { - type inet:ipv4-address; - description - "IPv4 address of the next-hop."; - } - } - - augment "/rt:active-route/rt:output/rt:route/rt:next-hop-options/" - + "rt:next-hop-list/rt:next-hop-list/rt:next-hop" { - when "../../rt:address-family='v4ur:ipv4-unicast'" { - description - "This augment is valid only for IPv4 unicast."; - } - if-feature rt:multipath-routes; - description - "This leaf augments the 'next-hop-list' case in the reply to - the 'rt:active-route' operation."; - leaf address { - type inet:ipv4-address; - description - "IPv4 address of the next-hop."; - } - } -} \ No newline at end of file diff --git a/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv4-unicast-routing@2018-03-13.yang b/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv4-unicast-routing@2018-03-13.yang new file mode 100755 index 000000000..8d2f94848 --- /dev/null +++ b/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv4-unicast-routing@2018-03-13.yang @@ -0,0 +1,395 @@ +module hc2vpp-ietf-ipv4-unicast-routing { + yang-version "1.1"; + namespace + "urn:ietf:params:xml:ns:yang:ietf-ipv4-unicast-routing"; + prefix "v4ur"; + + /* + This models was modified due to ODL bugs described here: https://jira.fd.io/browse/HC2VPP-298. + Affected sections are renamed or commented, see comments below. + TODO: revert these changes and rename model to ietf-ipv4-unicast-routing once bugs are fixed. + */ + + import hc2vpp-ietf-routing { + prefix "rt"; + description + "An 'ietf-routing' module version that is compatible with + the Network Management Datastore Architecture (NMDA) + is required."; + } + + import ietf-inet-types { + prefix "inet"; + } + organization + "IETF NETMOD (Network Modeling) Working Group"; + contact + "WG Web: + WG List: + + Editor: Ladislav Lhotka + + Acee Lindem + + Yingzhen Qu + "; + + description + "This YANG module augments the 'ietf-routing' module with basic + parameters for IPv4 unicast routing. The model fully conforms + to the Network Management Datastore Architecture (NMDA). + + Copyright (c) 2018 IETF Trust and the persons + identified as authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 8349; see + the RFC itself for full legal notices."; + + revision 2018-03-13 { + description + "Network Management Datastore Architecture (NMDA) revision."; + reference + "RFC 8349: A YANG Data Model for Routing Management + (NMDA Version)"; + } + + revision 2016-11-04 { + description + "Initial revision."; + reference + "RFC 8022: A YANG Data Model for Routing Management"; + } + + /* Identities */ + + identity ipv4-unicast { + base rt:ipv4; + description + "This identity represents the IPv4 unicast address family."; + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:routes/rt:route" { + when "derived-from-or-self(../../rt:address-family, " + + "'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + description + "This leaf augments an IPv4 unicast route."; + leaf destination-prefix { + type inet:ipv4-prefix; + description + "IPv4 destination prefix."; + } + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:routes/rt:route/" + + "rt:next-hop/rt:next-hop-options/rt:simple-next-hop" { + when "derived-from-or-self(../../../rt:address-family, " + + "'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + description + "Augments the 'simple-next-hop' case in IPv4 unicast routes."; + leaf next-hop-address { + type inet:ipv4-address; + description + "IPv4 address of the next hop."; + } + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:routes/rt:route/" + + "rt:next-hop/rt:next-hop-options/rt:next-hop-list/" + + "rt:next-hop-list/rt:next-hop" { + when "derived-from-or-self(../../../../../rt:address-family, " + + "'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + description + "This leaf augments the 'next-hop-list' case of IPv4 unicast + routes."; + leaf address { + type inet:ipv4-address; + description + "IPv4 address of the next hop."; + } + } + + /* + TODO(HC2VPP-298): + needed to comment out action which caused problems probapby simmilar to: + https://jira.opendaylight.org/browse/YANGTOOLS-841 + + augment + "/rt:routing/rt:ribs/rt:rib/rt:active-route/rt:input" { + when "derived-from-or-self(../rt:address-family, " + + "'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast RIBs."; + } + description + "This augment adds the input parameter of the 'active-route' + action."; + leaf destination-address { + type inet:ipv4-address; + description + "IPv4 destination address."; + } + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route" { + when "derived-from-or-self(../../rt:address-family, " + + "'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + description + "This augment adds the destination prefix to the reply of the + 'active-route' action."; + leaf destination-prefix { + type inet:ipv4-prefix; + description + "IPv4 destination prefix."; + } + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route/rt:next-hop/rt:next-hop-options/" + + "rt:simple-next-hop" { + when "derived-from-or-self(../../../rt:address-family, " + + "'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + description + "Augments the 'simple-next-hop' case in the reply to the + 'active-route' action."; + leaf next-hop-address { + type inet:ipv4-address; + description + "IPv4 address of the next hop."; + } + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route/rt:next-hop/rt:next-hop-options/" + + "rt:next-hop-list/rt:next-hop-list/rt:next-hop" { + when "derived-from-or-self(../../../../../rt:address-family, " + + "'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + description + "Augments the 'next-hop-list' case in the reply to the + 'active-route' action."; + leaf next-hop-address { + type inet:ipv4-address; + description + "IPv4 address of the next hop."; + } + } + */ + + augment "/rt:routing/rt:control-plane-protocols/" + + "rt:control-plane-protocol/rt:static-routes" { + description + "This augment defines the 'static' pseudo-protocol + with data specific to IPv4 unicast."; + container ipv4 { + description + "Support for a 'static' pseudo-protocol instance + consists of a list of routes."; + list route { + key "destination-prefix"; + description + "A list of static routes."; + leaf destination-prefix { + type inet:ipv4-prefix; + mandatory true; + description + "IPv4 destination prefix."; + } + leaf description { + type string; + description + "Textual description of the route."; + } + container next-hop { + description + "Support for next-hop."; + uses rt:next-hop-content { + augment "next-hop-options/simple-next-hop" { + description + "Augments the 'simple-next-hop' case in IPv4 static + routes."; + leaf next-hop-address { + type inet:ipv4-address; + description + "IPv4 address of the next hop."; + } + } + augment "next-hop-options/next-hop-list/next-hop-list/" + + "next-hop" { + description + "Augments the 'next-hop-list' case in IPv4 static + routes."; + leaf next-hop-address { + type inet:ipv4-address; + description + "IPv4 address of the next hop."; + } + } + } + } + } + } + } + + /* + * The subsequent data nodes are obviated and obsoleted + * by the Network Management Datastore Architecture + * as described in RFC 8342. + */ + augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route" { + when "derived-from-or-self(../../rt:address-family, " + + "'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + status obsolete; + description + "This leaf augments an IPv4 unicast route."; + leaf destination-prefix { + type inet:ipv4-prefix; + status obsolete; + description + "IPv4 destination prefix."; + } + } + augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route/" + + "rt:next-hop/rt:next-hop-options/rt:simple-next-hop" { + when "derived-from-or-self( + ../../../rt:address-family, 'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + status obsolete; + description + "Augments the 'simple-next-hop' case in IPv4 unicast routes."; + leaf next-hop-address { + type inet:ipv4-address; + status obsolete; + description + "IPv4 address of the next hop."; + } + } + augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route/" + + "rt:next-hop/rt:next-hop-options/rt:next-hop-list/" + + "rt:next-hop-list/rt:next-hop" { + when "derived-from-or-self(../../../../../rt:address-family, + 'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + status obsolete; + description + "This leaf augments the 'next-hop-list' case of IPv4 unicast + routes."; + leaf address { + type inet:ipv4-address; + status obsolete; + description + "IPv4 address of the next hop."; + } + } + /* + TODO(HC2VPP-298): + needed to comment out action which caused problems probapby simmilar to: + https://jira.opendaylight.org/browse/YANGTOOLS-841 + + augment "/rt:routing-state/rt:ribs/rt:rib/rt:active-route/" + + "rt:input" { + when "derived-from-or-self(../rt:address-family, + 'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast RIBs."; + } + status obsolete; + description + "This augment adds the input parameter of the 'active-route' + action."; + leaf destination-address { + type inet:ipv4-address; + status obsolete; + description + "IPv4 destination address."; + } + } + augment "/rt:routing-state/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route" { + when "derived-from-or-self(../../rt:address-family, + 'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + status obsolete; + description + "This augment adds the destination prefix to the reply of the + 'active-route' action."; + leaf destination-prefix { + type inet:ipv4-prefix; + status obsolete; + description + "IPv4 destination prefix."; + } + } + augment "/rt:routing-state/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route/rt:next-hop/rt:next-hop-options/" + + "rt:simple-next-hop" { + when "derived-from-or-self(../../../rt:address-family, + 'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + status obsolete; + description + "Augments the 'simple-next-hop' case in the reply to the + 'active-route' action."; + leaf next-hop-address { + type inet:ipv4-address; + status obsolete; + description + "IPv4 address of the next hop."; + } + } + augment "/rt:routing-state/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route/rt:next-hop/rt:next-hop-options/" + + "rt:next-hop-list/rt:next-hop-list/rt:next-hop" { + when "derived-from-or-self(../../../../../rt:address-family, + 'v4ur:ipv4-unicast')" { + description + "This augment is valid only for IPv4 unicast."; + } + status obsolete; + description + "Augments the 'next-hop-list' case in the reply to the + 'active-route' action."; + leaf next-hop-address { + type inet:ipv4-address; + status obsolete; + description + "IPv4 address of the next hop."; + } + } + */ +} diff --git a/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-router-advertisements@2018-03-13.yang b/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-router-advertisements@2018-03-13.yang new file mode 100755 index 000000000..9c33ffc94 --- /dev/null +++ b/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-router-advertisements@2018-03-13.yang @@ -0,0 +1,501 @@ +submodule hc2vpp-ietf-ipv6-router-advertisements { + yang-version "1.1"; + + belongs-to hc2vpp-ietf-ipv6-unicast-routing { + prefix "v6ur"; + } + + import ietf-inet-types { + prefix "inet"; + } + + import ietf-interfaces { + prefix "if"; + description + "An 'ietf-interfaces' module version that is compatible with + the Network Management Datastore Architecture (NMDA) + is required."; + } + + import ietf-ip { + prefix "ip"; + description + "An 'ietf-ip' module version that is compatible with + the Network Management Datastore Architecture (NMDA) + is required."; + } + + organization + "IETF NETMOD (Network Modeling) Working Group"; + contact + "WG Web: + WG List: + + Editor: Ladislav Lhotka + + Acee Lindem + + Yingzhen Qu + "; + + description + "This YANG module augments the 'ietf-ip' module with + parameters for IPv6 Router Advertisements. The model fully + conforms to the Network Management Datastore + Architecture (NMDA). + + Copyright (c) 2018 IETF Trust and the persons + identified as authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 8349; see + the RFC itself for full legal notices."; + + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)"; + + revision 2018-03-13 { + description + "Network Management Datastore Architecture (NMDA) revision."; + reference + "RFC 8349: A YANG Data Model for Routing Management + (NMDA Version)"; + } + + revision 2016-11-04 { + description + "Initial revision."; + reference + "RFC 8022: A YANG Data Model for Routing Management"; + } + + augment "/if:interfaces/if:interface/ip:ipv6" { + description + "Augments interface configuration with parameters of IPv6 + Router Advertisements."; + container ipv6-router-advertisements { + description + "Support for IPv6 Router Advertisements."; + leaf send-advertisements { + type boolean; + default "false"; + description + "A flag indicating whether or not the router sends + periodic Router Advertisements and responds to + Router Solicitations."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - AdvSendAdvertisements"; + } + leaf max-rtr-adv-interval { + type uint16 { + range "4..65535"; + } + units "seconds"; + default "600"; + description + "The maximum time allowed between sending unsolicited + multicast Router Advertisements from the interface."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - MaxRtrAdvInterval"; + } + leaf min-rtr-adv-interval { + type uint16 { + range "3..1350"; + } + units "seconds"; + must ". <= 0.75 * ../max-rtr-adv-interval" { + description + "The value MUST NOT be greater than 75% of + 'max-rtr-adv-interval'."; + } + description + "The minimum time allowed between sending unsolicited + multicast Router Advertisements from the interface. + + The default value to be used operationally if this + leaf is not configured is determined as follows: + + - if max-rtr-adv-interval >= 9 seconds, the default + value is 0.33 * max-rtr-adv-interval; + + - otherwise, it is 0.75 * max-rtr-adv-interval."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - MinRtrAdvInterval"; + } + leaf managed-flag { + type boolean; + default "false"; + description + "The value to be placed in the 'Managed address + configuration' flag field in the Router + Advertisement."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - AdvManagedFlag"; + } + leaf other-config-flag { + type boolean; + default "false"; + description + "The value to be placed in the 'Other configuration' + flag field in the Router Advertisement."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - AdvOtherConfigFlag"; + } + leaf link-mtu { + type uint32; + default "0"; + description + "The value to be placed in MTU options sent by the + router. A value of zero indicates that no MTU options + are sent."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - AdvLinkMTU"; + } + leaf reachable-time { + type uint32 { + range "0..3600000"; + } + units "milliseconds"; + default "0"; + description + "The value to be placed in the Reachable Time field in + the Router Advertisement messages sent by the router. + A value of zero means unspecified (by this router)."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - AdvReachableTime"; + } + leaf retrans-timer { + type uint32; + units "milliseconds"; + default "0"; + description + "The value to be placed in the Retrans Timer field in + the Router Advertisement messages sent by the router. + A value of zero means unspecified (by this router)."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - AdvRetransTimer"; + } + leaf cur-hop-limit { + type uint8; + description + "The value to be placed in the Cur Hop Limit field in + the Router Advertisement messages sent by the router. + A value of zero means unspecified (by this router). + + If this parameter is not configured, the device SHOULD + use the IANA-specified value for the default IPv4 + Time to Live (TTL) parameter that was in effect at the + time of implementation."; + reference + "RFC 3232: Assigned Numbers: RFC 1700 is Replaced by + an On-line Database + RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - AdvCurHopLimit + IANA: IP Parameters + (https://www.iana.org/assignments/ip-parameters)"; + } + leaf default-lifetime { + type uint16 { + range "0..65535"; + } + units "seconds"; + description + "The value to be placed in the Router Lifetime field of + Router Advertisements sent from the interface, in + seconds. It MUST be either zero or between + max-rtr-adv-interval and 9000 seconds. A value of zero + indicates that the router is not to be used as a + default router. These limits may be overridden by + specific documents that describe how IPv6 operates over + different link layers. + + If this parameter is not configured, the device SHOULD + use a value of 3 * max-rtr-adv-interval."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - AdvDefaultLifetime"; + } + container prefix-list { + description + "Support for prefixes to be placed in Prefix + Information options in Router Advertisement messages + sent from the interface. + + Prefixes that are advertised by default but do not + have their entries in the child 'prefix' list are + advertised with the default values of all parameters. + + The link-local prefix SHOULD NOT be included in the + list of advertised prefixes."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + - AdvPrefixList"; + list prefix { + key "prefix-spec"; + description + "Support for an advertised prefix entry."; + leaf prefix-spec { + type inet:ipv6-prefix; + description + "IPv6 address prefix."; + } + choice control-adv-prefixes { + default "advertise"; + description + "Either (1) the prefix is explicitly removed from the + set of advertised prefixes or (2) the parameters with + which the prefix is advertised are specified (default + case)."; + leaf no-advertise { + type empty; + description + "The prefix will not be advertised. + + This can be used for removing the prefix from + the default set of advertised prefixes."; + } + case advertise { + leaf valid-lifetime { + type uint32; + units "seconds"; + default "2592000"; + description + "The value to be placed in the Valid Lifetime + in the Prefix Information option. The + designated value of all 1's (0xffffffff) + represents infinity."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 + (IPv6) - AdvValidLifetime"; + } + leaf on-link-flag { + type boolean; + default "true"; + description + "The value to be placed in the on-link flag + ('L-bit') field in the Prefix Information + option."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 + (IPv6) - AdvOnLinkFlag"; + } + leaf preferred-lifetime { + type uint32; + units "seconds"; + must ". <= ../valid-lifetime" { + description + "This value MUST NOT be greater than + valid-lifetime."; + } + default "604800"; + description + "The value to be placed in the Preferred + Lifetime in the Prefix Information option. + The designated value of all 1's (0xffffffff) + represents infinity."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 + (IPv6) - AdvPreferredLifetime"; + } + leaf autonomous-flag { + type boolean; + default "true"; + description + "The value to be placed in the Autonomous Flag + field in the Prefix Information option."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 + (IPv6) - AdvAutonomousFlag"; + } + } + } + } + } + } + } + + /* + * The subsequent data nodes are obviated and obsoleted + * by the Network Management Datastore Architecture + * as described in RFC 8342. + */ + augment "/if:interfaces-state/if:interface/ip:ipv6" { + status obsolete; + description + "Augments interface state data with parameters of IPv6 + Router Advertisements."; + container ipv6-router-advertisements { + status obsolete; + description + "Parameters of IPv6 Router Advertisements."; + leaf send-advertisements { + type boolean; + status obsolete; + description + "A flag indicating whether or not the router sends + periodic Router Advertisements and responds to + Router Solicitations."; + } + leaf max-rtr-adv-interval { + type uint16 { + range "4..1800"; + } + units "seconds"; + status obsolete; + description + "The maximum time allowed between sending unsolicited + multicast Router Advertisements from the interface."; + } + leaf min-rtr-adv-interval { + type uint16 { + range "3..1350"; + } + units "seconds"; + status obsolete; + description + "The minimum time allowed between sending unsolicited + multicast Router Advertisements from the interface."; + } + leaf managed-flag { + type boolean; + status obsolete; + description + "The value that is placed in the 'Managed address + configuration' flag field in the Router Advertisement."; + } + leaf other-config-flag { + type boolean; + status obsolete; + description + "The value that is placed in the 'Other configuration' flag + field in the Router Advertisement."; + } + leaf link-mtu { + type uint32; + status obsolete; + description + "The value that is placed in MTU options sent by the + router. A value of zero indicates that no MTU options + are sent."; + } + leaf reachable-time { + type uint32 { + range "0..3600000"; + } + units "milliseconds"; + status obsolete; + description + "The value that is placed in the Reachable Time field in + the Router Advertisement messages sent by the router. A + value of zero means unspecified (by this router)."; + } + leaf retrans-timer { + type uint32; + units "milliseconds"; + status obsolete; + description + "The value that is placed in the Retrans Timer field in the + Router Advertisement messages sent by the router. A value + of zero means unspecified (by this router)."; + } + leaf cur-hop-limit { + type uint8; + status obsolete; + description + "The value that is placed in the Cur Hop Limit field in the + Router Advertisement messages sent by the router. A value + of zero means unspecified (by this router)."; + } + leaf default-lifetime { + type uint16 { + range "0..9000"; + } + units "seconds"; + status obsolete; + description + "The value that is placed in the Router Lifetime field of + Router Advertisements sent from the interface, in seconds. + A value of zero indicates that the router is not to be + used as a default router."; + } + container prefix-list { + status obsolete; + description + "A list of prefixes that are placed in Prefix Information + options in Router Advertisement messages sent from the + interface. + + By default, these are all prefixes that the router + advertises via routing protocols as being on-link for the + interface from which the advertisement is sent."; + list prefix { + key "prefix-spec"; + status obsolete; + description + "Advertised prefix entry and its parameters."; + leaf prefix-spec { + type inet:ipv6-prefix; + status obsolete; + description + "IPv6 address prefix."; + } + leaf valid-lifetime { + type uint32; + units "seconds"; + status obsolete; + description + "The value that is placed in the Valid Lifetime in the + Prefix Information option. The designated value of + all 1's (0xffffffff) represents infinity. + + An implementation SHOULD keep this value constant in + consecutive advertisements, except when it is + explicitly changed in configuration."; + } + leaf on-link-flag { + type boolean; + status obsolete; + description + "The value that is placed in the on-link flag ('L-bit') + field in the Prefix Information option."; + } + leaf preferred-lifetime { + type uint32; + units "seconds"; + status obsolete; + description + "The value that is placed in the Preferred Lifetime in + the Prefix Information option, in seconds. The + designated value of all 1's (0xffffffff) represents + infinity. + + An implementation SHOULD keep this value constant in + consecutive advertisements, except when it is + explicitly changed in configuration."; + } + leaf autonomous-flag { + type boolean; + status obsolete; + description + "The value that is placed in the Autonomous Flag field + in the Prefix Information option."; + } + } + } + } + } +} diff --git a/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-unicast-routing@2017-09-17.yang b/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-unicast-routing@2017-09-17.yang deleted file mode 100644 index 9d955dfaf..000000000 --- a/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-unicast-routing@2017-09-17.yang +++ /dev/null @@ -1,848 +0,0 @@ -module hc2vpp-ietf-ipv6-unicast-routing { - - namespace "urn:ietf:params:xml:ns:yang:ietf-ipv6-unicast-routing"; - - prefix "v6ur"; - - import vpp-routing-table-lookup { - prefix "vpp-tl"; - } - - import hc2vpp-ietf-routing { - prefix "rt"; - revision-date 2014-05-24; - } - - import ietf-inet-types { - prefix "inet"; - } - - import ietf-interfaces { - prefix "if"; - } - - import ietf-ip { - prefix "ip"; - } - - //TODO modification needed because of yangtools bug(unable to proceed augmentation in separate model of augmentation in this model) - import vpp-routing { - prefix vpp-r; - } - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: Thomas Nadeau - - - WG Chair: Juergen Schoenwaelder - - - Editor: Ladislav Lhotka - "; - - description - "This YANG module augments the 'ietf-routing' module with basic - configuration and operational state data for IPv6 unicast - routing. - - Copyright (c) 2014 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject to - the license terms contained in, the Simplified BSD License set - forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see the - RFC itself for full legal notices."; - - revision 2017-09-17 { - description - "Table lookup support"; - } - - revision 2014-05-25 { - description - "Initial revision."; - reference - "RFC XXXX: A YANG Data Model for Routing Management"; - } - - /* Identities */ - - identity ipv6-unicast { - base rt:ipv6; - description - "This identity represents the IPv6 unicast address family."; - } - - /* Operational state data */ - - augment "/rt:routing-state/rt:routing-instance/rt:interfaces/" - + "rt:interface" { - description - "IPv6-specific parameters of router interfaces."; - container ipv6-router-advertisements { - description - "Parameters of IPv6 Router Advertisements."; - leaf send-advertisements { - type boolean; - description - "A flag indicating whether or not the router sends periodic - Router Advertisements and responds to Router - Solicitations."; - } - leaf max-rtr-adv-interval { - type uint16 { - range "4..1800"; - } - units "seconds"; - description - "The maximum time allowed between sending unsolicited - multicast Router Advertisements from the interface."; - } - leaf min-rtr-adv-interval { - type uint16 { - range "3..1350"; - } - units "seconds"; - description - "The minimum time allowed between sending unsolicited - multicast Router Advertisements from the interface."; - } - leaf managed-flag { - type boolean; - description - "The value that is placed in the 'Managed address - configuration' flag field in the Router Advertisement."; - } - leaf other-config-flag { - type boolean; - description - "The value that is placed in the 'Other configuration' flag - field in the Router Advertisement."; - } - leaf link-mtu { - type uint32; - description - "The value that is placed in MTU options sent by the - router. A value of zero indicates that no MTU options are - sent."; - } - leaf reachable-time { - type uint32 { - range "0..3600000"; - } - units "milliseconds"; - description - "The value that is placed in the Reachable Time field in - the Router Advertisement messages sent by the router. A - value of zero means unspecified (by this router)."; - } - leaf retrans-timer { - type uint32; - units "milliseconds"; - description - "The value that is placed in the Retrans Timer field in the - Router Advertisement messages sent by the router. A value - of zero means unspecified (by this router)."; - } - leaf cur-hop-limit { - type uint8; - description - "The value that is placed in the Cur Hop Limit field in the - Router Advertisement messages sent by the router. A value - of zero means unspecified (by this router)."; - } - leaf default-lifetime { - type uint16 { - range "0..9000"; - } - units "seconds"; - description - "The value that is placed in the Router Lifetime field of - Router Advertisements sent from the interface, in seconds. - A value of zero indicates that the router is not to be - used as a default router."; - } - container prefix-list { - description - "A list of prefixes that are placed in Prefix Information - options in Router Advertisement messages sent from the - interface. - - By default, these are all prefixes that the router - advertises via routing protocols as being on-link for the - interface from which the advertisement is sent."; - list prefix { - key "prefix-spec"; - description - "Advertised prefix entry and its parameters."; - leaf prefix-spec { - type inet:ipv6-prefix; - description - "IPv6 address prefix."; - } - leaf valid-lifetime { - type uint32; - units "seconds"; - description - "The value that is placed in the Valid Lifetime in the - Prefix Information option. The designated value of all - 1's (0xffffffff) represents infinity."; - } - leaf on-link-flag { - type boolean; - description - "The value that is placed in the on-link flag ('L-bit') - field in the Prefix Information option."; - } - leaf preferred-lifetime { - type uint32; - units "seconds"; - description - "The value that is placed in the Preferred Lifetime in - the Prefix Information option, in seconds. The - designated value of all 1's (0xffffffff) represents - infinity."; - } - leaf autonomous-flag { - type boolean; - description - "The value that is placed in the Autonomous Flag field - in the Prefix Information option."; - } - } - } - } - } - - augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route" { - when "../../rt:address-family = 'v6ur:ipv6-unicast'" { - description - "This augment is valid only for IPv6 unicast."; - } - description - "This leaf augments an IPv6 unicast route."; - leaf destination-prefix { - type inet:ipv6-prefix; - description - "IPv6 destination prefix."; - } - } - - augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route/" - + "rt:next-hop-options/rt:simple-next-hop" { - when "../../rt:address-family = 'v6ur:ipv6-unicast'" { - description - "This augment is valid only for IPv6 unicast."; - } - description - "This leaf augments the 'simple-next-hop' case of IPv6 unicast - routes."; - leaf next-hop { - type inet:ipv6-address; - description - "IPv6 address of the next-hop."; - } - } - - augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route/" - + "rt:next-hop-options/rt:next-hop-list/rt:next-hop-list/" - + "rt:next-hop" { - when "../../../../rt:address-family = 'v6ur:ipv6-unicast'" { - description - "This augment is valid only for IPv6 unicast."; - } - if-feature rt:multipath-routes; - description - "This leaf augments the 'next-hop-list' case of IPv6 unicast - routes."; - leaf address { - type inet:ipv6-address; - description - "IPv6 address of the next-hop."; - } - } - - /* Configuration data */ - - augment - "/rt:routing/rt:routing-instance/rt:interfaces/rt:interface" { - when "/if:interfaces/if:interface[if:name=current()/rt:name]/" - + "ip:ipv6/ip:enabled='true'" { - description - "This augment is only valid for router interfaces with - enabled IPv6."; - } - description - "Configuration of IPv6-specific parameters of router - interfaces."; - container ipv6-router-advertisements { - description - "Configuration of IPv6 Router Advertisements."; - leaf send-advertisements { - type boolean; - default "false"; - description - "A flag indicating whether or not the router sends periodic - Router Advertisements and responds to Router - Solicitations."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - AdvSendAdvertisements."; - } - leaf max-rtr-adv-interval { - type uint16 { - range "4..1800"; - } - units "seconds"; - default "600"; - description - "The maximum time allowed between sending unsolicited - multicast Router Advertisements from the interface."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - MaxRtrAdvInterval."; - } - leaf min-rtr-adv-interval { - type uint16 { - range "3..1350"; - } - units "seconds"; - must ". <= 0.75 * ../max-rtr-adv-interval" { - description - "The value MUST NOT be greater than 75 % of - 'max-rtr-adv-interval'."; - } - description - "The minimum time allowed between sending unsolicited - multicast Router Advertisements from the interface. - - The default value to be used operationally if this leaf is - not configured is determined as follows: - - - if max-rtr-adv-interval >= 9 seconds, the default value - is 0.33 * max-rtr-adv-interval; - - - otherwise it is 0.75 * max-rtr-adv-interval."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - MinRtrAdvInterval."; - } - leaf managed-flag { - type boolean; - default "false"; - description - "The value to be placed in the 'Managed address - configuration' flag field in the Router Advertisement."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - AdvManagedFlag."; - } - leaf other-config-flag { - type boolean; - default "false"; - description - "The value to be placed in the 'Other configuration' flag - field in the Router Advertisement."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - AdvOtherConfigFlag."; - } - leaf link-mtu { - type uint32; - default "0"; - description - "The value to be placed in MTU options sent by the router. - A value of zero indicates that no MTU options are sent."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - AdvLinkMTU."; - } - leaf reachable-time { - type uint32 { - range "0..3600000"; - } - units "milliseconds"; - default "0"; - description - "The value to be placed in the Reachable Time field in the - Router Advertisement messages sent by the router. A value - of zero means unspecified (by this router)."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - AdvReachableTime."; - } - leaf retrans-timer { - type uint32; - units "milliseconds"; - default "0"; - description - "The value to be placed in the Retrans Timer field in the - Router Advertisement messages sent by the router. A value - of zero means unspecified (by this router)."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - AdvRetransTimer."; - } - leaf cur-hop-limit { - type uint8; - description - "The value to be placed in the Cur Hop Limit field in the - Router Advertisement messages sent by the router. A value - of zero means unspecified (by this router). - - If this parameter is not configured, the device SHOULD use - the value specified in IANA Assigned Numbers that was in - effect at the time of implementation."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - AdvCurHopLimit. - - IANA: IP Parameters, - http://www.iana.org/assignments/ip-parameters"; - } - leaf default-lifetime { - type uint16 { - range "0..9000"; - } - units "seconds"; - description - "The value to be placed in the Router Lifetime field of - Router Advertisements sent from the interface, in seconds. - It MUST be either zero or between max-rtr-adv-interval and - 9000 seconds. A value of zero indicates that the router is - not to be used as a default router. These limits may be - overridden by specific documents that describe how IPv6 - operates over different link layers. - - If this parameter is not configured, the device SHOULD use - a value of 3 * max-rtr-adv-interval."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - AdvDefaultLifeTime."; - } - container prefix-list { - description - "Configuration of prefixes to be placed in Prefix - Information options in Router Advertisement messages sent - from the interface. - - Prefixes that are advertised by default but do not have - their entries in the child 'prefix' list are advertised - with the default values of all parameters. - - The link-local prefix SHOULD NOT be included in the list - of advertised prefixes."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - - AdvPrefixList."; - list prefix { - key "prefix-spec"; - description - "Configuration of an advertised prefix entry."; - leaf prefix-spec { - type inet:ipv6-prefix; - description - "IPv6 address prefix."; - } - choice control-adv-prefixes { - default "advertise"; - description - "The prefix either may be explicitly removed from the - set of advertised prefixes, or parameters with which - it is advertised may be specified (default case)."; - leaf no-advertise { - type empty; - description - "The prefix will not be advertised. - - This can be used for removing the prefix from the - default set of advertised prefixes."; - } - case advertise { - leaf valid-lifetime { - type uint32; - units "seconds"; - default "2592000"; - description - "The value to be placed in the Valid Lifetime in - the Prefix Information option. The designated - value of all 1's (0xffffffff) represents - infinity."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 - (IPv6) - AdvValidLifetime."; - } - leaf on-link-flag { - type boolean; - default "true"; - description - "The value to be placed in the on-link flag - ('L-bit') field in the Prefix Information - option."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 - (IPv6) - AdvOnLinkFlag."; - } - leaf preferred-lifetime { - type uint32; - units "seconds"; - must ". <= ../valid-lifetime" { - description - "This value MUST NOT be greater than - valid-lifetime."; - } - default "604800"; - description - "The value to be placed in the Preferred Lifetime - in the Prefix Information option. The designated - value of all 1's (0xffffffff) represents - infinity."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 - (IPv6) - AdvPreferredLifetime."; - } - leaf autonomous-flag { - type boolean; - default "true"; - description - "The value to be placed in the Autonomous Flag - field in the Prefix Information option."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 - (IPv6) - AdvAutonomousFlag."; - } - } - } - } - } - } - } - - //NOTE - added same augmentation for operational state - - augment "/rt:routing-state/rt:routing-instance/rt:routing-protocols/rt:routing-protocol/rt:static-routes" { - description - "This augment defines the configuration of the 'static' - pseudo-protocol with data specific to IPv6 unicast."; - container ipv6 { - description - "Configuration of a 'static' pseudo-protocol instance - consists of a list of routes."; - list route { - key "id"; - ordered-by "user"; - description - "A user-ordered list of static routes."; - leaf id { - type uint32 { - //WARNING - range changed from 1..max to be mappable on vpp table ids - range "0..max"; - } - description - "Unique numeric identifier of the route. - - This value is unrelated to system-assigned 'id' - parameters of routes in RIBs."; - } - leaf description { - type string; - description - "Textual description of the route."; - } - leaf destination-prefix { - type inet:ipv6-prefix; - mandatory "true"; - description - "IPv6 destination prefix."; - } - choice next-hop-options { - mandatory "true"; - description - "Options for expressing the next-hop in static routes."; - case special-next-hop { - //WARNING - changed, see ietf-routing.yang - uses rt:special-next-hop-grouping; - } - - // TODO - HONEYCOMB-398/HC2VPP-237 - case table-lookup { - container table-lookup-params { - uses vpp-tl:table-lookup-case-params; - } - } - - case simple-next-hop { - leaf next-hop { - type inet:ipv6-address; - description - "IPv6 address of the next-hop."; - } - //TODO - temporarily set to absolute path until https://bugs.opendaylight.org/show_bug.cgi?id=6881 is resolved - leaf outgoing-interface { - type leafref { - path "/rt:routing/rt:routing-instance/rt:interfaces/rt:interface/" - + "rt:name"; - } - description - "Name of the outgoing interface. - - Only interfaces configured for the ancestor routing - instance can be given."; - } - } - case next-hop-list { - if-feature rt:multipath-routes; - container next-hop-list { - description - "Configuration of multiple next-hops."; - list next-hop { - key "id"; - description - "An entry of a next-hop list."; - leaf id { - type uint32; - description - "Unique numeric identifier of the entry. - - This value is unrelated to system-assigned 'id' - parameters of next-hops in RIBs."; - } - leaf address { - type inet:ipv6-address; - description - "IPv6 address of the next-hop."; - } - //TODO - temporarily set to absolute path until https://bugs.opendaylight.org/show_bug.cgi?id=6881 is resolved - leaf outgoing-interface { - type leafref { - path "/rt:routing/rt:routing-instance/rt:interfaces/rt:interface/" - + "rt:name"; - } - description - "Name of the outgoing interface. - - Only interfaces configured for the ancestor - routing instance can be given."; - } - uses rt:next-hop-classifiers { - refine "priority" { - default "primary"; - } - refine "weight" { - default "0"; - } - } - } - } - } - } - - //TODO modification needed because of yangtools bug(unable to proceed augmentation in separate model of augmentation in this model) - container vpp-ipv6-route-state{ - uses vpp-r:vpp-route-attributes; - } - } - } - } - - augment "/rt:routing/rt:routing-instance/rt:routing-protocols/rt:routing-protocol/rt:static-routes" { - description - "This augment defines the configuration of the 'static' - pseudo-protocol with data specific to IPv6 unicast."; - container ipv6 { - description - "Configuration of a 'static' pseudo-protocol instance - consists of a list of routes."; - list route { - key "id"; - ordered-by "user"; - description - "A user-ordered list of static routes."; - leaf id { - type uint32 { - //WARNING - range changed from 1..max to be mappable on vpp table ids - range "0..max"; - } - description - "Unique numeric identifier of the route. - - This value is unrelated to system-assigned 'id' - parameters of routes in RIBs."; - } - leaf description { - type string; - description - "Textual description of the route."; - } - leaf destination-prefix { - type inet:ipv6-prefix; - mandatory "true"; - description - "IPv6 destination prefix."; - } - choice next-hop-options { - mandatory "true"; - description - "Options for expressing the next-hop in static routes."; - case special-next-hop { - //WARNING - changed, see ietf-routing.yang - uses rt:special-next-hop-grouping; - } - - // TODO - HONEYCOMB-398/HC2VPP-237 - case table-lookup { - container table-lookup-params { - uses vpp-tl:table-lookup-case-params; - } - } - - case simple-next-hop { - leaf next-hop { - type inet:ipv6-address; - description - "IPv6 address of the next-hop."; - } - //TODO - temporarily set to absolute path until https://bugs.opendaylight.org/show_bug.cgi?id=6881 is resolved - leaf outgoing-interface { - type leafref { - path "/rt:routing/rt:routing-instance/rt:interfaces/rt:interface/" - + "rt:name"; - } - description - "Name of the outgoing interface. - - Only interfaces configured for the ancestor routing - instance can be given."; - } - } - case next-hop-list { - if-feature rt:multipath-routes; - container next-hop-list { - description - "Configuration of multiple next-hops."; - list next-hop { - key "id"; - description - "An entry of a next-hop list."; - leaf id { - type uint32; - description - "Unique numeric identifier of the entry. - - This value is unrelated to system-assigned 'id' - parameters of next-hops in RIBs."; - } - leaf address { - type inet:ipv6-address; - description - "IPv6 address of the next-hop."; - } - //TODO - temporarily set to absolute path until https://bugs.opendaylight.org/show_bug.cgi?id=6881 is resolved - leaf outgoing-interface { - type leafref { - path "/rt:routing/rt:routing-instance/rt:interfaces/rt:interface/" - + "rt:name"; - } - description - "Name of the outgoing interface. - - Only interfaces configured for the ancestor - routing instance can be given."; - } - uses rt:next-hop-classifiers { - refine "priority" { - default "primary"; - } - refine "weight" { - default "0"; - } - } - } - } - } - } - - //TODO modification needed because of yangtools bug(unable to proceed augmentation in separate model of augmentation in this model) - container vpp-ipv6-route{ - uses vpp-r:vpp-route-attributes; - } - } - } - } - - /* RPC methods */ - - augment "/rt:active-route/rt:input/rt:destination-address" { - when "rt:address-family='v6ur:ipv6-unicast'" { - description - "This augment is valid only for IPv6 unicast."; - } - description - "This leaf augments the 'rt:destination-address' parameter of - the 'rt:active-route' operation."; - leaf address { - type inet:ipv6-address; - description - "IPv6 destination address."; - } - } - - augment "/rt:active-route/rt:output/rt:route" { - when "rt:address-family='v6ur:ipv6-unicast'" { - description - "This augment is valid only for IPv6 unicast."; - } - description - "This leaf augments the reply to the 'rt:active-route' - operation."; - leaf destination-prefix { - type inet:ipv6-prefix; - description - "IPv6 destination prefix."; - } - } - - augment "/rt:active-route/rt:output/rt:route/rt:next-hop-options/" - + "rt:simple-next-hop" { - when "rt:address-family='v6ur:ipv6-unicast'" { - description - "This augment is valid only for IPv6 unicast."; - } - description - "This leaf augments the 'simple-next-hop' case in the reply to - the 'rt:active-route' operation."; - leaf next-hop { - type inet:ipv6-address; - description - "IPv6 address of the next-hop."; - } - } - - augment "/rt:active-route/rt:output/rt:route/rt:next-hop-options/" - + "rt:next-hop-list/rt:next-hop-list/rt:next-hop" { - when "../../rt:address-family='v6ur:ipv6-unicast'" { - description - "This augment is valid only for IPv6 unicast."; - } - if-feature rt:multipath-routes; - description - "This leaf augments the 'next-hop-list' case in the reply to - the 'rt:active-route' operation."; - leaf address { - type inet:ipv6-address; - description - "IPv6 address of the next-hop."; - } - } -} \ No newline at end of file diff --git a/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-unicast-routing@2018-03-13.yang b/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-unicast-routing@2018-03-13.yang new file mode 100755 index 000000000..664bce29f --- /dev/null +++ b/routing/routing-api/src/main/yang/hc2vpp-ietf-ipv6-unicast-routing@2018-03-13.yang @@ -0,0 +1,420 @@ +module hc2vpp-ietf-ipv6-unicast-routing { + yang-version "1.1"; + namespace + "urn:ietf:params:xml:ns:yang:ietf-ipv6-unicast-routing"; + prefix "v6ur"; + + /* + This models was modified due to ODL bugs described here: https://jira.fd.io/browse/HC2VPP-298. + Affected sections are renamed or commented, see comments below. + TODO: revert these changes and rename model to ietf-ipv6-unicast-routing once bugs are fixed. + */ + + import hc2vpp-ietf-routing { + prefix "rt"; + description + "An 'ietf-routing' module version that is compatible with + the Network Management Datastore Architecture (NMDA) + is required."; + } + + import ietf-inet-types { + prefix "inet"; + description + "An 'ietf-interfaces' module version that is compatible with + the Network Management Datastore Architecture (NMDA) + is required."; + } + + /* + Copied ietf-ip import from hc2vpp-ietf-ipv6-router-advertisements as a workaround + for https://jira.opendaylight.org/browse/YANGTOOLS-876. + + TODO: Remove ietf-ip import once YANGTOOLS-876 is fixed and HC adapts to proper yangtools version. + Bug fix will be available in yangtools 2.0.4 version. + */ + import ietf-ip { + prefix "ip"; + description + "An 'ietf-ip' module version that is compatible with + the Network Management Datastore Architecture (NMDA) + is required."; + } + + include hc2vpp-ietf-ipv6-router-advertisements { + revision-date 2018-03-13; + } + + organization + "IETF NETMOD (Network Modeling) Working Group"; + contact + "WG Web: + WG List: + + Editor: Ladislav Lhotka + + Acee Lindem + + Yingzhen Qu + "; + + description + "This YANG module augments the 'ietf-routing' module with basic + parameters for IPv6 unicast routing. The model fully conforms + to the Network Management Datastore Architecture (NMDA). + + Copyright (c) 2018 IETF Trust and the persons + identified as authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 8349; see + the RFC itself for full legal notices."; + + revision 2018-03-13 { + description + "Network Management Datastore Architecture (NMDA) revision."; + reference + "RFC 8349: A YANG Data Model for Routing Management + (NMDA Version)"; + } + + /* Identities */ + + revision 2016-11-04 { + description + "Initial revision."; + reference + "RFC 8022: A YANG Data Model for Routing Management"; + } + + identity ipv6-unicast { + base rt:ipv6; + description + "This identity represents the IPv6 unicast address family."; + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:routes/rt:route" { + when "derived-from-or-self(../../rt:address-family, " + + "'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + description + "This leaf augments an IPv6 unicast route."; + leaf destination-prefix { + type inet:ipv6-prefix; + description + "IPv6 destination prefix."; + } + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:routes/rt:route/" + + "rt:next-hop/rt:next-hop-options/rt:simple-next-hop" { + when "derived-from-or-self(../../../rt:address-family, " + + "'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + description + "Augments the 'simple-next-hop' case in IPv6 unicast routes."; + leaf next-hop-address { + type inet:ipv6-address; + description + "IPv6 address of the next hop."; + } + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:routes/rt:route/" + + "rt:next-hop/rt:next-hop-options/rt:next-hop-list/" + + "rt:next-hop-list/rt:next-hop" { + when "derived-from-or-self(../../../../../rt:address-family, " + + "'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + description + "This leaf augments the 'next-hop-list' case of IPv6 unicast + routes."; + leaf address { + type inet:ipv6-address; + description + "IPv6 address of the next hop."; + } + } + /* + TODO(HC2VPP-298): + needed to comment out action which caused problems probapby simmilar to: + https://jira.opendaylight.org/browse/YANGTOOLS-841 + + augment + "/rt:routing/rt:ribs/rt:rib/rt:active-route/rt:input" { + when "derived-from-or-self(../rt:address-family, " + + "'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast RIBs."; + } + description + "This augment adds the input parameter of the 'active-route' + action."; + leaf destination-address { + type inet:ipv6-address; + description + "IPv6 destination address."; + } + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route" { + when "derived-from-or-self(../../rt:address-family, " + + "'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + description + "This augment adds the destination prefix to the reply of the + 'active-route' action."; + leaf destination-prefix { + type inet:ipv6-prefix; + description + "IPv6 destination prefix."; + } + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route/rt:next-hop/rt:next-hop-options/" + + "rt:simple-next-hop" { + when "derived-from-or-self(../../../rt:address-family, " + + "'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + description + "Augments the 'simple-next-hop' case in the reply to the + 'active-route' action."; + leaf next-hop-address { + type inet:ipv6-address; + description + "IPv6 address of the next hop."; + } + } + + augment "/rt:routing/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route/rt:next-hop/rt:next-hop-options/" + + "rt:next-hop-list/rt:next-hop-list/rt:next-hop" { + when "derived-from-or-self(../../../../../rt:address-family, " + + "'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + description + "Augments the 'next-hop-list' case in the reply to the + 'active-route' action."; + leaf next-hop-address { + type inet:ipv6-address; + description + "IPv6 address of the next hop."; + } + } + */ + + /* Data node augmentations */ + + augment "/rt:routing/rt:control-plane-protocols/" + + "rt:control-plane-protocol/rt:static-routes" { + description + "This augment defines the 'static' pseudo-protocol + with data specific to IPv6 unicast."; + container ipv6 { + description + "Support for a 'static' pseudo-protocol instance + consists of a list of routes."; + list route { + key "destination-prefix"; + description + "A list of static routes."; + leaf destination-prefix { + type inet:ipv6-prefix; + mandatory true; + description + "IPv6 destination prefix."; + } + leaf description { + type string; + description + "Textual description of the route."; + } + container next-hop { + description + "Next hop for the route."; + uses rt:next-hop-content { + augment "next-hop-options/simple-next-hop" { + description + "Augments the 'simple-next-hop' case in IPv6 static + routes."; + leaf next-hop-address { + type inet:ipv6-address; + description + "IPv6 address of the next hop."; + } + } + augment "next-hop-options/next-hop-list/next-hop-list/" + + "next-hop" { + description + "Augments the 'next-hop-list' case in IPv6 static + routes."; + leaf next-hop-address { + type inet:ipv6-address; + description + "IPv6 address of the next hop."; + } + } + } + } + } + } + } + + /* + * The subsequent data nodes are obviated and obsoleted + * by the Network Management Datastore Architecture + * as described in RFC 8342. + */ + augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route" { + when "derived-from-or-self(../../rt:address-family, + 'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + status obsolete; + description + "This leaf augments an IPv6 unicast route."; + leaf destination-prefix { + type inet:ipv6-prefix; + status obsolete; + description + "IPv6 destination prefix."; + } + } + augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route/" + + "rt:next-hop/rt:next-hop-options/rt:simple-next-hop" { + when "derived-from-or-self(../../../rt:address-family, + 'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + status obsolete; + description + "Augments the 'simple-next-hop' case in IPv6 unicast routes."; + leaf next-hop-address { + type inet:ipv6-address; + status obsolete; + description + "IPv6 address of the next hop."; + } + } + augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route/" + + "rt:next-hop/rt:next-hop-options/rt:next-hop-list/" + + "rt:next-hop-list/rt:next-hop" { + when "derived-from-or-self(../../../../../rt:address-family, + 'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + status obsolete; + description + "This leaf augments the 'next-hop-list' case of IPv6 unicast + routes."; + leaf address { + type inet:ipv6-address; + status obsolete; + description + "IPv6 address of the next hop."; + } + } + /* + TODO(HC2VPP-298): + needed to comment out action which caused problems probapby simmilar to: + https://jira.opendaylight.org/browse/YANGTOOLS-841 + + augment "/rt:routing-state/rt:ribs/rt:rib/" + + "rt:active-route/rt:input" { + when "derived-from-or-self(../rt:address-family, + 'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast RIBs."; + } + status obsolete; + description + "This augment adds the input parameter of the 'active-route' + action."; + leaf destination-address { + type inet:ipv6-address; + status obsolete; + description + "IPv6 destination address."; + } + } + augment "/rt:routing-state/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route" { + when "derived-from-or-self(../../rt:address-family, + 'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + status obsolete; + description + "This augment adds the destination prefix to the reply of the + 'active-route' action."; + leaf destination-prefix { + type inet:ipv6-prefix; + status obsolete; + description + "IPv6 destination prefix."; + } + } + augment "/rt:routing-state/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route/rt:next-hop/rt:next-hop-options/" + + "rt:simple-next-hop" { + when "derived-from-or-self(../../../rt:address-family, + 'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + status obsolete; + description + "Augments the 'simple-next-hop' case in the reply to the + 'active-route' action."; + leaf next-hop-address { + type inet:ipv6-address; + status obsolete; + description + "IPv6 address of the next hop."; + } + } + augment "/rt:routing-state/rt:ribs/rt:rib/rt:active-route/" + + "rt:output/rt:route/rt:next-hop/rt:next-hop-options/" + + "rt:next-hop-list/rt:next-hop-list/rt:next-hop" { + when "derived-from-or-self(../../../../../rt:address-family, + 'v6ur:ipv6-unicast')" { + description + "This augment is valid only for IPv6 unicast."; + } + status obsolete; + description + "Augments the 'next-hop-list' case in the reply to the + 'active-route' action."; + leaf next-hop-address { + type inet:ipv6-address; + status obsolete; + description + "IPv6 address of the next hop."; + } + } + */ +} diff --git a/routing/routing-api/src/main/yang/hc2vpp-ietf-routing-types@2017-02-27.yang b/routing/routing-api/src/main/yang/hc2vpp-ietf-routing-types@2017-02-27.yang deleted file mode 100644 index 6d0f853a8..000000000 --- a/routing/routing-api/src/main/yang/hc2vpp-ietf-routing-types@2017-02-27.yang +++ /dev/null @@ -1,725 +0,0 @@ -module hc2vpp-ietf-routing-types { - - namespace "urn:ietf:params:xml:ns:yang:ietf-routing-types"; - prefix "rt-types"; - - import ietf-yang-types { - prefix "yang"; - } - - import ietf-inet-types { - prefix "inet"; - } - - organization "IETF Routing Area Working Group (rtgwg)"; - - contact - "Routing Area Working Group - "; - - description - "This module contains a collection of YANG data types - considered generally useful for routing protocols."; - - revision 2017-02-27 { - description - "Initial revision."; - reference - "RFC TBD: Routing YANG Data Types"; - } - - /*** collection of types related to routing ***/ - typedef router-id { - type yang:dotted-quad; - description - "A 32-bit number in the dotted quad format assigned to each - router. This number uniquely identifies the router within an - Autonomous System."; - } - - // address-family - identity address-family { - description - "Base identity from which identities describing address - families are derived."; - } - - identity ipv4 { - base address-family; - description - "This identity represents IPv4 address family."; - } - - identity ipv6 { - base address-family; - description - "This identity represents IPv6 address family."; - } - - //The rest of the values deinfed in the IANA registry - - identity nsap { - base address-family; - description - "Address family from IANA registry."; - } - identity hdlc { - base address-family; - description - "(8-bit multidrop) - Address family from IANA registry."; - } - identity bbn1822 { - base address-family; - description - "AHIP (BBN report #1822) - Address family from IANA registry."; - } - identity ieee802 { - base address-family; - description - "(includes all 802 media plus Ethernet canonical format) - Address family from IANA registry."; - } - identity e163 { - base address-family; - description - "Address family from IANA registry."; - } - identity e164 { - base address-family; - description - "SMDS, Frame Relay, ATM - Address family from IANA registry."; - } - identity f69 { - base address-family; - description - "(Telex) - Address family from IANA registry."; - } - identity x121 { - base address-family; - description - "(X.25, Frame Relay) - Address family from IANA registry."; - } - identity ipx { - base address-family; - description - "Address family from IANA registry."; - } - identity appletalk { - base address-family; - description - "Address family from IANA registry."; - } - identity decnet-iv { - base address-family; - description - "Decnet IV - Address family from IANA registry."; - } - identity vines { - base address-family; - description - "Banyan Vines - Address family from IANA registry."; - } - identity e164-nsap { - base address-family; - description - "E.164 with NSAP format subaddress - Address family from IANA registry."; - } - identity dns { - base address-family; - description - "Domain Name System - Address family from IANA registry."; - } - identity dn { - base address-family; - description - "Distinguished Name - Address family from IANA registry."; - } - identity as-num { - base address-family; - description - "AS Number - Address family from IANA registry."; - } - identity xtp-v4 { - base address-family; - description - "XTP over IPv4 - Address family from IANA registry."; - } - identity xtp-v6 { - base address-family; - description - "XTP over IPv6 - Address family from IANA registry."; - } - identity xtp { - base address-family; - description - "XTP native mode XTP - Address family from IANA registry."; - } - identity fc-port { - base address-family; - description - "Fibre Channel World-Wide Port Name - Address family from IANA registry."; - } - identity fc-node { - base address-family; - description - "Fibre Channel World-Wide Node Name - Address family from IANA registry."; - } - identity gwid { - base address-family; - description - "Address family from IANA registry."; - } - identity l2vpn { - base address-family; - description - "Address family from IANA registry."; - } - identity mpls-tp-section-eid { - base address-family; - description - "MPLS-TP Section Endpoint Identifier - Address family from IANA registry."; - } - identity mpls-tp-lsp-eid { - base address-family; - description - "MPLS-TP LSP Endpoint Identifier - Address family from IANA registry."; - } - identity mpls-tp-pwe-eid { - base address-family; - description - "MPLS-TP Pseudowire Endpoint Identifier - Address family from IANA registry."; - } - identity mt-v4 { - base address-family; - description - "Multi-Topology IPv4. - Address family from IANA registry."; - } - identity mt-v6 { - base address-family; - description - "Multi-Topology IPv6. - Address family from IANA registry."; - } - - /*** collection of types related to VPN ***/ - typedef route-target { - type string { - pattern - '(0:(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|' - + '[0-5]?\d{0,3}\d):(429496729[0-5]|42949672[0-8]\d|' - + '4294967[01]\d{2}|429496[0-6]\d{3}|42949[0-5]\d{4}|' - + '4294[0-8]\d{5}|429[0-3]\d{6}|42[0-8]\d{7}|4[01]\d{8}|' - + '[0-3]?\d{0,8}\d))|' - + '(1:(((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|' - + '1\d{2}|2[0-4]\d|25[0-5])):(6553[0-5]|655[0-2]\d|' - + '65[0-4]\d{2}|6[0-4]\d{3}|[0-5]?\d{0,3}\d))|' - + '(2:(429496729[0-5]|42949672[0-8]\d|4294967[01]\d{2}|' - + '429496[0-6]\d{3}|42949[0-5]\d{4}|4294[0-8]\d{5}|' - + '429[0-3]\d{6}|42[0-8]\d{7}|4[01]\d{8}|[0-3]?\d{0,8}\d):' - + '(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|' - + '[0-5]?\d{0,3}\d))'; - } - description - "A route target is an 8-octet BGP extended community - initially identifying a set of sites in a BGP - VPN (RFC 4364). However, it has since taken on a more - general role in BGP route filtering. - A route target consists of three fields: - a 2-octet type field, an administrator field, - and an assigned number field. - According to the data formats for type 0, 1, and 2 defined in - RFC4360 and RFC5668, the encoding pattern is defined as: - - 0:2-octet-asn:4-octet-number - 1:4-octet-ipv4addr:2-octet-number - 2:4-octet-asn:2-octet-number. - - Some valid examples are: 0:100:100, 1:1.1.1.1:100, and - 2:1234567890:203."; - reference - "RFC4360: BGP Extended Communities Attribute. - RFC5668: 4-Octet AS Specific BGP Extended Community."; - } - - typedef route-target-type { - type enumeration { - enum "import" { - value "0"; - description - "The route target applies to route import."; - } - enum "export" { - value "1"; - description - "The route target applies to route export."; - } - enum "both" { - value "2"; - description - "The route target applies to both route import and - route export."; - } - } - description - "Indicates the role a route target takes - in route filtering."; - reference - "RFC4364: BGP/MPLS IP Virtual Private Networks (VPNs)."; - } - - typedef route-distinguisher { - type string { - pattern - '(0:(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|' - + '[0-5]?\d{0,3}\d):(429496729[0-5]|42949672[0-8]\d|' - + '4294967[01]\d{2}|429496[0-6]\d{3}|42949[0-5]\d{4}|' - + '4294[0-8]\d{5}|429[0-3]\d{6}|42[0-8]\d{7}|4[01]\d{8}|' - + '[0-3]?\d{0,8}\d))|' - + '(1:(((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|' - + '1\d{2}|2[0-4]\d|25[0-5])):(6553[0-5]|655[0-2]\d|' - + '65[0-4]\d{2}|6[0-4]\d{3}|[0-5]?\d{0,3}\d))|' - + '(2:(429496729[0-5]|42949672[0-8]\d|4294967[01]\d{2}|' - + '429496[0-6]\d{3}|42949[0-5]\d{4}|4294[0-8]\d{5}|' - + '429[0-3]\d{6}|42[0-8]\d{7}|4[01]\d{8}|[0-3]?\d{0,8}\d):' - + '(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|' - + '[0-5]?\d{0,3}\d))|' - + '(([3-9a-fA-F]|[1-9a-fA-F][\da-fA-F]{1,3}):' - + '[\da-fA-F]{1,12})'; - } - description - "A route distinguisher is an 8-octet value used to distinguish - routes from different BGP VPNs (RFC 4364). A route - distinguisher consists of three fields: A 2-octet type field, - an administrator field, and an assigned number field. - According to the data formats for type 0, 1, and 2 defined in - RFC4364, the encoding pattern is defined as: - - 0:2-octet-asn:4-octet-number - 1:4-octet-ipv4addr:2-octet-number - 2:4-octet-asn:2-octet-number. - 2-octet-other-hex-number:6-octet-hex-number - - Some valid examples are: 0:100:100, 1:1.1.1.1:100, and - 2:1234567890:203."; - reference - "RFC4364: BGP/MPLS IP Virtual Private Networks (VPNs)."; - } - - /*** collection of types common to multicast ***/ - typedef ipv4-multicast-group-address { - type inet:ipv4-address { - pattern '(2((2[4-9])|(3[0-9]))\.).*'; - } - description - "This type represents an IPv4 multicast group address, - which is in the range from 224.0.0.0 to 239.255.255.255."; - reference - "RFC1112: Host Extensions for IP Multicasting."; - } - - typedef ipv6-multicast-group-address { - type inet:ipv6-address { - pattern - '(([fF]{2}[0-9a-fA-F]{2}):).*'; - } - description - "This type represents an IPv6 multicast group address, - which is in the range of FF00::/8."; - reference - "RFC4291: IP Version 6 Addressing Architecture. Sec 2.7. - RFC7346: IPv6 Multicast Address Scopes."; - } - - typedef ip-multicast-group-address { - type union { - type ipv4-multicast-group-address; - type ipv6-multicast-group-address; - } - description - "This type represents an IP multicast group address and is IP - version neutral. The format of the textual representation - implies the IP version."; - } - - typedef ipv4-multicast-source-address { - type union { - type enumeration { - enum 'any' { - /* - ODL does not support * as enum name (how it should be named to java identifier?) - enum '*' { - */ - description - "Any source address."; - } - } - type inet:ipv4-address; - } - description - "Multicast source IPv4 address type."; - } - - typedef ipv6-multicast-source-address { - type union { - type enumeration { - enum 'any' { - /* - ODL does not support * as enum name (how it should be named to java identifier?) - enum '*' { - */ - description - "Any source address."; - } - } - type inet:ipv6-address; - } - description - "Multicast source IPv6 address type."; - } - - /*** collection of types common to protocols ***/ - typedef bandwidth-ieee-float32 { - type string { - pattern - '0[xX](0((\.0?)?[pP](\+)?0?|(\.0?))|' - + '1(\.([\da-fA-F]{0,5}[02468aAcCeE]?)?)?[pP](\+)?(12[0-7]|' - + '1[01]\d|0?\d?\d)?)'; - } - description - "Bandwidth in IEEE 754 floating point 32-bit binary format: - (-1)**(S) * 2**(Exponent-127) * (1 + Fraction), - where Exponent uses 8 bits, and Fraction uses 23 bits. - The units are octets per second. - The encoding format is the external hexadecimal-significand - character sequences specified in IEEE 754 and C99, - restricted to be normalized, non-negative, and non-fraction: - 0x1.hhhhhhp{+}d or 0X1.HHHHHHP{+}D - where 'h' and 'H' are hexadecimal digits, 'd' and 'D' are - integers in the range of [0..127]. - When six hexadecimal digits are used for 'hhhhhh' or 'HHHHHH', - the least significant digit must be an even number. - 'x' and 'X' indicate hexadecimal; 'p' and 'P' indicate power - of two. - Some examples are: 0x0p0, 0x1p10, and 0x1.abcde2p+20"; - reference - "IEEE Std 754-2008: IEEE Standard for Floating-Point - Arithmetic."; - } - - typedef link-access-type { - type enumeration { - enum "broadcast" { - description - "Specify broadcast multi-access network."; - } - enum "non-broadcast-multiaccess" { - description - "Specify Non-Broadcast Multi-Access (NBMA) network."; - } - enum "point-to-multipoint" { - description - "Specify point-to-multipoint network."; - } - enum "point-to-point" { - description - "Specify point-to-point network."; - } - } - description - "Link access type."; - } - - typedef timer-multiplier { - type uint8; - description - "The number of timer value intervals that should be - interpreted as a failure."; - } - - typedef timer-value-seconds16 { - type union { - type uint16 { - range "1..65535"; - } - type enumeration { - enum "infinity" { - description "The timer is set to infinity."; - } - enum "not-set" { - description "The timer is not set."; - } - } - } - units seconds; - description "Timer value type, in seconds (16 bit range)."; - } - - typedef timer-value-seconds32 { - type union { - type uint32 { - range "1..4294967295"; - } - type enumeration { - enum "infinity" { - description "The timer is set to infinity."; - } - enum "not-set" { - description "The timer is not set."; - } - } - } - units seconds; - description "Timer value type, in seconds (32 bit range)."; - } - - typedef timer-value-milliseconds { - type union { - type uint32{ - range "1..4294967295"; - } - type enumeration { - enum "infinity" { - description "The timer is set to infinity."; - } - enum "not-set" { - description "The timer is not set."; - } - } - } - units milliseconds; - description "Timer value type, in milliseconds."; - } - - /*** collection of types related to MPLS/GMPLS ***/ - typedef generalized-label { - type binary; - description - "Generalized label. Nodes sending and receiving the - Generalized Label know the kinds of link they are - using. Hence, the Generalized Label does not identify - its type. Instead, nodes are expected to know from - the context and type of label to expect."; - reference "RFC3471: Section 3.2"; - } - - identity mpls-label-special-purpose-value { - description - "Base identity for deriving identities describing - special-purpose Multiprotocol Label Switching (MPLS) label - values."; - reference - "RFC7274: Allocating and Retiring Special-Purpose MPLS - Labels."; - } - - identity ipv4-explicit-null-label { - base mpls-label-special-purpose-value; - description - "This identity represents the IPv4 Explicit NULL Label."; - reference - "RFC3032: MPLS Label Stack Encoding. Section 2.1."; - } - - identity router-alert-label { - base mpls-label-special-purpose-value; - description - "This identity represents the Router Alert Label."; - reference - "RFC3032: MPLS Label Stack Encoding. Section 2.1."; - } - - identity ipv6-explicit-null-label { - base mpls-label-special-purpose-value; - description - "This identity represents the IPv6 Explicit NULL Label."; - reference - "RFC3032: MPLS Label Stack Encoding. Section 2.1."; - } - - identity implicit-null-label { - base mpls-label-special-purpose-value; - description - "This identity represents the Implicit NULL Label."; - reference - "RFC3032: MPLS Label Stack Encoding. Section 2.1."; - } - - identity entropy-label-indicator { - base mpls-label-special-purpose-value; - description - "This identity represents the Entropy Label Indicator."; - reference - "RFC6790: The Use of Entropy Labels in MPLS Forwarding. - Sections 3 and 10.1."; - } - - identity gal-label { - base mpls-label-special-purpose-value; - description - "This identity represents the Generic Associated Channel Label - (GAL)."; - reference - "RFC5586: MPLS Generic Associated Channel. - Sections 4 and 10."; - } - - identity oam-alert-label { - base mpls-label-special-purpose-value; - description - "This identity represents the OAM Alert Label."; - reference - "RFC3429: Assignment of the 'OAM Alert Label' for Multiprotocol - Label Switching Architecture (MPLS) Operation and Maintenance - (OAM) Functions. - Sections 3 and 6."; - } - - identity extension-label { - base mpls-label-special-purpose-value; - description - "This identity represents the Extension Label."; - reference - "RFC7274: Allocating and Retiring Special-Purpose MPLS Labels. - Sections 3.1 and 5."; - } - - typedef mpls-label-special-purpose { - type identityref { - base mpls-label-special-purpose-value; - } - description - "This type represents the special-purpose Multiprotocol Label - Switching (MPLS) label values."; - reference - "RFC3032: MPLS Label Stack Encoding. - RFC7274: Allocating and Retiring Special-Purpose MPLS - Labels."; - } - - typedef mpls-label-general-use { - type uint32 { - range "16..1048575"; - } - description - "The 20 bits label values in an MPLS label stack entry, - specified in RFC3032. This label value does not include - the encodings of Traffic Class and TTL (time to live). - The label range specified by this type is for general use, - with special-purpose MPLS label values excluded."; - reference - "RFC3032: MPLS Label Stack Encoding."; - } - - - typedef mpls-label { -/* -TODO: binding generator creates invalid type bindings, so we changed type to uint32. -Change back after https://jira.opendaylight.org/browse/MDSAL-269 is resolved. - type union { - type mpls-label-special-purpose; - type mpls-label-general-use; - } -*/ - type uint32 { - range "0..1048575"; - } - description - "The 20 bits label values in an MPLS label stack entry, - specified in RFC3032. This label value does not include - the encodings of Traffic Class and TTL (time to live)."; - reference - "RFC3032: MPLS Label Stack Encoding."; - } - - /* - * Groupings - */ - grouping mpls-label-stack { - description - "A grouping that specifies an MPLS label stack."; - container mpls-label-stack { - description - "Container for a list of MPLS label stack entries."; - list entry { - key "id"; - description - "List of MPLS label stack entries."; - leaf id { - type uint8; - description - "Identifies the sequence of an MPLS label stack entries. - An entry with smaller ID value is precedes an entry in - the label stack with a smaller ID."; - } - leaf label { - type rt-types:mpls-label; - description - "Label value."; - } - leaf ttl { - type uint8; - description - "Time to Live (TTL)."; - reference - "RFC3032: MPLS Label Stack Encoding."; - } - leaf traffic-class { - type uint8 { - range "0..7"; - } - description - "Traffic Class (TC)."; - reference - "RFC5462: Multiprotocol Label Switching (MPLS) Label - Stack Entry: 'EXP' Field Renamed to 'Traffic Class' - Field."; - } - } - } - } // mpls-label-stack - - grouping vpn-route-targets { - description - "A grouping that specifies Route Target import-export rules - used in the BGP enabled Virtual Private Networks (VPNs)."; - reference - "RFC4364: BGP/MPLS IP Virtual Private Networks (VPNs). - RFC4664: Framework for Layer 2 Virtual Private Networks - (L2VPNs)"; - list vpn-target { - key route-target; - description - "List of Route Targets."; - leaf route-target { - type rt-types:route-target; - description - "Route Target value"; - } - leaf route-target-type { - type rt-types:route-target-type; - mandatory true; - description - "Import/export type of the Route Target."; - } - } - } // vpn-route-targets -} diff --git a/routing/routing-api/src/main/yang/hc2vpp-ietf-routing-types@2017-12-04.yang b/routing/routing-api/src/main/yang/hc2vpp-ietf-routing-types@2017-12-04.yang new file mode 100755 index 000000000..a0d6e19ed --- /dev/null +++ b/routing/routing-api/src/main/yang/hc2vpp-ietf-routing-types@2017-12-04.yang @@ -0,0 +1,793 @@ +module hc2vpp-ietf-routing-types { + + namespace "urn:ietf:params:xml:ns:yang:ietf-routing-types"; + prefix rt-types; + + /* + This models was modified due to ODL bugs described here: https://jira.fd.io/browse/HC2VPP-298. + Affected sections are renamed or commented, see comments below. + TODO: revert these changes and rename model to ietf-routing-types once bugs are fixed. + */ + + import ietf-yang-types { + prefix yang; + } + import ietf-inet-types { + prefix inet; + } + + organization + "IETF RTGWG - Routing Area Working Group"; + contact + "WG Web: + WG List: + + Editors: Xufeng Liu + + Yingzhen Qu + + Acee Lindem + + Christian Hopps + + Lou Berger + "; + + description + "This module contains a collection of YANG data types + considered generally useful for routing protocols. + + Copyright (c) 2017 IETF Trust and the persons + identified as authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 8294; see + the RFC itself for full legal notices."; + revision 2017-12-04 { + description "Initial revision."; + reference + "RFC 8294: Common YANG Data Types for the Routing Area. + Section 3."; + } + + /*** Identities related to MPLS/GMPLS ***/ + + identity mpls-label-special-purpose-value { + description + "Base identity for deriving identities describing + special-purpose Multiprotocol Label Switching (MPLS) label + values."; + reference + "RFC 7274: Allocating and Retiring Special-Purpose MPLS + Labels."; + } + + identity ipv4-explicit-null-label { + base mpls-label-special-purpose-value; + description + "This identity represents the IPv4 Explicit NULL Label."; + reference + "RFC 3032: MPLS Label Stack Encoding. Section 2.1."; + } + + identity router-alert-label { + base mpls-label-special-purpose-value; + description + "This identity represents the Router Alert Label."; + reference + "RFC 3032: MPLS Label Stack Encoding. Section 2.1."; + } + + identity ipv6-explicit-null-label { + base mpls-label-special-purpose-value; + description + "This identity represents the IPv6 Explicit NULL Label."; + reference + "RFC 3032: MPLS Label Stack Encoding. Section 2.1."; + } + + identity implicit-null-label { + base mpls-label-special-purpose-value; + description + "This identity represents the Implicit NULL Label."; + reference + "RFC 3032: MPLS Label Stack Encoding. Section 2.1."; + } + + identity entropy-label-indicator { + base mpls-label-special-purpose-value; + description + "This identity represents the Entropy Label Indicator."; + reference + "RFC 6790: The Use of Entropy Labels in MPLS Forwarding. + Sections 3 and 10.1."; + } + + identity gal-label { + base mpls-label-special-purpose-value; + description + "This identity represents the Generic Associated Channel + (G-ACh) Label (GAL)."; + reference + "RFC 5586: MPLS Generic Associated Channel. + Sections 4 and 10."; + } + + identity oam-alert-label { + base mpls-label-special-purpose-value; + description + "This identity represents the OAM Alert Label."; + reference + "RFC 3429: Assignment of the 'OAM Alert Label' for + Multiprotocol Label Switching Architecture (MPLS) + Operation and Maintenance (OAM) Functions. + Sections 3 and 6."; + } + + identity extension-label { + base mpls-label-special-purpose-value; + description + "This identity represents the Extension Label."; + reference + "RFC 7274: Allocating and Retiring Special-Purpose MPLS + Labels. Sections 3.1 and 5."; + } + + /*** Collection of types related to routing ***/ + + typedef router-id { + type yang:dotted-quad; + description + "A 32-bit number in the dotted-quad format assigned to each + router. This number uniquely identifies the router within + an Autonomous System."; + } + + /*** Collection of types related to VPNs ***/ + + typedef route-target { + type string { + pattern + '(0:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0):(429496729[0-5]|' + + '42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|429496[0-6][0-9]{3}|' + + '42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|429[0-3][0-9]{6}|' + + '42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0))|' + + '(1:((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|' + + '25[0-5])\.){3}([0-9]|[1-9][0-9]|' + + '1[0-9]{2}|2[0-4][0-9]|25[0-5])):(6553[0-5]|' + + '655[0-2][0-9]|' + + '65[0-4][0-9]{2}|6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(2:(429496729[0-5]|42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|' + + '429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|' + + '429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0):' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(6(:[a-fA-F0-9]{2}){6})|' + + '(([3-57-9a-fA-F]|[1-9a-fA-F][0-9a-fA-F]{1,3}):' + + '[0-9a-fA-F]{1,12})'; + } + + description + "A Route Target is an 8-octet BGP extended community + initially identifying a set of sites in a BGP VPN + (RFC 4364). However, it has since taken on a more general + role in BGP route filtering. A Route Target consists of two + or three fields: a 2-octet Type field, an administrator + field, and, optionally, an assigned number field. + + According to the data formats for types 0, 1, 2, and 6 as + defined in RFC 4360, RFC 5668, and RFC 7432, the encoding + pattern is defined as: + + 0:2-octet-asn:4-octet-number + 1:4-octet-ipv4addr:2-octet-number + 2:4-octet-asn:2-octet-number + 6:6-octet-mac-address + + Additionally, a generic pattern is defined for future + Route Target types: + + 2-octet-other-hex-number:6-octet-hex-number + + Some valid examples are 0:100:100, 1:1.1.1.1:100, + 2:1234567890:203, and 6:26:00:08:92:78:00."; + reference + "RFC 4360: BGP Extended Communities Attribute. + RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs). + RFC 5668: 4-Octet AS Specific BGP Extended Community. + RFC 7432: BGP MPLS-Based Ethernet VPN."; + } + + typedef ipv6-route-target { + type string { + pattern + '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' + + '(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.){3}' + + '(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])))' + + ':' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)'; + pattern '((([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?))' + + ':' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)'; + } + description + "An IPv6 Route Target is a 20-octet BGP IPv6 Address + Specific Extended Community serving the same function + as a standard 8-octet Route Target, except that it only + allows an IPv6 address as the global administrator. + The format is . + + Two valid examples are 2001:db8::1:6544 and + 2001:db8::5eb1:791:6b37:17958."; + reference + "RFC 5701: IPv6 Address Specific BGP Extended Community + Attribute."; + } + + typedef route-target-type { + type enumeration { + enum import { + value 0; + description + "The Route Target applies to route import."; + } + enum export { + value 1; + description + "The Route Target applies to route export."; + } + + enum both { + value 2; + description + "The Route Target applies to both route import and + route export."; + } + } + description + "Indicates the role a Route Target takes in route filtering."; + reference + "RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs)."; + } + + typedef route-distinguisher { + type string { + pattern + '(0:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0):(429496729[0-5]|' + + '42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|429496[0-6][0-9]{3}|' + + '42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|429[0-3][0-9]{6}|' + + '42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0))|' + + '(1:((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|' + + '25[0-5])\.){3}([0-9]|[1-9][0-9]|' + + '1[0-9]{2}|2[0-4][0-9]|25[0-5])):(6553[0-5]|' + + '655[0-2][0-9]|' + + '65[0-4][0-9]{2}|6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(2:(429496729[0-5]|42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|' + + '429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|' + + '429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0):' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(6(:[a-fA-F0-9]{2}){6})|' + + '(([3-57-9a-fA-F]|[1-9a-fA-F][0-9a-fA-F]{1,3}):' + + '[0-9a-fA-F]{1,12})'; + } + + description + "A Route Distinguisher is an 8-octet value used to + distinguish routes from different BGP VPNs (RFC 4364). + A Route Distinguisher will have the same format as a + Route Target as per RFC 4360 and will consist of + two or three fields: a 2-octet Type field, an administrator + field, and, optionally, an assigned number field. + + According to the data formats for types 0, 1, 2, and 6 as + defined in RFC 4360, RFC 5668, and RFC 7432, the encoding + pattern is defined as: + + 0:2-octet-asn:4-octet-number + 1:4-octet-ipv4addr:2-octet-number + 2:4-octet-asn:2-octet-number + 6:6-octet-mac-address + + Additionally, a generic pattern is defined for future + route discriminator types: + + 2-octet-other-hex-number:6-octet-hex-number + + Some valid examples are 0:100:100, 1:1.1.1.1:100, + 2:1234567890:203, and 6:26:00:08:92:78:00."; + reference + "RFC 4360: BGP Extended Communities Attribute. + RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs). + RFC 5668: 4-Octet AS Specific BGP Extended Community. + RFC 7432: BGP MPLS-Based Ethernet VPN."; + } + + typedef route-origin { + type string { + pattern + '(0:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0):(429496729[0-5]|' + + '42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|429496[0-6][0-9]{3}|' + + '42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|429[0-3][0-9]{6}|' + + '42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0))|' + + '(1:((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|' + + '25[0-5])\.){3}([0-9]|[1-9][0-9]|' + + '1[0-9]{2}|2[0-4][0-9]|25[0-5])):(6553[0-5]|' + + '655[0-2][0-9]|' + + '65[0-4][0-9]{2}|6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(2:(429496729[0-5]|42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|' + + '429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|' + + '429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0):' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(6(:[a-fA-F0-9]{2}){6})|' + + '(([3-57-9a-fA-F]|[1-9a-fA-F][0-9a-fA-F]{1,3}):' + + '[0-9a-fA-F]{1,12})'; + } + description + "A Route Origin is an 8-octet BGP extended community + identifying the set of sites where the BGP route + originated (RFC 4364). A Route Origin will have the same + format as a Route Target as per RFC 4360 and will consist + of two or three fields: a 2-octet Type field, an + administrator field, and, optionally, an assigned number + field. + + According to the data formats for types 0, 1, 2, and 6 as + defined in RFC 4360, RFC 5668, and RFC 7432, the encoding + pattern is defined as: + + 0:2-octet-asn:4-octet-number + 1:4-octet-ipv4addr:2-octet-number + 2:4-octet-asn:2-octet-number + 6:6-octet-mac-address + Additionally, a generic pattern is defined for future + Route Origin types: + + 2-octet-other-hex-number:6-octet-hex-number + + Some valid examples are 0:100:100, 1:1.1.1.1:100, + 2:1234567890:203, and 6:26:00:08:92:78:00."; + reference + "RFC 4360: BGP Extended Communities Attribute. + RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs). + RFC 5668: 4-Octet AS Specific BGP Extended Community. + RFC 7432: BGP MPLS-Based Ethernet VPN."; + } + + typedef ipv6-route-origin { + type string { + pattern + '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' + + '(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.){3}' + + '(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])))' + + ':' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)'; + pattern '((([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?))' + + ':' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)'; + } + description + "An IPv6 Route Origin is a 20-octet BGP IPv6 Address + Specific Extended Community serving the same function + as a standard 8-octet route, except that it only allows + an IPv6 address as the global administrator. The format + is . + + Two valid examples are 2001:db8::1:6544 and + 2001:db8::5eb1:791:6b37:17958."; + reference + "RFC 5701: IPv6 Address Specific BGP Extended Community + Attribute."; + } + + /*** Collection of types common to multicast ***/ + + typedef ipv4-multicast-group-address { + type inet:ipv4-address { + pattern '(2((2[4-9])|(3[0-9]))\.).*'; + } + description + "This type represents an IPv4 multicast group address, + which is in the range of 224.0.0.0 to 239.255.255.255."; + reference + "RFC 1112: Host Extensions for IP Multicasting."; + } + + typedef ipv6-multicast-group-address { + type inet:ipv6-address { + pattern '(([fF]{2}[0-9a-fA-F]{2}):).*'; + } + description + "This type represents an IPv6 multicast group address, + which is in the range of ff00::/8."; + reference + "RFC 4291: IP Version 6 Addressing Architecture. Section 2.7. + RFC 7346: IPv6 Multicast Address Scopes."; + } + + typedef ip-multicast-group-address { + type union { + type ipv4-multicast-group-address; + type ipv6-multicast-group-address; + } + description + "This type represents a version-neutral IP multicast group + address. The format of the textual representation implies + the IP version."; + } + + typedef ipv4-multicast-source-address { + type union { + type enumeration { + /* Needed to change '*' to 'any' otherwise it will fail to build java classes from this enum + bug in mdsal reported here: https://jira.opendaylight.org/browse/MDSAL-332 + TODO(HC2VPP-298): change back to '*' when resolved + */ + enum any { + description + "Any source address."; + } + } + type inet:ipv4-address; + } + description + "Multicast source IPv4 address type."; + } + + typedef ipv6-multicast-source-address { + type union { + type enumeration { + /* Needed to change '*' to 'any' otherwise it will fail to build java classes from this enum + bug in mdsal reported here: https://jira.opendaylight.org/browse/MDSAL-332 + TODO(HC2VPP-298): change back to '*' when resolved + */ + enum any { + description + "Any source address."; + } + } + type inet:ipv6-address; + } + description + "Multicast source IPv6 address type."; + } + + /*** Collection of types common to protocols ***/ + + typedef bandwidth-ieee-float32 { + type string { + pattern + '0[xX](0((\.0?)?[pP](\+)?0?|(\.0?))|' + + '1(\.([0-9a-fA-F]{0,5}[02468aAcCeE]?)?)?[pP](\+)?(12[0-7]|' + + '1[01][0-9]|0?[0-9]?[0-9])?)'; + } + description + "Bandwidth in IEEE 754 floating-point 32-bit binary format: + (-1)**(S) * 2**(Exponent-127) * (1 + Fraction), + where Exponent uses 8 bits and Fraction uses 23 bits. + The units are octets per second. + The encoding format is the external hexadecimal-significant + character sequences specified in IEEE 754 and ISO/IEC C99. + The format is restricted to be normalized, non-negative, and + non-fraction: 0x1.hhhhhhp{+}d, 0X1.HHHHHHP{+}D, or 0x0p0, + where 'h' and 'H' are hexadecimal digits and 'd' and 'D' are + integers in the range of [0..127]. + When six hexadecimal digits are used for 'hhhhhh' or + 'HHHHHH', the least significant digit must be an even + number. 'x' and 'X' indicate hexadecimal; 'p' and 'P' + indicate a power of two. Some examples are 0x0p0, 0x1p10, + and 0x1.abcde2p+20."; + reference + "IEEE Std 754-2008: IEEE Standard for Floating-Point + Arithmetic. + ISO/IEC C99: Information technology - Programming + Languages - C."; + } + + typedef link-access-type { + type enumeration { + enum broadcast { + description + "Specify broadcast multi-access network."; + } + enum non-broadcast-multiaccess { + description + "Specify Non-Broadcast Multi-Access (NBMA) network."; + } + enum point-to-multipoint { + description + "Specify point-to-multipoint network."; + } + enum point-to-point { + description + "Specify point-to-point network."; + } + } + description + "Link access type."; + } + + typedef timer-multiplier { + type uint8; + description + "The number of timer value intervals that should be + interpreted as a failure."; + } + + typedef timer-value-seconds16 { + type union { + type uint16 { + range "1..65535"; + } + type enumeration { + enum infinity { + description + "The timer is set to infinity."; + } + enum not-set { + description + "The timer is not set."; + } + } + } + units "seconds"; + description + "Timer value type, in seconds (16-bit range)."; + } + + typedef timer-value-seconds32 { + type union { + type uint32 { + range "1..4294967295"; + } + type enumeration { + enum infinity { + description + "The timer is set to infinity."; + } + enum not-set { + description + "The timer is not set."; + } + } + } + units "seconds"; + description + "Timer value type, in seconds (32-bit range)."; + } + + typedef timer-value-milliseconds { + type union { + type uint32 { + range "1..4294967295"; + } + type enumeration { + enum infinity { + description + "The timer is set to infinity."; + } + enum not-set { + description + "The timer is not set."; + } + } + } + units "milliseconds"; + description + "Timer value type, in milliseconds."; + } + + typedef percentage { + type uint8 { + range "0..100"; + } + description + "Integer indicating a percentage value."; + } + + typedef timeticks64 { + type uint64; + description + "This type is based on the timeticks type defined in + RFC 6991, but with 64-bit width. It represents the time, + modulo 2^64, in hundredths of a second between two epochs."; + reference + "RFC 6991: Common YANG Data Types."; + } + + typedef uint24 { + type uint32 { + range "0..16777215"; + } + description + "24-bit unsigned integer."; + } + + /*** Collection of types related to MPLS/GMPLS ***/ + + typedef generalized-label { + type binary; + description + "Generalized Label. Nodes sending and receiving the + Generalized Label are aware of the link-specific + label context and type."; + reference + "RFC 3471: Generalized Multi-Protocol Label Switching (GMPLS) + Signaling Functional Description. Section 3.2."; + } + + typedef mpls-label-special-purpose { + type identityref { + base mpls-label-special-purpose-value; + } + description + "This type represents the special-purpose MPLS label values."; + reference + "RFC 3032: MPLS Label Stack Encoding. + RFC 7274: Allocating and Retiring Special-Purpose MPLS + Labels."; + } + + typedef mpls-label-general-use { + type uint32 { + range "16..1048575"; + } + description + "The 20-bit label value in an MPLS label stack as specified + in RFC 3032. This label value does not include the + encodings of Traffic Class and TTL (Time to Live). + The label range specified by this type is for general use, + with special-purpose MPLS label values excluded."; + reference + "RFC 3032: MPLS Label Stack Encoding."; + } + + typedef mpls-label { + /* + TODO: binding generator creates invalid type bindings, so we changed type to uint32. + Change back after https://jira.opendaylight.org/browse/MDSAL-269 is resolved. + type union { + type mpls-label-special-purpose; + type mpls-label-general-use; + } + */ + type uint32 { + range "0..1048575"; + } + description + "The 20-bit label value in an MPLS label stack as specified + in RFC 3032. This label value does not include the + encodings of Traffic Class and TTL."; + reference + "RFC 3032: MPLS Label Stack Encoding."; + } + + /*** Groupings **/ + + grouping mpls-label-stack { + description + "This grouping specifies an MPLS label stack. The label + stack is encoded as a list of label stack entries. The + list key is an identifier that indicates the relative + ordering of each entry, with the lowest-value identifier + corresponding to the top of the label stack."; + container mpls-label-stack { + description + "Container for a list of MPLS label stack entries."; + list entry { + key "id"; + description + "List of MPLS label stack entries."; + leaf id { + type uint8; + description + "Identifies the entry in a sequence of MPLS label + stack entries. An entry with a smaller identifier + value precedes an entry with a larger identifier + value in the label stack. The value of this ID has + no semantic meaning other than relative ordering + and referencing the entry."; + } + leaf label { + type rt-types:mpls-label; + description + "Label value."; + } + + leaf ttl { + type uint8; + description + "Time to Live (TTL)."; + reference + "RFC 3032: MPLS Label Stack Encoding."; + } + leaf traffic-class { + type uint8 { + range "0..7"; + } + description + "Traffic Class (TC)."; + reference + "RFC 5462: Multiprotocol Label Switching (MPLS) Label + Stack Entry: 'EXP' Field Renamed to 'Traffic Class' + Field."; + } + } + } + } + + grouping vpn-route-targets { + description + "A grouping that specifies Route Target import-export rules + used in BGP-enabled VPNs."; + reference + "RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs). + RFC 4664: Framework for Layer 2 Virtual Private Networks + (L2VPNs)."; + list vpn-target { + key "route-target"; + description + "List of Route Targets."; + leaf route-target { + type rt-types:route-target; + description + "Route Target value."; + } + leaf route-target-type { + type rt-types:route-target-type; + mandatory true; + description + "Import/export type of the Route Target."; + } + } + } +} diff --git a/routing/routing-api/src/main/yang/hc2vpp-ietf-routing@2014-05-24.yang b/routing/routing-api/src/main/yang/hc2vpp-ietf-routing@2014-05-24.yang deleted file mode 100644 index 63d163b27..000000000 --- a/routing/routing-api/src/main/yang/hc2vpp-ietf-routing@2014-05-24.yang +++ /dev/null @@ -1,1035 +0,0 @@ -module hc2vpp-ietf-routing { - - namespace "urn:ietf:params:xml:ns:yang:ietf-routing"; - - prefix "rt"; - - import ietf-yang-types { - prefix "yang"; - } - - import ietf-interfaces { - prefix "if"; - } - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: Thomas Nadeau - - - WG Chair: Juergen Schoenwaelder - - - Editor: Ladislav Lhotka - "; - - description - "This YANG module defines essential components for the management - of a routing subsystem. - - Copyright (c) 2014 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject to - the license terms contained in, the Simplified BSD License set - forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see the - RFC itself for full legal notices."; - - revision 2014-05-24 { - description - "Initial revision."; - reference - "RFC XXXX: A YANG Data Model for Routing Management"; - } - - /* Features */ - - feature multiple-ribs { - description - "This feature indicates that the device supports multiple RIBS - per address family, and the framework for passing routes - between RIBs. - - Devices that do not support this feature MUST provide exactly - one system-controlled RIB per supported address family. These - RIBs then appear as entries of the list - /routing-state/ribs/rib."; - } - - feature multipath-routes { - description - "This feature indicates that the device supports multipath - routes that have a list of next-hops."; - } - - /* Identities */ - - identity address-family { - description - "Base identity from which identities describing address - families are derived."; - } - - identity ipv4 { - base address-family; - description - "This identity represents IPv4 address family."; - } - - identity ipv6 { - base address-family; - description - "This identity represents IPv6 address family."; - } - - identity routing-instance-type { - description - "Base identity from which identities describing routing - instance types are derived. - - It is primarily intended for discriminating among different - types of logical routers or router virtualization."; - } - - identity standard-routing-instance { - base routing-instance-type; - description - "This identity represents a default routing instance."; - } - - identity routing-protocol { - description - "Base identity from which routing protocol identities are - derived."; - } - - identity direct { - base routing-protocol; - description - "Routing pseudo-protocol which provides routes to directly - connected networks."; - } - - identity static { - base routing-protocol; - description - "Static routing pseudo-protocol."; - } - - identity route-filter { - description - "Base identity from which all route filters are derived."; - } - - identity deny-all-route-filter { - base route-filter; - description - "Route filter that blocks all routes."; - } - - identity allow-all-route-filter { - base route-filter; - description - "Route filter that permits all routes."; - } - - /* Type Definitions */ - - typedef routing-instance-ref { - type leafref { - path "/rt:routing/rt:routing-instance/rt:name"; - } - description - "This type is used for leafs that reference a routing instance - configuration."; - } - - typedef routing-instance-state-ref { - type leafref { - path "/rt:routing-state/rt:routing-instance/rt:name"; - } - description - "This type is used for leafs that reference state data of a - routing instance."; - } - - typedef rib-ref { - type leafref { - path "/rt:routing/rt:ribs/rt:rib/rt:name"; - } - description - "This type is used for leafs that reference a RIB - configuration."; - } - - typedef rib-state-ref { - type leafref { - path "/rt:routing-state/rt:ribs/rt:rib/rt:name"; - } - description - "This type is used for leafs that reference a RIB in state - data."; - } - - typedef route-filter-ref { - type leafref { - path "/rt:routing/rt:route-filters/rt:route-filter/rt:name"; - } - description - "This type is used for leafs that reference a route filter - configuration."; - } - - typedef route-filter-state-ref { - type leafref { - path "/rt:routing-state/rt:route-filters/rt:route-filter/" - + "rt:name"; - } - description - "This type is used for leafs that reference a route filter in - state data."; - } - - /* Groupings */ - - grouping address-family-grouping { - description - "This grouping provides a leaf identifying an address - family."; - leaf address-family { - type identityref { - base address-family; - } - mandatory "true"; - description - "Address family."; - } - } - - grouping state-entry-id { - description - "This grouping defines a unique identifier for entries in - several operational state lists."; - leaf id { - type uint64; - description - "Unique numerical identifier of a list entry in operational - state. It may be used by protocols or tools that inspect - and/or manipulate operational state data and prefer - fixed-size integers as list entry handles. - - These identifiers are always ephemeral, i.e., they may - change after a reboot."; - } - } - - grouping router-id { - description - "This grouping provides the definition of router ID."; - leaf router-id { - type yang:dotted-quad; - description - "Router ID - 32-bit number in the form of a dotted quad. Some - protocols use this parameter for identifying a router to its - neighbors."; - } - } - - grouping outgoing-interface { - description - "This grouping defines the outgoing interface for use in - next-hops."; - leaf outgoing-interface { - type leafref { - path "/rt:routing-state/rt:routing-instance/rt:interfaces/" - + "rt:interface/rt:name"; - } - description - "Name of the outgoing interface."; - } - } - - // TODO(HC2VPP-273): renamed due to https://jira.opendaylight.org/browse/MDSAL-1 - // (having same name for grouping and it's leaf ends up in Java compilation error) - // - // Change grouping name back after switching to Binding Specificiation v2 (HONEYCOMB-420). - // - // grouping special-next-hop { - grouping special-next-hop-grouping { - description - "This grouping provides the leaf for specifying special - next-hop options."; - leaf special-next-hop { - type enumeration { - enum blackhole { - description - "Silently discard the packet."; - } - enum unreachable { - description - "Discard the packet and notify the sender with an error - message indicating that the destination host is - unreachable."; - } - enum prohibit { - description - "Discard the packet and notify the sender with an error - message indicating that the communication is - administratively prohibited."; - } - enum receive { - description - "The packet will be received by the local network - device."; - } - } - description - "Special next-hop options."; - } - } - - grouping next-hop-classifiers { - description - "This grouping provides two next-hop classifiers."; - leaf priority { - type enumeration { - enum primary { - value "1"; - description - "Primary next-hop."; - } - enum backup { - value "2"; - description - "Backup next-hop."; - } - } - description - "Simple priority for distinguishing between primary and - backup next-hops. - - Backup next-hops are used if and only if no primary - next-hops are reachable."; - } - leaf weight { - type uint8; - must ". = 0 or not(../../next-hop/weight = 0)" { - error-message "Illegal combination of zero and non-zero " - + "next-hop weights."; - description - "Next-hop weights must be either all zero (equal - load-balancing) or all non-zero."; - } - description - "This parameter specifies the weight of the next-hop for load - balancing. The number specifies the relative fraction of the - traffic that will use the corresponding next-hop. - - A value of 0 represents equal load-balancing. - - If both primary and backup next-hops are present, then the - weights for each priority level are used separately."; - } - } - - grouping next-hop-content { - description - "Generic parameters of next-hops in routes."; - choice next-hop-options { - mandatory "true"; - description - "Options for expressing the next-hop in routes."; - case special-next-hop { - uses special-next-hop-grouping; - } - case simple-next-hop { - uses outgoing-interface; - } - case next-hop-list { - if-feature multipath-routes; - container next-hop-list { - description - "Container for multiple next-hops."; - list next-hop { - key "id"; - description - "An entry of a next-hop list."; - uses state-entry-id; - uses outgoing-interface; - uses next-hop-classifiers; - } - } - } - } - } - - grouping route-metadata { - description - "Route metadata."; - leaf source-protocol { - type identityref { - base routing-protocol; - } - mandatory "true"; - description - "Type of the routing protocol from which the route - originated."; - } - leaf last-updated { - type yang:date-and-time; - description - "Time stamp of the last modification of the route. If the - route was never modified, it is the time when the route was - inserted into the RIB."; - } - } - - /* Operational state data */ - - container routing-state { - config "false"; - description - "Operational state of the routing subsystem."; - list routing-instance { - key "name"; - unique "id"; - description - "Each list entry is a container for operational state data of - a routing instance. - - An implementation MAY create one or more system-controlled - instances, other user-controlled instances MAY be created by - configuration."; - leaf name { - type string; - description - "The name of the routing instance. - - For system-controlled instances the name is persistent, - i.e., it SHOULD NOT change across reboots."; - } - uses state-entry-id { - refine "id" { - mandatory "true"; - } - } - leaf type { - type identityref { - base routing-instance-type; - } - description - "The routing instance type, primarily intended for - discriminating among different types of logical routers, - route virtualization, master-slave arrangements etc., - while keeping all routing instances in the same flat - list."; - } - uses router-id { - description - "Global router ID. - - An implementation may choose a value if none is - configured. - - Routing protocols that use router ID MAY override this - global parameter."; - } - container default-ribs { - description - "Default RIBs used by the routing instance."; - list default-rib { - key "address-family"; - description - "Each list entry specifies the default RIB for one - address family. - - The default RIB is operationally connected to all - routing protocols for which a connected RIB has not been - explicitly configured. - - The 'direct' pseudo-protocol is always connected to the - default RIBs."; - uses address-family-grouping; - leaf rib-name { - type rib-state-ref; - mandatory "true"; - description - "Name of an existing RIB to be used as the default RIB - for the given routing instance and address family."; - } - } - } - container interfaces { - description - "Network layer interfaces belonging to the routing - instance."; - list interface { - key "name"; - description - "List of network layer interfaces assigned to the routing - instance."; - leaf name { - type if:interface-state-ref; - description - "A reference to the name of a configured network layer - interface."; - } - } - } - container routing-protocols { - description - "Container for the list of routing protocol instances."; - list routing-protocol { - key "name"; - description - "Operational state of a routing protocol instance. - - An implementation MUST provide exactly one - system-controlled instance of the type 'direct'. Other - instances MAY be created by configuration."; - leaf name { - type string; - description - "The name of the routing protocol instance. - - For system-controlled instances this name is - persistent, i.e., it SHOULD NOT change across - reboots."; - } - leaf type { - type identityref { - base routing-protocol; - } - mandatory "true"; - description - "Type of the routing protocol."; - } - container connected-ribs { - description - "Container for connected RIBs."; - list connected-rib { - key "rib-name"; - description - "List of RIBs to which the routing protocol instance - is connected (at most one RIB per address - family)."; - leaf rib-name { - type rib-state-ref; - description - "Name of an existing RIB."; - } - leaf import-filter { - type route-filter-state-ref; - description - "Reference to a route filter that is used for - filtering routes passed from this routing protocol - instance to the RIB specified by the 'rib-name' - sibling node. - - If this leaf is not present, the behavior is - protocol-specific, but typically it means that all - routes are accepted."; - } - leaf export-filter { - type route-filter-state-ref; - description - "Reference to a route filter that is used for - filtering routes passed from the RIB specified by - the 'rib-name' sibling node to this routing - protocol instance. - - If this leaf is not present, the behavior is - protocol-specific - typically it means that all - routes are accepted. - - The 'direct' and 'static' pseudo-protocols accept - no routes from any RIB."; - } - } - } - - //NOTE -added to allow operational state for static-routes - container static-routes { - when "../type='rt:static'" { - description - "This container is only valid for the 'static' - routing protocol."; - } - description - "Configuration of the 'static' pseudo-protocol. - - Address family specific modules augment this node with - their lists of routes."; - } - } - } - } - container ribs { - description - "Container for RIBs."; - list rib { - key "name"; - unique "id"; - description - "Each entry represents a RIB identified by the 'name' key. - All routes in a RIB MUST belong to the same address - family. - - The server MUST provide a system-controlled default RIB - for each address family, and MAY provide other - system-controlled RIBs. Additional RIBs MAY be created in - the configuration."; - leaf name { - type string; - description - "The name of the RIB."; - } - uses state-entry-id { - refine "id" { - mandatory "true"; - } - } - uses address-family-grouping; - container routes { - description - "Current contents of the RIB."; - list route { - key "id"; - description - "A RIB route entry. This data node MUST be augmented - with information specific for routes of each address - family."; - uses state-entry-id; - uses next-hop-content; - uses route-metadata; - } - } - container recipient-ribs { - if-feature multiple-ribs; - description - "Container for recipient RIBs."; - list recipient-rib { - key "rib-name"; - description - "List of RIBs that receive routes from this RIB."; - leaf rib-name { - type rib-state-ref; - description - "The name of the recipient RIB."; - } - leaf filter { - type route-filter-state-ref; - description - "A route filter which is applied to the routes passed - to the recipient RIB."; - } - } - } - } - } - container route-filters { - description - "Container for route filters."; - list route-filter { - key "name"; - description - "Route filters are used for filtering and/or manipulating - routes that are passed between a routing protocol and a - RIB and vice versa, or between two RIBs. - - It is expected that other modules augment this list with - contents specific for a particular route filter type."; - leaf name { - type string; - description - "The name of the route filter."; - } - leaf type { - type identityref { - base route-filter; - } - mandatory "true"; - description - "Type of the route-filter - an identity derived from the - 'route-filter' base identity."; - } - } - } - } - - /* Configuration Data */ - - container routing { - description - "Configuration parameters for the routing subsystem."; - list routing-instance { - key "name"; - description - "Configuration of a routing instance."; - leaf name { - type string; - description - "The name of the routing instance. - - For system-controlled entries, the value of this leaf must - be the same as the name of the corresponding entry in - state data. - - For user-controlled entries, an arbitrary name can be - used."; - } - leaf type { - type identityref { - base routing-instance-type; - } - default "rt:standard-routing-instance"; - description - "The type of the routing instance."; - } - leaf enabled { - type boolean; - default "true"; - description - "Enable/disable the routing instance. - - If this parameter is false, the parent routing instance is - disabled and does not appear in operational state data, - despite any other configuration that might be present."; - } - uses router-id { - description - "Configuration of the global router ID."; - } - leaf description { - type string; - description - "Textual description of the routing instance."; - } - container default-ribs { - if-feature multiple-ribs; - description - "Configuration of the default RIBs used by the routing - instance. - - The default RIB for an addressed family if by default - connected to all routing protocol instances supporting - that address family, and always receives direct routes."; - list default-rib { - must "address-family=/routing/ribs/rib[name=current()/" - + "rib-name]/address-family" { - error-message "Address family mismatch."; - description - "The entry's address family MUST match that of the - referenced RIB."; - } - key "address-family"; - description - "Each list entry configures the default RIB for one - address family."; - uses address-family-grouping; - leaf rib-name { - type string; - mandatory "true"; - description - "Name of an existing RIB to be used as the default RIB - for the given routing instance and address family."; - } - } - } - container interfaces { - description - "Configuration of the routing instance's interfaces."; - list interface { - key "name"; - description - "List of network layer interfaces assigned to the routing - instance."; - leaf name { - type if:interface-ref; - description - "A reference to the name of a configured network layer - interface."; - } - } - } - container routing-protocols { - description - "Configuration of routing protocol instances."; - list routing-protocol { - key "name"; - description - "Each entry contains configuration of a routing protocol - instance."; - leaf name { - type string; - description - "An arbitrary name of the routing protocol instance."; - } - leaf description { - type string; - description - "Textual description of the routing protocol - instance."; - } - leaf enabled { - type boolean; - default "true"; - description - "Enable/disable the routing protocol instance. - - If this parameter is false, the parent routing - protocol instance is disabled and does not appear in - operational state data, despite any other - configuration that might be present."; - } - leaf type { - type identityref { - base routing-protocol; - } - mandatory "true"; - description - "Type of the routing protocol - an identity derived - from the 'routing-protocol' base identity."; - } - container connected-ribs { - description - "Configuration of connected RIBs."; - list connected-rib { - must "not(/routing/ribs/rib[name=current()/" - + "preceding-sibling::connected-rib/" - + "rib-name and address-family=/routing/ribs/" - + "rib[name=current()/rib-name]/address-family])" { - error-message - "Duplicate address family for connected RIBs."; - description - "For each address family, there MUST NOT be more - than one connected RIB."; - } - key "rib-name"; - description - "List of RIBs to which the routing protocol instance - is connected (at most one RIB per address family). - - If no connected RIB is configured for an address - family, the routing protocol is connected to the - default RIB for that address family."; - leaf rib-name { - type rib-ref; - must "../../../type != 'rt:direct' or " - + "../../../../../default-ribs/ " - + "default-rib/rib-name=." { - error-message "The 'direct' protocol can be " - + "connected only to a default RIB."; - description - "For the 'direct' pseudo-protocol, the connected - RIB must always be a default RIB."; - } - description - "Name of an existing RIB."; - } - leaf import-filter { - type route-filter-ref; - description - "Configuration of import filter."; - } - leaf export-filter { - type route-filter-ref; - description - "Configuration of export filter."; - } - } - } - container static-routes { - when "../type='rt:static'" { - description - "This container is only valid for the 'static' - routing protocol."; - } - description - "Configuration of the 'static' pseudo-protocol. - - Address family specific modules augment this node with - their lists of routes."; - } - } - } - } - container ribs { - description - "Configured RIBs."; - list rib { - key "name"; - description - "Each entry represents a configured RIB identified by the - 'name' key. - - Entries having the same key as a system-controlled entry - of the list /routing-state/ribs/rib are used for - configuring parameters of that entry. Other entries define - additional user-controlled RIBs."; - leaf name { - type string; - description - "The name of the RIB. - - For system-controlled entries, the value of this leaf - must be the same as the name of the corresponding entry - in state data. - - For user-controlled entries, an arbitrary name can be - used."; - } - uses address-family-grouping; - leaf description { - type string; - description - "Textual description of the RIB."; - } - container recipient-ribs { - if-feature multiple-ribs; - description - "Configuration of recipient RIBs."; - list recipient-rib { - must "rib-name != ../../name" { - error-message - "Source and recipient RIBs are identical."; - description - "A RIB MUST NOT appear among its recipient RIBs."; - } - must "/routing/ribs/rib[name=current()/rib-name]/" - + "address-family=../../address-family" { - error-message "Address family mismatch."; - description - "Address family of the recipient RIB MUST match that - of the source RIB."; - } - key "rib-name"; - description - "Each entry configures a recipient RIB."; - leaf rib-name { - type rib-ref; - description - "The name of the recipient RIB."; - } - leaf filter { - type route-filter-ref; - description - "A route filter which is applied to the routes passed - to the recipient RIB."; - } - } - } - } - } - container route-filters { - description - "Configuration of route filters."; - list route-filter { - key "name"; - description - "Each entry configures a named route filter."; - leaf name { - type string; - description - "The name of the route filter."; - } - leaf description { - type string; - description - "Textual description of the route filter."; - } - leaf type { - type identityref { - base route-filter; - } - mandatory "true"; - description - "Type of the route filter.."; - } - } - } - } - - /* RPC methods */ - - rpc active-route { - description - "Return the active route that a routing-instance uses for - sending packets to a destination address."; - input { - leaf routing-instance-name { - type routing-instance-state-ref; - mandatory "true"; - description - "Name of the routing instance whose forwarding information - base is being queried. - - If the routing instance with name equal to the value of - this parameter doesn't exist, then this operation SHALL - fail with error-tag 'data-missing' and error-app-tag - 'routing-instance-not-found'."; - } - container destination-address { - description - "Network layer destination address. - - Address family specific modules MUST augment this - container with a leaf named 'address'."; - uses address-family-grouping; - } - } - output { - container route { - description - "The active route for the specified destination. - - If the routing instance has no active route for the - destination address, no output is returned - the server - SHALL send an containing a single element - . - - Address family specific modules MUST augment this list - with appropriate route contents."; - uses address-family-grouping; - uses next-hop-content; - uses route-metadata; - } - } - } - - rpc route-count { - description - "Return the current number of routes in a RIB."; - input { - leaf rib-name { - type rib-state-ref; - mandatory "true"; - description - "Name of the RIB. - - If the RIB with name equal to the value of this parameter - doesn't exist, then this operation SHALL fail with - error-tag 'data-missing' and error-app-tag - 'rib-not-found'."; - } - } - output { - leaf number-of-routes { - type uint64; - mandatory "true"; - description - "Number of routes in the RIB."; - } - } - } -} \ No newline at end of file diff --git a/routing/routing-api/src/main/yang/hc2vpp-ietf-routing@2018-03-13.yang b/routing/routing-api/src/main/yang/hc2vpp-ietf-routing@2018-03-13.yang new file mode 100755 index 000000000..837ce7f67 --- /dev/null +++ b/routing/routing-api/src/main/yang/hc2vpp-ietf-routing@2018-03-13.yang @@ -0,0 +1,740 @@ +module hc2vpp-ietf-routing { + yang-version "1.1"; + namespace "urn:ietf:params:xml:ns:yang:ietf-routing"; + prefix "rt"; + + /* + This models was modified due to ODL bugs described here: https://jira.fd.io/browse/HC2VPP-298. + Affected sections are renamed or commented, see comments below. + TODO: revert these changes and rename model to ietf-routing once bugs are fixed. + */ + + import ietf-yang-types { + prefix "yang"; + } + + import ietf-interfaces { + prefix "if"; + description + "An 'ietf-interfaces' module version that is compatible with + the Network Management Datastore Architecture (NMDA) + is required."; + } + + /* + TODO remove vpp-routing-types when HONEYCOMB-398 is resolved + */ + import vpp-routing-types { + prefix vpp-routing-types; + } + + organization + "IETF NETMOD (Network Modeling) Working Group"; + contact + "WG Web: + WG List: + + Editor: Ladislav Lhotka + + Acee Lindem + + Yingzhen Qu + "; + + description + "This YANG module defines essential components for the management + of a routing subsystem. The model fully conforms to the Network + Management Datastore Architecture (NMDA). + + Copyright (c) 2018 IETF Trust and the persons + identified as authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + This version of this YANG module is part of RFC 8349; see + the RFC itself for full legal notices."; + + revision 2018-03-13 { + description + "Network Management Datastore Architecture (NMDA) revision."; + reference + "RFC 8349: A YANG Data Model for Routing Management + (NMDA Version)"; + } + + revision 2016-11-04 { + description + "Initial revision."; + reference + "RFC 8022: A YANG Data Model for Routing Management"; + } + + /* Features */ + feature multiple-ribs { + description + "This feature indicates that the server supports + user-defined RIBs. + + Servers that do not advertise this feature SHOULD provide + exactly one system-controlled RIB per supported address family + and also make it the default RIB. This RIB then appears as an + entry in the list '/routing/ribs/rib'."; + } + + feature router-id { + description + "This feature indicates that the server supports an explicit + 32-bit router ID that is used by some routing protocols. + + Servers that do not advertise this feature set a router ID + algorithmically, usually to one of the configured IPv4 + addresses. However, this algorithm is implementation + specific."; + } + + /* Identities */ + /* + added "-identity" to resolve class naming conflicts + bug in mdsal reported here: https://jira.opendaylight.org/browse/MDSAL-332 + TODO(HC2VPP-298): remove "-identity" postfix when resolved + */ + identity address-family-identity { + description + "Base identity from which identities describing address + families are derived."; + } + + /* + added "-identity" to resolve class naming conflicts + bug in mdsal reported here: https://jira.opendaylight.org/browse/MDSAL-332 + TODO(HC2VPP-298): remove "-identity" postfix when resolved + */ + identity ipv4 { + base rt:address-family-identity; + description + "This identity represents an IPv4 address family."; + } + + /* + added "-identity" to resolve class naming conflicts + bug in mdsal reported here: https://jira.opendaylight.org/browse/MDSAL-332 + TODO(HC2VPP-298): remove "-identity" postfix when resolved + */ + identity ipv6 { + base rt:address-family-identity; + description + "This identity represents an IPv6 address family."; + } + + identity control-plane-protocol { + description + "Base identity from which control-plane protocol identities are + derived."; + } + + identity routing-protocol { + base control-plane-protocol; + description + "Identity from which Layer 3 routing protocol identities are + derived."; + } + + identity direct { + base routing-protocol; + description + "Routing pseudo-protocol that provides routes to directly + connected networks."; + } + + identity static { + base routing-protocol; + description + "'Static' routing pseudo-protocol."; + } + + /* Type Definitions */ + + typedef route-preference { + type uint32; + description + "This type is used for route preferences."; + } + + /* Groupings */ + + grouping address-family { + description + "This grouping provides a leaf identifying an address + family."; + leaf address-family { + type identityref { + /* + added "-identity" to resolve class naming conflicts + bug in mdsal reported here: https://jira.opendaylight.org/browse/MDSAL-332 + TODO(HC2VPP-298): remove "-identity" postfix when resolved + */ + base rt:address-family-identity; + } + mandatory true; + description + "Address family."; + } + } + + grouping router-id { + description + "This grouping provides a router ID."; + leaf router-id { + type yang:dotted-quad; + description + "A 32-bit number in the form of a dotted quad that is used by + some routing protocols identifying a router."; + reference + "RFC 2328: OSPF Version 2"; + } + } + + grouping special-next-hop { + description + "This grouping provides a leaf with an enumeration of special + next hops."; + /* + added "-enum" to resolve class naming conflicts + bug in mdsal reported here: https://jira.opendaylight.org/browse/MDSAL-332 + TODO(HC2VPP-298): remove "-enum" postfix when resolved + */ + leaf special-next-hop-enum { + type enumeration { + enum blackhole { + description + "Silently discard the packet."; + } + enum unreachable { + description + "Discard the packet and notify the sender with an error + message indicating that the destination host is + unreachable."; + } + enum prohibit { + description + "Discard the packet and notify the sender with an error + message indicating that the communication is + administratively prohibited."; + } + enum receive { + description + "The packet will be received by the local system."; + } + } + description + "Options for special next hops."; + } + } + + grouping next-hop-content { + description + "Generic parameters of next hops in static routes."; + choice next-hop-options { + mandatory true; + description + "Options for next hops in static routes. + + It is expected that further cases will be added through + augments from other modules."; + case simple-next-hop { + description + "This case represents a simple next hop consisting of the + next-hop address and/or outgoing interface. + + Modules for address families MUST augment this case with a + leaf containing a next-hop address of that address + family."; + leaf outgoing-interface { + type if:interface-ref; + description + "Name of the outgoing interface."; + } + } + case special-next-hop { + uses special-next-hop; + } + case next-hop-list { + container next-hop-list { + description + "Container for multiple next hops."; + list next-hop { + key "index"; + description + "An entry in a next-hop list. + + Modules for address families MUST augment this list + with a leaf containing a next-hop address of that + address family."; + leaf index { + type string; + description + "A user-specified identifier utilized to uniquely + reference the next-hop entry in the next-hop list. + The value of this index has no semantic meaning + other than for referencing the entry."; + } + leaf outgoing-interface { + type if:interface-ref; + description + "Name of the outgoing interface."; + } + } + } + } + // table lookup case for VPP + // TODO - HONEYCOMB-398/HC2VPP-237 - move table lookup case to separate module + case table-lookup-case { + uses vpp-routing-types:table-lookup-case-params; + } + } + } + + grouping next-hop-state-content { + description + "Generic state parameters of next hops."; + choice next-hop-options { + mandatory true; + description + "Options for next hops. + + It is expected that further cases will be added through + augments from other modules, e.g., for recursive + next hops."; + case simple-next-hop { + description + "This case represents a simple next hop consisting of the + next-hop address and/or outgoing interface. + + Modules for address families MUST augment this case with a + leaf containing a next-hop address of that address + family."; + leaf outgoing-interface { + type if:interface-ref; + description + "Name of the outgoing interface."; + } + } + case special-next-hop { + uses special-next-hop; + } + case next-hop-list { + container next-hop-list { + description + "Container for multiple next hops."; + list next-hop { + description + "An entry in a next-hop list. + + Modules for address families MUST augment this list + with a leaf containing a next-hop address of that + address family."; + leaf outgoing-interface { + type if:interface-ref; + description + "Name of the outgoing interface."; + } + } + } + } + } + } + + grouping route-metadata { + description + "Common route metadata."; + leaf source-protocol { + type identityref { + base routing-protocol; + } + mandatory true; + description + "Type of the routing protocol from which the route + originated."; + } + leaf active { + type empty; + description + "The presence of this leaf indicates that the route is + preferred among all routes in the same RIB that have the + same destination prefix."; + } + leaf last-updated { + type yang:date-and-time; + description + "Timestamp of the last modification of the route. If the + route was never modified, it is the time when the route was + inserted into the RIB."; + } + } + + /* Data nodes */ + + container routing { + description + "Configuration parameters for the routing subsystem."; + uses router-id { + if-feature "router-id"; + description + "Support for the global router ID. Routing protocols + that use a router ID can use this parameter or override it + with another value."; + } + container interfaces { + config false; + description + "Network-layer interfaces used for routing."; + leaf-list interface { + type if:interface-ref; + description + "Each entry is a reference to the name of a configured + network-layer interface."; + } + } + container control-plane-protocols { + description + "Support for control-plane protocol instances."; + list control-plane-protocol { + key "type name"; + description + "Each entry contains a control-plane protocol instance."; + leaf type { + type identityref { + base control-plane-protocol; + } + description + "Type of the control-plane protocol -- an identity + derived from the 'control-plane-protocol' + base identity."; + } + leaf name { + type string; + description + "An arbitrary name of the control-plane protocol + instance."; + } + leaf description { + type string; + description + "Textual description of the control-plane protocol + instance."; + } + container static-routes { + when "derived-from-or-self(../type, 'rt:static')" { + description + "This container is only valid for the 'static' routing + protocol."; + } + description + "Support for the 'static' pseudo-protocol. + + Address-family-specific modules augment this node with + their lists of routes."; + } + } + } + container ribs { + description + "Support for RIBs."; + list rib { + key "name"; + description + "Each entry contains a configuration for a RIB identified + by the 'name' key. + + Entries having the same key as a system-controlled entry + in the list '/routing/ribs/rib' are used for + configuring parameters of that entry. Other entries + define additional user-controlled RIBs."; + leaf name { + type string; + description + "The name of the RIB. + + For system-controlled entries, the value of this leaf + must be the same as the name of the corresponding entry + in the operational state. + + For user-controlled entries, an arbitrary name can be + used."; + } + uses address-family { + description + "The address family of the system-controlled RIB."; + } + + leaf default-rib { + if-feature "multiple-ribs"; + type boolean; + default "true"; + config false; + description + "This flag has the value of 'true' if and only if the RIB + is the default RIB for the given address family. + + By default, control-plane protocols place their routes + in the default RIBs."; + } + container routes { + config false; + description + "Current contents of the RIB."; + list route { + description + "A RIB route entry. This data node MUST be augmented + with information specific to routes of each address + family."; + leaf route-preference { + type route-preference; + description + "This route attribute, also known as 'administrative + distance', allows for selecting the preferred route + among routes with the same destination prefix. A + smaller value indicates a route that is + more preferred."; + } + container next-hop { + description + "Route's next-hop attribute."; + uses next-hop-state-content; + } + uses route-metadata; + } + } + /* + TODO(HC2VPP-298): + needed to comment out action which caused problems probapby simmilar to: + https://jira.opendaylight.org/browse/YANGTOOLS-841 + + action active-route { + description + "Return the active RIB route that is used for the + destination address. + + Address-family-specific modules MUST augment input + parameters with a leaf named 'destination-address'."; + output { + container route { + description + "The active RIB route for the specified destination. + + If no route exists in the RIB for the destination + address, no output is returned. + + Address-family-specific modules MUST augment this + container with appropriate route contents."; + container next-hop { + description + "Route's next-hop attribute."; + uses next-hop-state-content; + } + uses route-metadata; + } + } + } + */ + leaf description { + type string; + description + "Textual description of the RIB."; + } + } + } + } + + /* + * The subsequent data nodes are obviated and obsoleted + * by the Network Management Datastore Architecture + * as described in RFC 8342. + */ + + container routing-state { + config false; + status obsolete; + description + "State data of the routing subsystem."; + uses router-id { + status obsolete; + description + "Global router ID. + + It may be either configured or assigned algorithmically by + the implementation."; + } + container interfaces { + status obsolete; + description + "Network-layer interfaces used for routing."; + leaf-list interface { + type if:interface-state-ref; + status obsolete; + description + "Each entry is a reference to the name of a configured + network-layer interface."; + } + } + container control-plane-protocols { + status obsolete; + description + "Container for the list of routing protocol instances."; + list control-plane-protocol { + key "type name"; + status obsolete; + description + "State data of a control-plane protocol instance. + + An implementation MUST provide exactly one + system-controlled instance of the 'direct' + pseudo-protocol. Instances of other control-plane + protocols MAY be created by configuration."; + leaf type { + type identityref { + base control-plane-protocol; + } + status obsolete; + description + "Type of the control-plane protocol."; + } + leaf name { + type string; + status obsolete; + description + "The name of the control-plane protocol instance. + + For system-controlled instances, this name is + persistent, i.e., it SHOULD NOT change across + reboots."; + } + } + } + container ribs { + status obsolete; + description + "Container for RIBs."; + list rib { + key "name"; + min-elements 1; + status obsolete; + description + "Each entry represents a RIB identified by the 'name' + key. All routes in a RIB MUST belong to the same address + family. + + An implementation SHOULD provide one system-controlled + default RIB for each supported address family."; + leaf name { + type string; + status obsolete; + description + "The name of the RIB."; + } + uses address-family { + status obsolete; + description + "The address family of the RIB."; + } + leaf default-rib { + if-feature "multiple-ribs"; + type boolean; + default "true"; + status obsolete; + description + "This flag has the value of 'true' if and only if the + RIB is the default RIB for the given address family. + + By default, control-plane protocols place their routes + in the default RIBs."; + } + container routes { + status obsolete; + description + "Current contents of the RIB."; + list route { + status obsolete; + description + "A RIB route entry. This data node MUST be augmented + with information specific to routes of each address + family."; + leaf route-preference { + type route-preference; + status obsolete; + description + "This route attribute, also known as 'administrative + distance', allows for selecting the preferred route + among routes with the same destination prefix. A + smaller value indicates a route that is + more preferred."; + } + container next-hop { + status obsolete; + description + "Route's next-hop attribute."; + uses next-hop-state-content { + status obsolete; + description + "Route's next-hop attribute operational state."; + } + } + uses route-metadata { + status obsolete; + description + "Route metadata."; + } + } + } + /* + TODO(HC2VPP-298): + needed to comment out action which caused problems probapby simmilar to: + https://jira.opendaylight.org/browse/YANGTOOLS-841 + + action active-route { + status obsolete; + description + "Return the active RIB route that is used for the + destination address. + + Address-family-specific modules MUST augment input + parameters with a leaf named 'destination-address'."; + output { + container route { + status obsolete; + description + "The active RIB route for the specified + destination. + + If no route exists in the RIB for the destination + address, no output is returned. + + Address-family-specific modules MUST augment this + container with appropriate route contents."; + container next-hop { + status obsolete; + description + "Route's next-hop attribute."; + uses next-hop-state-content { + status obsolete; + description + "Active route state data."; + } + } + uses route-metadata { + status obsolete; + description + "Active route metadata."; + } + } + } + } + */ + } + } + } +} diff --git a/routing/routing-api/src/main/yang/vpp-ipv4-unicast-routing@2018-03-19.yang b/routing/routing-api/src/main/yang/vpp-ipv4-unicast-routing@2018-03-19.yang new file mode 100644 index 000000000..d4147cc4b --- /dev/null +++ b/routing/routing-api/src/main/yang/vpp-ipv4-unicast-routing@2018-03-19.yang @@ -0,0 +1,78 @@ +module vpp-ipv4-unicast-routing { + + namespace "urn:ietf:params:xml:ns:yang:vpp-ipv4-unicast-routing"; + prefix "vpp-v4ur"; + + import yang-ext { + prefix "ext"; + } + + import vpp-classifier { + prefix "classifier"; + } + + import hc2vpp-ietf-routing { + prefix "ietf-r"; + revision-date 2018-03-13; + } + + import hc2vpp-ietf-ipv4-unicast-routing { + prefix "v4ur"; + revision-date 2018-03-13; + } + + import vpp-routing { + prefix "vpp-rt"; + revision-date 2018-03-19; + } + + import vpp-routing-types { + prefix "vpp-rt-tp"; + revision-date 2018-04-06; + } + + organization + "FD.io - The Fast Data Project"; + + contact + "Hc2vpp Wiki + Mailing List "; + + description + "This module contains a collection of YANG definitions + that extend hc2vpp-ietf-routing module + with VPP specific ipv4 unicast routing features. + + Copyright (c) 2018 Bell Canada, Pantheon.tech and/or its affiliates. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2018-03-19 { + description "Initial revision"; + } + + augment "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/rt:static-routes/" + + "v4ur:ipv4/v4ur:route/v4ur:next-hop/v4ur:next-hop-options/v4ur:next-hop-list/v4ur:next-hop-list/v4ur:next-hop" + { + ext:augment-identifier "vpp-ipv4-next-hop-augmentation"; + uses vpp-rt-tp:vpp-next-hop-attributes; + } + + augment "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/rt:static-routes/v4ur:ipv4/v4ur:route" + { + ext:augment-identifier "vpp-ipv4-route-attributes-augmentation"; + container vpp-ipv4-route{ + uses vpp-rt:vpp-route-attributes; + } + } +} diff --git a/routing/routing-api/src/main/yang/vpp-ipv6-unicast-routing@2018-03-19.yang b/routing/routing-api/src/main/yang/vpp-ipv6-unicast-routing@2018-03-19.yang new file mode 100644 index 000000000..dcad55e80 --- /dev/null +++ b/routing/routing-api/src/main/yang/vpp-ipv6-unicast-routing@2018-03-19.yang @@ -0,0 +1,78 @@ +module vpp-ipv6-unicast-routing { + + namespace "urn:ietf:params:xml:ns:yang:vpp-ipv6-unicast-routing"; + prefix "vpp-v6ur"; + + import yang-ext { + prefix "ext"; + } + + import vpp-classifier { + prefix "classifier"; + } + + import hc2vpp-ietf-routing { + prefix "ietf-r"; + revision-date 2018-03-13; + } + + import hc2vpp-ietf-ipv6-unicast-routing { + prefix "v6ur"; + revision-date 2018-03-13; + } + + import vpp-routing { + prefix "vpp-rt"; + revision-date 2018-03-19; + } + + import vpp-routing-types { + prefix "vpp-rt-tp"; + revision-date 2018-04-06; + } + + organization + "FD.io - The Fast Data Project"; + + contact + "Hc2vpp Wiki + Mailing List "; + + description + "This module contains a collection of YANG definitions + that extend hc2vpp-ietf-routing module + with VPP specific ipv6 unicast routing features. + + Copyright (c) 2018 Bell Canada, Pantheon.tech and/or its affiliates. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2018-03-19 { + description "Initial revision"; + } + + augment "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/rt:static-routes/" + + "v6ur:ipv6/v6ur:route/v6ur:next-hop/v6ur:next-hop-options/v6ur:next-hop-list/v6ur:next-hop-list/v6ur:next-hop" + { + ext:augment-identifier "vpp-ipv6-next-hop-augmentation"; + uses vpp-rt-tp:vpp-next-hop-attributes; + } + + augment "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/rt:static-routes/v6ur:ipv6/v6ur:route" + { + ext:augment-identifier "vpp-ipv6-route-attributes-augmentation"; + container vpp-ipv6-route{ + uses vpp-rt:vpp-route-attributes; + } + } +} diff --git a/routing/routing-api/src/main/yang/vpp-routing-ra@2017-05-02.yang b/routing/routing-api/src/main/yang/vpp-routing-ra@2017-05-02.yang deleted file mode 100644 index 87dfdbd57..000000000 --- a/routing/routing-api/src/main/yang/vpp-routing-ra@2017-05-02.yang +++ /dev/null @@ -1,132 +0,0 @@ -module vpp-routing-ra { - - namespace "urn:ietf:params:xml:ns:yang:vpp-routing-ra"; - prefix "vpp-routing"; - - import yang-ext { - prefix "ext"; - } - - import hc2vpp-ietf-routing { - prefix "ietf-r"; - } - - import hc2vpp-ietf-ipv6-unicast-routing { - prefix "v6ur"; - } - - organization - "FD.io - The Fast Data Project"; - - contact - "Hc2vpp Wiki - Mailing List "; - - description - "This module contains a collection of YANG definitions - that extend hc2vpp-ietf-routing module - with VPP specific routing advertisments features. - - Copyright (c) 2017 Cisco and/or its affiliates. - - Licensed under the Apache License, Version 2.0 (the 'License'); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at: - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an 'AS IS' BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License."; - - revision 2017-05-02 { - description "Changed namespace"; - } - - revision 2017-03-15 { - description "Initial revision."; - } - - grouping ipv6-router-advertisements-vpp-attributes { - leaf suppress-link-layer { - type boolean; - default false; - description - "Dicates not to include the optional source link-layer address - in the ICMPv6 router-advertisement messages."; - } - leaf send-unicast { - type boolean; - default false; - description - "Use the source address of the router-solicitation message if availiable."; - } - leaf cease { - type boolean; - default false; - description - "Cease sending ICMPv6 router-advertisement messages."; - } - leaf initial-count { - type uint8 { - range "1..3"; - } - default 3; - description - "Number of initial ICMPv6 router-advertisement messages sent."; - } - leaf initial-interval { - type uint8 { - range "1..16"; - } - units "seconds"; - default 16; - description - "Interval between initial ICMPv6 router-advertisement messages."; - } - - description - "VPP specific configuration of RA messages. Mapped to sw_interface_ip6nd_ra_config API: - https://git.fd.io/vpp/tree/src/vnet/ip/ip.api#n196"; - - reference - "https://docs.fd.io/vpp/17.04/clicmd_src_vnet_ip.html#clicmd_ip6_nd"; - } - - grouping control-adv-prefixes-vpp-attributes { - leaf advertise-router-address { - type boolean; - default true; - description - "Send full router address in prefix advertisement."; - } - leaf vpp-default { - type boolean; - default false; - description - "Use VPP default values for prefix advertisment."; - } - - description - "VPP specific configuration of prefixes in RA messages. Mapped to sw_interface_ip6nd_ra_prefix API: - https://git.fd.io/vpp/tree/src/vnet/ip/ip.api#n243"; - - reference - "https://docs.fd.io/vpp/17.04/clicmd_src_vnet_ip.html#clicmd_ip6_nd"; - } - - augment "/ietf-r:routing/ietf-r:routing-instance/ietf-r:interfaces/ietf-r:interface/" - + "v6ur:ipv6-router-advertisements" { - ext:augment-identifier "ipv6-router-advertisements-vpp-augmentation"; - uses ipv6-router-advertisements-vpp-attributes; - } - - augment "/ietf-r:routing/ietf-r:routing-instance/ietf-r:interfaces/ietf-r:interface/" - + "v6ur:ipv6-router-advertisements/v6ur:prefix-list/v6ur:prefix" { - // TODO control-adv-prefixes/advertise case should be target node (change after yangtools issues are solved) - ext:augment-identifier "control-adv-prefixes-vpp-augmentation"; - uses control-adv-prefixes-vpp-attributes; - } -} \ No newline at end of file diff --git a/routing/routing-api/src/main/yang/vpp-routing-ra@2018-03-19.yang b/routing/routing-api/src/main/yang/vpp-routing-ra@2018-03-19.yang new file mode 100644 index 000000000..5be3f6d38 --- /dev/null +++ b/routing/routing-api/src/main/yang/vpp-routing-ra@2018-03-19.yang @@ -0,0 +1,145 @@ +module vpp-routing-ra { + + namespace "urn:ietf:params:xml:ns:yang:vpp-routing-ra"; + prefix "vpp-routing"; + + import yang-ext { + prefix "ext"; + } + + import hc2vpp-ietf-routing { + prefix "ietf-r"; + revision-date 2018-03-13; + } + + import hc2vpp-ietf-ipv6-unicast-routing { + prefix "v6ur"; + revision-date 2018-03-13; + } + + import ietf-ip { + prefix "ip"; + } + + import ietf-interfaces { + prefix "if"; + } + + organization + "FD.io - The Fast Data Project"; + + contact + "Hc2vpp Wiki + Mailing List "; + + description + "This module contains a collection of YANG definitions + that extend hc2vpp-ietf-routing module + with VPP specific routing advertisments features. + + Copyright (c) 2017 Cisco and/or its affiliates. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2018-03-19 { + description + "Update hc2vpp-ietf-routing revision-date to 2018-03-13"; + } + + revision 2017-05-02 { + description "Changed namespace"; + } + + revision 2017-03-15 { + description "Initial revision."; + } + + grouping ipv6-router-advertisements-vpp-attributes { + leaf suppress-link-layer { + type boolean; + default false; + description + "Dicates not to include the optional source link-layer address + in the ICMPv6 router-advertisement messages."; + } + leaf send-unicast { + type boolean; + default false; + description + "Use the source address of the router-solicitation message if availiable."; + } + leaf cease { + type boolean; + default false; + description + "Cease sending ICMPv6 router-advertisement messages."; + } + leaf initial-count { + type uint8 { + range "1..3"; + } + default 3; + description + "Number of initial ICMPv6 router-advertisement messages sent."; + } + leaf initial-interval { + type uint8 { + range "1..16"; + } + units "seconds"; + default 16; + description + "Interval between initial ICMPv6 router-advertisement messages."; + } + + description + "VPP specific configuration of RA messages. Mapped to sw_interface_ip6nd_ra_config API: + https://git.fd.io/vpp/tree/src/vnet/ip/ip.api#n196"; + + reference + "https://docs.fd.io/vpp/17.04/clicmd_src_vnet_ip.html#clicmd_ip6_nd"; + } + + grouping control-adv-prefixes-vpp-attributes { + leaf advertise-router-address { + type boolean; + default true; + description + "Send full router address in prefix advertisement."; + } + leaf vpp-default { + type boolean; + default false; + description + "Use VPP default values for prefix advertisment."; + } + + description + "VPP specific configuration of prefixes in RA messages. Mapped to sw_interface_ip6nd_ra_prefix API: + https://git.fd.io/vpp/tree/src/vnet/ip/ip.api#n243"; + + reference + "https://docs.fd.io/vpp/17.04/clicmd_src_vnet_ip.html#clicmd_ip6_nd"; + } + + augment "/if:interfaces/if:interface/ip:ipv6/v6ur:ipv6-router-advertisements" { + ext:augment-identifier "ipv6-router-advertisements-vpp-augmentation"; + uses ipv6-router-advertisements-vpp-attributes; + } + + augment "/if:interfaces/if:interface/ip:ipv6/v6ur:ipv6-router-advertisements/v6ur:prefix-list/v6ur:prefix" { + // TODO control-adv-prefixes/advertise case should be target node (change after yangtools issues are solved) + ext:augment-identifier "control-adv-prefixes-vpp-augmentation"; + uses control-adv-prefixes-vpp-attributes; + } +} diff --git a/routing/routing-api/src/main/yang/vpp-routing-table-lookup@2017-09-17.yang b/routing/routing-api/src/main/yang/vpp-routing-table-lookup@2017-09-17.yang deleted file mode 100644 index 4e646f996..000000000 --- a/routing/routing-api/src/main/yang/vpp-routing-table-lookup@2017-09-17.yang +++ /dev/null @@ -1,49 +0,0 @@ -module vpp-routing-table-lookup { - - namespace "urn:ietf:params:xml:ns:yang:vpp-routing-table-lookup"; - prefix "vpp-routing"; - - import vpp-routing { - prefix "vpp-r"; - } - - organization - "FD.io - The Fast Data Project"; - - contact - "Hc2vpp Wiki - Mailing List "; - - description - "This module extends hc2vpp-ietf-routing module - with VPP table lookup option. - - Copyright (c) 2017 Cisco and/or its affiliates. - - Licensed under the Apache License, Version 2.0 (the 'License'); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at: - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an 'AS IS' BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License."; - - revision 2017-09-17 { - description "Initial revision"; - } - - grouping table-lookup-case-params { - leaf secondary-vrf { - type vpp-r:vni-reference; - mandatory true; - description "Secondary vrf used to lookup in"; - } - // uses special deaggregation address every time : 0.0.0.0 - } - - //TODO - HONEYCOMB-398/HC2VPP-237 - move table lookup case here -} \ No newline at end of file diff --git a/routing/routing-api/src/main/yang/vpp-routing-types@2018-04-06.yang b/routing/routing-api/src/main/yang/vpp-routing-types@2018-04-06.yang new file mode 100644 index 000000000..bba228b73 --- /dev/null +++ b/routing/routing-api/src/main/yang/vpp-routing-types@2018-04-06.yang @@ -0,0 +1,60 @@ +module vpp-routing-types { + + namespace "urn:ietf:params:xml:ns:yang:vpp-routing-types"; + prefix "vpp-routing-types"; + + organization + "FD.io - The Fast Data Project"; + + contact + "Hc2vpp Wiki + Mailing List "; + + description + "This module contains a collection of YANG definitions + that extend hc2vpp-ietf-routing-types module + with VPP specific data. + + Copyright (c) 2018 Bell Canada, Pantheon.tech and/or its affiliates. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2018-04-06 { + description "Initial revision."; + } + + /*** Collection of types related to VPP routing ***/ + + typedef vni-reference { + type uint32; + description "Vrf index reference"; + } + + /*** Groupings ***/ + + grouping vpp-next-hop-attributes { + leaf weight{ + type uint8; + description "Weight classification for next hop in list of next hops"; + } + } + + grouping table-lookup-case-params { + leaf secondary-vrf { + type vni-reference; + mandatory true; + description "Secondary vrf used to lookup in"; + } + // uses special deaggregation address every time : 0.0.0.0 + } +} diff --git a/routing/routing-api/src/main/yang/vpp-routing@2017-09-17.yang b/routing/routing-api/src/main/yang/vpp-routing@2017-09-17.yang deleted file mode 100644 index 2088fec38..000000000 --- a/routing/routing-api/src/main/yang/vpp-routing@2017-09-17.yang +++ /dev/null @@ -1,89 +0,0 @@ -module vpp-routing { - - namespace "urn:ietf:params:xml:ns:yang:vpp-routing"; - prefix "vpp-routing"; - - import yang-ext { - prefix "ext"; - } - - import vpp-classifier { - prefix "classifier"; - } - - import hc2vpp-ietf-routing { - prefix "ietf-r"; - } - - organization - "FD.io - The Fast Data Project"; - - contact - "Hc2vpp Wiki - Mailing List "; - - description - "This module contains a collection of YANG definitions - that extend hc2vpp-ietf-routing module - with VPP specific routing features. - - Copyright (c) 2016-2017 Cisco and/or its affiliates. - - Licensed under the Apache License, Version 2.0 (the 'License'); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at: - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an 'AS IS' BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License."; - - revision 2017-09-17 { - description "Support for table lookup option moved to separate model."; - } - - revision 2016-12-14 { - description "Initial revision."; - } - - typedef vni-reference{ - type uint32; - description "Vrf index reference"; - } - - grouping vpp-route-attributes { - leaf classify-table{ - // classify_table_index + is_classify flag - type classifier:classify-table-ref; - description "Optional reference to classify table"; - } - } - - grouping vpp-routing-protocol-attributes{ - //vrf_id - leaf primary-vrf{ - type vni-reference; - mandatory true; - description "Main vrf associated to route"; - } - } - - augment /ietf-r:routing/ietf-r:routing-instance/ietf-r:routing-protocols/ietf-r:routing-protocol{ - ext:augment-identifier "routing-protocol-vpp-attr"; - container vpp-protocol-attributes { - presence "Config attributes"; - uses vpp-routing-protocol-attributes; - } - } - - augment /ietf-r:routing-state/ietf-r:routing-instance/ietf-r:routing-protocols/ietf-r:routing-protocol{ - ext:augment-identifier "routing-protocol-state-vpp-attr"; - container vpp-protocol-state-attributes { - presence "Operational attributes"; - uses vpp-routing-protocol-attributes; - } - } -} \ No newline at end of file diff --git a/routing/routing-api/src/main/yang/vpp-routing@2018-03-19.yang b/routing/routing-api/src/main/yang/vpp-routing@2018-03-19.yang new file mode 100644 index 000000000..aad069bdf --- /dev/null +++ b/routing/routing-api/src/main/yang/vpp-routing@2018-03-19.yang @@ -0,0 +1,86 @@ +module vpp-routing { + + namespace "urn:ietf:params:xml:ns:yang:vpp-routing"; + prefix "vpp-routing"; + + import yang-ext { + prefix "ext"; + } + + import vpp-classifier { + prefix "classifier"; + } + + import hc2vpp-ietf-routing { + prefix "ietf-r"; + revision-date 2018-03-13; + } + + import vpp-routing-types { + prefix vpp-routing-types; + revision-date 2018-04-06; + } + + organization + "FD.io - The Fast Data Project"; + + contact + "Hc2vpp Wiki + Mailing List "; + + description + "This module contains a collection of YANG definitions + that extend hc2vpp-ietf-routing module + with VPP specific routing features. + + Copyright (c) 2016-2017 Cisco and/or its affiliates. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2018-03-19 { + description "Update hc2vpp-ietf-routing revision-date to 2018-03-13"; + } + + revision 2017-09-17 { + description "Support for table lookup option moved to separate model."; + } + + revision 2016-12-14 { + description "Initial revision."; + } + + grouping vpp-route-attributes { + leaf classify-table{ + // classify_table_index + is_classify flag + type classifier:classify-table-ref; + description "Optional reference to classify table"; + } + } + + grouping vpp-routing-protocol-attributes{ + //vrf_id + leaf primary-vrf{ + type vpp-routing-types:vni-reference; + mandatory true; + description "Main vrf associated to route"; + } + } + + augment /ietf-r:routing/ietf-r:control-plane-protocols/ietf-r:control-plane-protocol{ + ext:augment-identifier "routing-protocol-vpp-attr"; + container vpp-protocol-attributes { + presence "Config attributes"; + uses vpp-routing-protocol-attributes; + } + } +} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/Ipv4RoutingNodes.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/Ipv4RoutingNodes.java new file mode 100644 index 000000000..50b29a8e2 --- /dev/null +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/Ipv4RoutingNodes.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016 Cisco, Bell Canada, Pantheon and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.routing; + +import com.google.common.collect.ImmutableSet; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import java.util.Set; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.SimpleNextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4RouteAttributesAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.VppIpv4Route; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public interface Ipv4RoutingNodes extends JvppReplyConsumer { + + @SuppressWarnings("unchecked") + default Set> ipv4RoutingHandledChildren(final InstanceIdentifier parent) { + return ImmutableSet.of( + parent.child(NextHop.class), + parent.child(NextHop.class).augmentation((Class)NextHopList.class), + parent.child(NextHop.class).augmentation((Class)NextHopList.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop.class), + parent.child(NextHop.class).augmentation((Class)NextHopList.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop.class) + .augmentation(NextHop1.class), + parent.child(NextHop.class).augmentation((Class)NextHopList.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop.class) + .augmentation(VppIpv4NextHopAugmentation.class), + parent.child(NextHop.class).augmentation((Class)SimpleNextHop1.class), + parent.augmentation(VppIpv4RouteAttributesAugmentation.class).child(VppIpv4Route.class)); + } + +} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/Ipv6RoutingNodes.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/Ipv6RoutingNodes.java new file mode 100644 index 000000000..ca87869c6 --- /dev/null +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/Ipv6RoutingNodes.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016 Cisco, Bell Canada, Pantheon and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.routing; + +import com.google.common.collect.ImmutableSet; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import java.util.Set; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.SimpleNextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6RouteAttributesAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.VppIpv6Route; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public interface Ipv6RoutingNodes extends JvppReplyConsumer { + + @SuppressWarnings("unchecked") + default Set> ipv6RoutingHandledChildren(final InstanceIdentifier parent) { + return ImmutableSet.of( + parent.augmentation(VppIpv6RouteAttributesAugmentation.class).child(VppIpv6Route.class), + parent.child(NextHop.class), + parent.child(NextHop.class) + .augmentation((Class)NextHopList.class), + parent.child(NextHop.class) + .augmentation((Class)NextHopList.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop.class), + parent.child(NextHop.class) + .augmentation((Class)NextHopList.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop.class) + .augmentation(NextHop1.class), + parent.child(NextHop.class) + .augmentation((Class)NextHopList.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop.class) + .augmentation(VppIpv6NextHopAugmentation.class), + parent.child(NextHop.class) + .augmentation((Class) SimpleNextHop1.class)); + } + +} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingConfiguration.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingConfiguration.java index c8f0ba634..3bb7043bf 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingConfiguration.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingConfiguration.java @@ -43,16 +43,9 @@ public class RoutingConfiguration { */ public static final String ROUTE_HOP_CONTEXT = "route-hop-context"; - - @InjectConfig("default-routing-instance-name") - private String defaultRoutingInstanceName; - @InjectConfig("learned-route-name-prefix") private String learnedRouteNamePrefix; - public String getDefaultRoutingInstanceName() { - return defaultRoutingInstanceName; - } public String getLearnedRouteNamePrefix() { return learnedRouteNamePrefix; diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingIIds.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingIIds.java new file mode 100644 index 000000000..e17b4439e --- /dev/null +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingIIds.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018 Bell Canada, Pantheon and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.routing; + +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.Ipv61; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.Ipv6RouterAdvertisements; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.PrefixList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.prefix.list.Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Routing; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class RoutingIIds { + + //Reader IIDs + public static final InstanceIdentifier ROUTING = InstanceIdentifier.create(Routing.class); + public static final InstanceIdentifier RT_CPS = ROUTING.child(ControlPlaneProtocols.class); + public static final InstanceIdentifier RT_CPS_CP = RT_CPS.child(ControlPlaneProtocol.class); + + public static final InstanceIdentifier RT_CPS_CP_SR = RT_CPS_CP.child(StaticRoutes.class); + public static final InstanceIdentifier RT_CPS_CP_SR_SRV4_IPV4_RT = + RT_CPS_CP_SR.augmentation(StaticRoutes1.class).child(Ipv4.class).child(Route.class); + public static final InstanceIdentifier RT_CPS_CP_SR_SRV4_IPV4_RT_PARENT = + InstanceIdentifier.create(Route.class); + + public static final InstanceIdentifier + RT_CPS_CP_SR_SRV6_IPV6_RT = RT_CPS_CP_SR.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1.class) + .child(Ipv6.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route.class); + public static final InstanceIdentifier + RT_CPS_CP_SR_SRV6_IPV6_RT_PARENT = InstanceIdentifier.create( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route.class); + + //Writer IIDs + public static final InstanceIdentifier IFCS_IFC_IFC1_IPV6_IPV61_RTADV = + InstanceIdentifier.create(Interfaces.class).child(Interface.class).augmentation(Interface1.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6.class) + .augmentation(Ipv61.class).child(Ipv6RouterAdvertisements.class); + public static final InstanceIdentifier IFCS_IFC_IFC1_IPV6_IPV61_RTADV_PRLST_PRFX = + IFCS_IFC_IFC1_IPV6_IPV61_RTADV.child(PrefixList.class).child(Prefix.class); +} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingModule.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingModule.java index a6fadf78c..8a109aece 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingModule.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingModule.java @@ -21,7 +21,7 @@ import com.google.inject.multibindings.Multibinder; import com.google.inject.name.Names; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.routing.read.RoutingStateReaderFactory; +import io.fd.hc2vpp.routing.read.RoutingReaderFactory; import io.fd.hc2vpp.routing.write.RoutingWriterFactory; import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.write.WriterFactory; @@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory; /** * RoutingModule class instantiating routing plugin components. */ -public final class RoutingModule extends AbstractModule { +public class RoutingModule extends AbstractModule { private static final Logger LOG = LoggerFactory.getLogger(RoutingModule.class); @@ -44,22 +44,22 @@ public final class RoutingModule extends AbstractModule { requestInjection(RoutingConfiguration.class); bind(NamingContext.class) - .annotatedWith(Names.named(RoutingConfiguration.ROUTING_PROTOCOL_CONTEXT)) - .toInstance(new NamingContext("learned-protocol-", RoutingConfiguration.ROUTING_PROTOCOL_CONTEXT)); + .annotatedWith(Names.named(RoutingConfiguration.ROUTING_PROTOCOL_CONTEXT)) + .toInstance(new NamingContext("learned-protocol-", RoutingConfiguration.ROUTING_PROTOCOL_CONTEXT)); bind(NamingContext.class) - .annotatedWith(Names.named(RoutingConfiguration.ROUTE_CONTEXT)) - .toInstance(new NamingContext("route-", RoutingConfiguration.ROUTE_CONTEXT)); + .annotatedWith(Names.named(RoutingConfiguration.ROUTE_CONTEXT)) + .toInstance(new NamingContext("route-", RoutingConfiguration.ROUTE_CONTEXT)); bind(MultiNamingContext.class) - .annotatedWith(Names.named(RoutingConfiguration.ROUTE_HOP_CONTEXT)) - .toInstance(new MultiNamingContext(RoutingConfiguration.ROUTE_HOP_CONTEXT, - RoutingConfiguration.MULTI_MAPPING_START_INDEX)); + .annotatedWith(Names.named(RoutingConfiguration.ROUTE_HOP_CONTEXT)) + .toInstance(new MultiNamingContext(RoutingConfiguration.ROUTE_HOP_CONTEXT, + RoutingConfiguration.MULTI_MAPPING_START_INDEX)); LOG.info("Injecting reader factories"); // creates reader factory binding final Multibinder readerFactoryBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class); - readerFactoryBinder.addBinding().to(RoutingStateReaderFactory.class); + readerFactoryBinder.addBinding().to(RoutingReaderFactory.class); LOG.info("Injecting writers factories"); // create writer factory binding diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/naming/Ipv4RouteNamesFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/naming/Ipv4RouteNamesFactory.java index 2ed0df12e..1205ffa6b 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/naming/Ipv4RouteNamesFactory.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/naming/Ipv4RouteNamesFactory.java @@ -16,7 +16,6 @@ package io.fd.hc2vpp.routing.naming; - import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.trait.RouteMapper; import io.fd.hc2vpp.routing.write.trait.RouteRequestProducer; @@ -29,14 +28,16 @@ import java.util.Arrays; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; 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.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; - +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentation; public final class Ipv4RouteNamesFactory implements RouteMapper, RouteRequestProducer { private static final String DOT = "."; - private static final String EMPTY = ""; + private static final String DASH = "-"; + private static final String UNDERSCORE = "_"; private final NamingContext interfaceContext; private final NamingContext routingProtocolContext; @@ -52,7 +53,7 @@ public final class Ipv4RouteNamesFactory implements RouteMapper, RouteRequestPro */ public String uniqueRouteName(@Nonnull final String parentProtocolName, @Nonnull final Route route) { return bindName(parentProtocolName, dotlessAddress(route.getDestinationPrefix()), - String.valueOf(extractPrefix(route.getDestinationPrefix()))); + String.valueOf(extractPrefix(route.getDestinationPrefix()))); } /** @@ -60,22 +61,31 @@ public final class Ipv4RouteNamesFactory implements RouteMapper, RouteRequestPro */ public String uniqueRouteName(@Nonnull final IpFibDetails details, @Nonnull final MappingContext mappingContext) { return bindName(routingProtocolContext.getName(details.tableId, mappingContext), - dotlessAddress(details.address), - String.valueOf(details.addressLength)); + dotlessAddress(details.address), String.valueOf(details.addressLength)); + } + + /** + * Construct unique name from provided parentProtocolName and {@code Ipv4Prefix} + */ + public String uniqueRouteName(@Nonnull final String parentProtocolName, @Nonnull final Ipv4Prefix prefix) { + return bindName(parentProtocolName, dotlessAddress(prefix), + String.valueOf(Byte.toUnsignedInt(extractPrefix(prefix)))); } + public Ipv4Prefix ipv4PrefixFromUniqueRouteName(@Nonnull final String uniqueName) { + String[] parts = uniqueName.split(UNDERSCORE); + return new Ipv4Prefix(dotted(parts[1]) + "/" + parts[2]); + } public String uniqueRouteHopName(@Nonnull final NextHop hop) { return bindName(hop.getOutgoingInterface(), - dotlessAddress(hop.getAddress()), - String.valueOf(hop.getWeight())); + dotlessAddress(hop.getAugmentation(NextHop1.class).getNextHopAddress()), + String.valueOf(hop.getAugmentation(VppIpv4NextHopAugmentation.class).getWeight())); } - - public String uniqueRouteHopName(@Nonnull final FibPath path, - @Nonnull final MappingContext mappingContext) { - return bindName(interfaceContext.getName(path.swIfIndex, mappingContext), - dotlessAddress(path.nextHop), String.valueOf(path.weight)); + public String uniqueRouteHopName(@Nonnull final FibPath path, @Nonnull final MappingContext mappingContext) { + return bindName(interfaceContext.getName(path.swIfIndex, mappingContext), dotlessAddress(path.nextHop), + String.valueOf(path.weight)); } private String dotlessAddress(final byte[] address) { @@ -103,6 +113,10 @@ public final class Ipv4RouteNamesFactory implements RouteMapper, RouteRequestPro } private String dotless(@Nonnull final String input) { - return input.replace(DOT, EMPTY); + return input.replace(DOT, DASH); + } + + private String dotted(@Nonnull final String input) { + return input.replace(DASH, DOT); } } diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/naming/Ipv6RouteNamesFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/naming/Ipv6RouteNamesFactory.java index abb48618c..da8affb7b 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/naming/Ipv6RouteNamesFactory.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/naming/Ipv6RouteNamesFactory.java @@ -19,6 +19,7 @@ package io.fd.hc2vpp.routing.naming; import com.google.common.net.InetAddresses; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.trait.RouteMapper; +import io.fd.hc2vpp.routing.write.trait.RouteRequestProducer; import io.fd.honeycomb.translate.MappingContext; import io.fd.vpp.jvpp.core.dto.Ip6FibDetails; import io.fd.vpp.jvpp.core.types.FibPath; @@ -27,12 +28,16 @@ import java.net.UnknownHostException; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentation; +public final class Ipv6RouteNamesFactory implements RouteMapper, RouteRequestProducer { -public final class Ipv6RouteNamesFactory implements RouteMapper { - - private static final String DOUBLE_DOT = ":"; - private static final String EMPTY = ""; + private static final String COLON = ":"; + private static final String DASH = "-"; + private static final String UNDERSCORE = "_"; private final NamingContext interfaceContext; private final NamingContext routingProtocolContext; @@ -47,7 +52,7 @@ public final class Ipv6RouteNamesFactory implements RouteMapper { * Construct unique name from provided {@code Route} */ public String uniqueRouteName(@Nonnull final String parentProtocolName, - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route route) { + @Nonnull final Route route) { return bindName(parentProtocolName, // to have address in compressed form doubleDotlessAddress(route.getDestinationPrefix()), @@ -63,11 +68,23 @@ public final class Ipv6RouteNamesFactory implements RouteMapper { String.valueOf(Byte.toUnsignedInt(details.addressLength))); } - public String uniqueRouteHopName( - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop hop) { + /** + * Construct unique name from provided parentProtocolName and {@code Ipv6Prefix} + */ + public String uniqueRouteName(@Nonnull final String parentProtocolName, @Nonnull final Ipv6Prefix prefix) { + return bindName(parentProtocolName, doubleDotlessAddress(prefix), String.valueOf(extractPrefix(prefix))); + } + + + public Ipv6Prefix ipv6PrefixFromUniqueRouteName(@Nonnull final String uniqueName) { + String[] parts = uniqueName.split(UNDERSCORE); + return new Ipv6Prefix(coloned(parts[1]) + "/" + parts[2]); + } + + public String uniqueRouteHopName(@Nonnull final NextHop hop) { return bindName(hop.getOutgoingInterface(), - doubleDotlessAddress(hop.getAddress()), - String.valueOf(hop.getWeight())); + doubleDotlessAddress(hop.getAugmentation(NextHop1.class).getNextHopAddress()), + String.valueOf(hop.getAugmentation(VppIpv6NextHopAugmentation.class).getWeight())); } public String uniqueRouteHopName(@Nonnull final FibPath path, @Nonnull final MappingContext mappingContext) { @@ -117,6 +134,10 @@ public final class Ipv6RouteNamesFactory implements RouteMapper { } private String doubleDotless(@Nonnull final String input) { - return input.replace(DOUBLE_DOT, EMPTY); + return input.replace(COLON, DASH); + } + + private String coloned(@Nonnull final String input) { + return input.replace(DASH, COLON); } } diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/ControlPlaneProtocolCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/ControlPlaneProtocolCustomizer.java new file mode 100644 index 000000000..372da27c6 --- /dev/null +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/ControlPlaneProtocolCustomizer.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.routing.read; + +import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.routing.trait.RouteMapper; +import io.fd.honeycomb.translate.ModificationCache; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; +import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; +import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocolsBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.RoutingProtocolVppAttr; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.RoutingProtocolVppAttrBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.routing.control.plane.protocols.control.plane.protocol.VppProtocolAttributesBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +final class ControlPlaneProtocolCustomizer + implements ListReaderCustomizer, + RouteMapper { + + private final NamingContext routingProtocolContext; + private final DumpCacheManager ipv4RoutesDumpManager; + private final DumpCacheManager ipv6RoutesDumpManager; + + + ControlPlaneProtocolCustomizer(@Nonnull final NamingContext routingProtocolContext, + @Nonnull final DumpCacheManager ipv4RoutesDumpManager, + @Nonnull final DumpCacheManager ipv6RoutesDumpManager) { + this.routingProtocolContext = routingProtocolContext; + this.ipv4RoutesDumpManager = ipv4RoutesDumpManager; + this.ipv6RoutesDumpManager = ipv6RoutesDumpManager; + } + + @Nonnull + @Override + public List getAllIds(@Nonnull final InstanceIdentifier instanceIdentifier, + @Nonnull final ReadContext readContext) throws ReadFailedException { + + final ModificationCache modificationCache = readContext.getModificationCache(); + + // builds keys from routing protocol prefix and unique set of table ids + return Stream.of( + ipv4TableIds(instanceIdentifier, modificationCache), + ipv6TableIds(instanceIdentifier, modificationCache)) + .flatMap(Collection::stream) + .map(tableId -> routingProtocolContext.getName(tableId, readContext.getMappingContext())) + .distinct() + .map(name -> new ControlPlaneProtocolKey(name, Static.class)) + .collect(Collectors.toList()); + } + + private List ipv4TableIds(final InstanceIdentifier instanceIdentifier, + final ModificationCache modificationCache) throws ReadFailedException { + final Optional + ipv4Routes = ipv4RoutesDumpManager.getDump(instanceIdentifier, modificationCache); + + if (ipv4Routes.isPresent()) { + return ipv4Routes.get().ipFibDetails.stream() + .map(ipFibDetails -> ipFibDetails.tableId) + .collect(Collectors.toList()); + } + return Collections.emptyList(); + } + + private List ipv6TableIds(final InstanceIdentifier instanceIdentifier, + final ModificationCache modificationCache) throws ReadFailedException { + final Optional + ipv6Routes = ipv6RoutesDumpManager.getDump(instanceIdentifier, modificationCache); + + if (ipv6Routes.isPresent()) { + return ipv6Routes.get().ip6FibDetails.stream() + .map(ipFibDetails -> ipFibDetails.tableId) + .collect(Collectors.toList()); + } + return Collections.emptyList(); + } + + @Override + public void merge(@Nonnull final Builder builder, + @Nonnull final List list) { + ((ControlPlaneProtocolsBuilder) builder).setControlPlaneProtocol(list); + } + + @Nonnull + @Override + public ControlPlaneProtocolBuilder getBuilder(@Nonnull final InstanceIdentifier instanceIdentifier) { + return new ControlPlaneProtocolBuilder(); + } + + @Override + public void readCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, + @Nonnull final ControlPlaneProtocolBuilder routingProtocolBuilder, + @Nonnull final ReadContext readContext) throws ReadFailedException { + final ControlPlaneProtocolKey key = instanceIdentifier.firstKeyOf(ControlPlaneProtocol.class); + routingProtocolBuilder + .setName(key.getName()) + .setKey(key) + .setType(Static.class) + .addAugmentation(RoutingProtocolVppAttr.class, new RoutingProtocolVppAttrBuilder().setVppProtocolAttributes( + new VppProtocolAttributesBuilder() + .setPrimaryVrf( + new VniReference( + Long.valueOf(routingProtocolContext.getIndex(key.getName(), + readContext.getMappingContext())))) + .build()) + .build()) + .build(); + } +} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv4ReadRoutingNodes.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv4ReadRoutingNodes.java deleted file mode 100644 index b42fd558a..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv4ReadRoutingNodes.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.read; - - -import com.google.common.collect.ImmutableSet; -import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; -import io.fd.hc2vpp.common.translate.util.MultiNamingContext; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.routing.RoutingConfiguration; -import io.fd.honeycomb.translate.impl.read.GenericListReader; -import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; -import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.IpFibDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes2; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes2Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.VppIpv4RouteState; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.table.lookup.TableLookupParams; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -import javax.annotation.Nonnull; -import java.util.Set; - -interface Ipv4ReadRoutingNodes extends JvppReplyConsumer { - - static InstanceIdentifier staticRoutesInstanceIdentifier( - final InstanceIdentifier staticRoutesInstanceIdentifier) { - return staticRoutesInstanceIdentifier.augmentation(StaticRoutes2.class); - } - - static InstanceIdentifier ipv4Identifier( - final InstanceIdentifier staticRoutes2InstanceIdentifier) { - return staticRoutes2InstanceIdentifier.child(Ipv4.class); - } - - default DumpCacheManager newIpv4RoutesDumpManager( - @Nonnull final FutureJVppCore vppApi) { - return new DumpCacheManager.DumpCacheManagerBuilder() - .withExecutor( - (identifier, params) -> getReplyForRead(vppApi.ipFibDump(new IpFibDump()).toCompletableFuture(), - identifier)) - .acceptOnly(IpFibDetailsReplyDump.class) - .build(); - } - - default void registerIpv4Routes(@Nonnull final InstanceIdentifier subTreeId, - @Nonnull final ModifiableReaderRegistryBuilder registry, - @Nonnull final DumpCacheManager ipv4DumpManager, - @Nonnull final RoutingConfiguration configuration, - @Nonnull final MultiNamingContext routeHopContext, - @Nonnull final NamingContext interfaceContext, - @Nonnull final NamingContext routeContext, - @Nonnull final NamingContext routingProtocolContext) { - - final InstanceIdentifier staticRoutes2InstanceIdentifier = - staticRoutesInstanceIdentifier(subTreeId); - final InstanceIdentifier ipv4InstanceIdentifier = ipv4Identifier(staticRoutes2InstanceIdentifier); - - registry.addStructuralReader(staticRoutes2InstanceIdentifier, StaticRoutes2Builder.class); - - registry.addStructuralReader(ipv4InstanceIdentifier, Ipv4Builder.class); - registry.subtreeAdd(ipv4RoutingHandledChildren(InstanceIdentifier.create(Route.class)), - new GenericListReader<>(ipv4InstanceIdentifier.child(Route.class), - new Ipv4RouteCustomizer(ipv4DumpManager, configuration, routeHopContext, interfaceContext, - routeContext, routingProtocolContext))); - } - - default Set> ipv4RoutingHandledChildren( - final InstanceIdentifier parent) { - return ImmutableSet.of( - parent.child(TableLookupParams.class), - parent.child(NextHopList.class), - parent.child(NextHopList.class).child(NextHop.class), - parent.child(VppIpv4RouteState.class)); - } - -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizer.java index 53d4f8335..1c5665839 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizer.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizer.java @@ -35,20 +35,21 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.VppIpv4RouteStateBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4RouteAttributesAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4RouteAttributesAugmentationBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.VppIpv4RouteBuilder; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class Ipv4RouteCustomizer +final class Ipv4RouteCustomizer implements ListReaderCustomizer, RouteMapper, Ipv4RoutePathParser { - private final DumpCacheManager ipv4RoutesDumpManager; private final RoutingConfiguration configuration; private final MultiNamingContext routeHopContext; @@ -58,12 +59,12 @@ public class Ipv4RouteCustomizer private final Ipv4RouteNamesFactory namesFactory; - public Ipv4RouteCustomizer(@Nonnull final DumpCacheManager ipv4RoutesDumpManager, - @Nonnull final RoutingConfiguration configuration, - @Nonnull final MultiNamingContext routeHopContext, - @Nonnull final NamingContext interfaceContext, - @Nonnull final NamingContext routesContext, - @Nonnull final NamingContext routingProtocolContext) { + Ipv4RouteCustomizer(@Nonnull final DumpCacheManager ipv4RoutesDumpManager, + @Nonnull final RoutingConfiguration configuration, + @Nonnull final MultiNamingContext routeHopContext, + @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext routesContext, + @Nonnull final NamingContext routingProtocolContext) { this.ipv4RoutesDumpManager = ipv4RoutesDumpManager; this.configuration = configuration; this.interfaceContext = interfaceContext; @@ -81,7 +82,7 @@ public class Ipv4RouteCustomizer final Optional ipv4RoutesDump = ipv4RoutesDumpManager.getDump(instanceIdentifier, readContext.getModificationCache()); - final String protocolName = instanceIdentifier.firstKeyOf(RoutingProtocol.class).getName(); + final String protocolName = instanceIdentifier.firstKeyOf(ControlPlaneProtocol.class).getName(); final int protocolTableId = routingProtocolContext.getIndex(protocolName, readContext.getMappingContext()); return ipv4RoutesDump.isPresent() @@ -104,14 +105,19 @@ public class Ipv4RouteCustomizer if (!routesContext.containsIndex(learnedRouteName, mappingContext)) { routesContext.addName(learnedRouteName, mappingContext); } - return keyForName(mappingContext, learnedRouteName); + return keyForLearnedName(learnedRouteName); } - return keyForName(mappingContext, routeName); + return keyForName(routeName); + } + + private RouteKey keyForName(final String name) { + // example learned-protocol-0_0-0-0-0_0 + return new RouteKey(namesFactory.ipv4PrefixFromUniqueRouteName(name)); } - private RouteKey keyForName(final MappingContext mappingContext, final String name) { - return new RouteKey( - Long.valueOf(routesContext.getIndex(name, mappingContext))); + private RouteKey keyForLearnedName(final String name) { + // example learned-route_learned-protocol-0_0-0-0-0_0 + return new RouteKey(namesFactory.ipv4PrefixFromUniqueRouteName(name.replace("learned-route_", ""))); } @Override @@ -130,8 +136,9 @@ public class Ipv4RouteCustomizer @Nonnull final RouteBuilder routeBuilder, @Nonnull final ReadContext readContext) throws ReadFailedException { final RouteKey key = instanceIdentifier.firstKeyOf(Route.class); - final String mappedName = routesContext.getName(key.getId().intValue(), readContext.getMappingContext()); - final String protocolName = instanceIdentifier.firstKeyOf(RoutingProtocol.class).getName(); + final String protocolName = instanceIdentifier.firstKeyOf(ControlPlaneProtocol.class).getName(); + final String mappedName = namesFactory.uniqueRouteName(protocolName, key.getDestinationPrefix()); + final int protocolTableId = routingProtocolContext.getIndex(protocolName, readContext.getMappingContext()); final Optional ipv4RoutesDump = ipv4RoutesDumpManager.getDump(instanceIdentifier, readContext.getModificationCache()); @@ -147,13 +154,16 @@ public class Ipv4RouteCustomizer if (opDetail.isPresent()) { final IpFibDetails detail = opDetail.get(); - routeBuilder.setNextHopOptions( + routeBuilder.setNextHop( resolveHopType(mappedName, Arrays.asList(detail.path), interfaceContext, routeHopContext, readContext.getMappingContext(), namesFactory)) .setKey(key) - .setId(key.getId()) .setDestinationPrefix(toIpv4Prefix(detail.address, toJavaByte(detail.addressLength))) - .setVppIpv4RouteState(new VppIpv4RouteStateBuilder().build()); + .addAugmentation(VppIpv4RouteAttributesAugmentation.class, + new VppIpv4RouteAttributesAugmentationBuilder() + .setVppIpv4Route(new VppIpv4RouteBuilder() + .build()) + .build()); } } } diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv6ReadRoutingNodes.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv6ReadRoutingNodes.java deleted file mode 100644 index e37b4a05e..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv6ReadRoutingNodes.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.read; - -import com.google.common.collect.ImmutableSet; -import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; -import io.fd.hc2vpp.common.translate.util.MultiNamingContext; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.routing.RoutingConfiguration; -import io.fd.honeycomb.translate.impl.read.GenericListReader; -import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; -import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.Ip6FibDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; -import java.util.Set; -import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes2; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes2Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.VppIpv6RouteState; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.table.lookup.TableLookupParams; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -interface Ipv6ReadRoutingNodes extends JvppReplyConsumer { - - static InstanceIdentifier staticRoutesInstanceIdentifier( - final InstanceIdentifier staticRoutesInstanceIdentifier) { - return staticRoutesInstanceIdentifier.augmentation(StaticRoutes2.class); - } - - static InstanceIdentifier ipv6Identifier( - final InstanceIdentifier staticRoutes2InstanceIdentifier) { - return staticRoutes2InstanceIdentifier.child(Ipv6.class); - } - - default DumpCacheManager newIpv6RoutesDumpManager( - @Nonnull final FutureJVppCore vppApi) { - return new DumpCacheManager.DumpCacheManagerBuilder() - .withExecutor( - (identifier, params) -> getReplyForRead( - vppApi.ip6FibDump(new Ip6FibDump()).toCompletableFuture(), identifier)) - .acceptOnly(Ip6FibDetailsReplyDump.class) - .build(); - } - - default void registerIpv6Routes(@Nonnull final InstanceIdentifier subTreeId, - @Nonnull final ModifiableReaderRegistryBuilder registry, - @Nonnull final DumpCacheManager ipv6DumpManager, - @Nonnull final RoutingConfiguration configuration, - @Nonnull final MultiNamingContext routeHopContext, - @Nonnull final NamingContext interfaceContext, - @Nonnull final NamingContext routeContext, - @Nonnull final NamingContext routingProtocolContext) { - - final InstanceIdentifier staticRoutes2InstanceIdentifier = - staticRoutesInstanceIdentifier(subTreeId); - final InstanceIdentifier ipv6InstanceIdentifier = ipv6Identifier(staticRoutes2InstanceIdentifier); - - registry.addStructuralReader(staticRoutes2InstanceIdentifier, StaticRoutes2Builder.class); - - registry.addStructuralReader(ipv6InstanceIdentifier, Ipv6Builder.class); - registry.subtreeAdd(ipv6RoutingHandledChildren(InstanceIdentifier.create(Route.class)), - new GenericListReader<>(ipv6InstanceIdentifier.child(Route.class), - new Ipv6RouteCustomizer(ipv6DumpManager, configuration, routeHopContext, interfaceContext, - routeContext, routingProtocolContext))); - } - - default Set> ipv6RoutingHandledChildren( - final InstanceIdentifier parent) { - return ImmutableSet.of( - parent.child(TableLookupParams.class), - parent.child(NextHopList.class), - parent.child(NextHopList.class).child(NextHop.class), - parent.child(VppIpv6RouteState.class)); - } - -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizer.java index a7ec37733..6003cf88b 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizer.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizer.java @@ -35,17 +35,19 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.VppIpv6RouteStateBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6RouteAttributesAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6RouteAttributesAugmentationBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.VppIpv6RouteBuilder; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class Ipv6RouteCustomizer +final class Ipv6RouteCustomizer implements ListReaderCustomizer, RouteMapper, Ipv6RoutePathParser { private final DumpCacheManager ipv6RoutesDumpManager; @@ -56,12 +58,12 @@ public class Ipv6RouteCustomizer private final NamingContext routingProtocolContext; private final Ipv6RouteNamesFactory namesFactory; - public Ipv6RouteCustomizer(@Nonnull final DumpCacheManager ipv6RoutesDumpManager, - @Nonnull final RoutingConfiguration configuration, - @Nonnull final MultiNamingContext routeHopContext, - @Nonnull final NamingContext interfaceContext, - @Nonnull final NamingContext routesContext, - @Nonnull final NamingContext routingProtocolContext) { + Ipv6RouteCustomizer(@Nonnull final DumpCacheManager ipv6RoutesDumpManager, + @Nonnull final RoutingConfiguration configuration, + @Nonnull final MultiNamingContext routeHopContext, + @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext routesContext, + @Nonnull final NamingContext routingProtocolContext) { this.ipv6RoutesDumpManager = ipv6RoutesDumpManager; this.configuration = configuration; this.interfaceContext = interfaceContext; @@ -79,7 +81,7 @@ public class Ipv6RouteCustomizer final Optional ipv6RoutesDump = ipv6RoutesDumpManager.getDump(instanceIdentifier, readContext.getModificationCache()); - final String protocolName = instanceIdentifier.firstKeyOf(RoutingProtocol.class).getName(); + final String protocolName = instanceIdentifier.firstKeyOf(ControlPlaneProtocol.class).getName(); final int protocolTableId = routingProtocolContext.getIndex(protocolName, readContext.getMappingContext()); return ipv6RoutesDump.isPresent() @@ -102,13 +104,18 @@ public class Ipv6RouteCustomizer if (!routesContext.containsIndex(learnedRouteName, mappingContext)) { routesContext.addName(learnedRouteName, mappingContext); } - return keyForName(mappingContext, learnedRouteName); + return keyForLearnedName(learnedRouteName); } - return keyForName(mappingContext, routeName); + return keyForName(routeName); } - private RouteKey keyForName(final MappingContext mappingContext, final String name) { - return new RouteKey(Long.valueOf(routesContext.getIndex(name, mappingContext))); + private RouteKey keyForName(final String name) { + return new RouteKey(namesFactory.ipv6PrefixFromUniqueRouteName(name)); + } + + private RouteKey keyForLearnedName(final String name) { + String learnedPrefix = configuration.getLearnedRouteNamePrefix() + "_"; + return new RouteKey(namesFactory.ipv6PrefixFromUniqueRouteName(name.replace(learnedPrefix, ""))); } @Override @@ -127,8 +134,8 @@ public class Ipv6RouteCustomizer @Nonnull final RouteBuilder routeBuilder, @Nonnull final ReadContext readContext) throws ReadFailedException { final RouteKey key = instanceIdentifier.firstKeyOf(Route.class); - final String mappedName = routesContext.getName(key.getId().intValue(), readContext.getMappingContext()); - final String protocolName = instanceIdentifier.firstKeyOf(RoutingProtocol.class).getName(); + final String protocolName = instanceIdentifier.firstKeyOf(ControlPlaneProtocol.class).getName(); + final String mappedName = namesFactory.uniqueRouteName(protocolName, key.getDestinationPrefix()); final int protocolTableId = routingProtocolContext.getIndex(protocolName, readContext.getMappingContext()); final Optional ipv6RoutesDump = ipv6RoutesDumpManager.getDump(instanceIdentifier, readContext.getModificationCache()); @@ -144,13 +151,17 @@ public class Ipv6RouteCustomizer if (opDetail.isPresent()) { final Ip6FibDetails detail = opDetail.get(); - routeBuilder.setNextHopOptions( + routeBuilder.setNextHop( resolveHopType(mappedName, Arrays.asList(detail.path), interfaceContext, routeHopContext, readContext.getMappingContext(), namesFactory)) .setKey(key) - .setId(key.getId()) + .setDestinationPrefix(key.getDestinationPrefix()) .setDestinationPrefix(toIpv6Prefix(detail.address, toJavaByte(detail.addressLength))) - .setVppIpv6RouteState(new VppIpv6RouteStateBuilder().build()); + .addAugmentation(VppIpv6RouteAttributesAugmentation.class, + new VppIpv6RouteAttributesAugmentationBuilder() + .setVppIpv6Route(new VppIpv6RouteBuilder() + .build()) + .build()); } } } diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingInstanceCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingInstanceCustomizer.java deleted file mode 100644 index 78e869f9a..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingInstanceCustomizer.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.read; - -import com.google.common.collect.ImmutableList; -import io.fd.hc2vpp.routing.RoutingConfiguration; -import io.fd.honeycomb.translate.read.ReadContext; -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; -import java.util.List; -import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.RoutingStateBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.StandardRoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.RoutingInstanceBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.RoutingInstanceKey; -import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Returns default instance of routing instance - */ -public class RoutingInstanceCustomizer - implements ListReaderCustomizer { - - private RoutingInstanceKey defaultKey; - - public RoutingInstanceCustomizer(@Nonnull final RoutingConfiguration configuration) { - defaultKey = new RoutingInstanceKey(configuration.getDefaultRoutingInstanceName()); - } - - @Nonnull - @Override - public List getAllIds(@Nonnull final InstanceIdentifier instanceIdentifier, - @Nonnull final ReadContext readContext) throws ReadFailedException { - return ImmutableList.of(defaultKey); - } - - @Override - public void merge(@Nonnull final Builder builder, @Nonnull final List list) { - RoutingStateBuilder.class.cast(builder).setRoutingInstance(list); - } - - @Nonnull - @Override - public RoutingInstanceBuilder getBuilder(@Nonnull final InstanceIdentifier instanceIdentifier) { - return new RoutingInstanceBuilder(); - } - - @Override - public void readCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, - @Nonnull final RoutingInstanceBuilder routingInstanceBuilder, - @Nonnull final ReadContext readContext) throws ReadFailedException { - routingInstanceBuilder.setType(StandardRoutingInstance.class) - .setKey(defaultKey) - .setName(defaultKey.getName()); - } -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizer.java deleted file mode 100644 index bbc9727a6..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizer.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.read; - -import com.google.common.base.Optional; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.routing.trait.RouteMapper; -import io.fd.honeycomb.translate.ModificationCache; -import io.fd.honeycomb.translate.read.ReadContext; -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; -import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Static; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocolsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolStateVppAttr; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolStateVppAttrBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol.VppProtocolStateAttributesBuilder; -import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - - -public class RoutingProtocolCustomizer - implements ListReaderCustomizer, RouteMapper { - - private final NamingContext routingProtocolContext; - private final DumpCacheManager ipv4RoutesDumpManager; - private final DumpCacheManager ipv6RoutesDumpManager; - - - public RoutingProtocolCustomizer(@Nonnull final NamingContext routingProtocolContext, - @Nonnull final DumpCacheManager ipv4RoutesDumpManager, - @Nonnull final DumpCacheManager ipv6RoutesDumpManager) { - this.routingProtocolContext = routingProtocolContext; - this.ipv4RoutesDumpManager = ipv4RoutesDumpManager; - this.ipv6RoutesDumpManager = ipv6RoutesDumpManager; - } - - @Nonnull - @Override - public List getAllIds(@Nonnull final InstanceIdentifier instanceIdentifier, - @Nonnull final ReadContext readContext) throws ReadFailedException { - - final ModificationCache modificationCache = readContext.getModificationCache(); - - // builds keys from routing protocol prefix and unique set of table ids - return Stream.of( - ipv4TableIds(instanceIdentifier, modificationCache), - ipv6TableIds(instanceIdentifier, modificationCache)) - .flatMap(Collection::stream) - .map(tableId -> routingProtocolContext.getName(tableId, readContext.getMappingContext())) - .distinct() - .map(RoutingProtocolKey::new) - .collect(Collectors.toList()); - } - - private List ipv4TableIds(final InstanceIdentifier instanceIdentifier, - final ModificationCache modificationCache) throws ReadFailedException { - final Optional - ipv4Routes = ipv4RoutesDumpManager.getDump(instanceIdentifier, modificationCache); - - if (ipv4Routes.isPresent()) { - return ipv4Routes.get().ipFibDetails.stream() - .map(ipFibDetails -> ipFibDetails.tableId) - .collect(Collectors.toList()); - } - return Collections.emptyList(); - } - - private List ipv6TableIds(final InstanceIdentifier instanceIdentifier, - final ModificationCache modificationCache) throws ReadFailedException { - final Optional - ipv6Routes = ipv6RoutesDumpManager.getDump(instanceIdentifier, modificationCache); - - if (ipv6Routes.isPresent()) { - return ipv6Routes.get().ip6FibDetails.stream() - .map(ipFibDetails -> ipFibDetails.tableId) - .collect(Collectors.toList()); - } - return Collections.emptyList(); - } - - @Override - public void merge(@Nonnull final Builder builder, @Nonnull final List list) { - RoutingProtocolsBuilder.class.cast(builder).setRoutingProtocol(list); - } - - @Nonnull - @Override - public RoutingProtocolBuilder getBuilder(@Nonnull final InstanceIdentifier instanceIdentifier) { - return new RoutingProtocolBuilder(); - } - - @Override - public void readCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, - @Nonnull final RoutingProtocolBuilder routingProtocolBuilder, - @Nonnull final ReadContext readContext) throws ReadFailedException { - - final RoutingProtocolKey key = instanceIdentifier.firstKeyOf(RoutingProtocol.class); - routingProtocolBuilder.setName(key.getName()).setKey(key).setType(Static.class) - .addAugmentation(RoutingProtocolStateVppAttr.class, new RoutingProtocolStateVppAttrBuilder() - .setVppProtocolStateAttributes(new VppProtocolStateAttributesBuilder() - .setPrimaryVrf(new VniReference(Long.valueOf(routingProtocolContext - .getIndex(key.getName(), readContext.getMappingContext())))) - .build()) - .build()); - } -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingReaderFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingReaderFactory.java new file mode 100644 index 000000000..9ec765c86 --- /dev/null +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingReaderFactory.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.routing.read; + +import com.google.inject.Inject; +import com.google.inject.name.Named; +import io.fd.hc2vpp.common.translate.util.MultiNamingContext; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.routing.Ipv4RoutingNodes; +import io.fd.hc2vpp.routing.Ipv6RoutingNodes; +import io.fd.hc2vpp.routing.RoutingConfiguration; +import io.fd.hc2vpp.routing.RoutingIIds; +import io.fd.honeycomb.translate.impl.read.GenericListReader; +import io.fd.honeycomb.translate.read.ReaderFactory; +import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; +import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; +import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.Ip6FibDump; +import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.IpFibDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.RoutingBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocolsBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutesBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +/** + * Factory producing readers for routing plugin's data. + */ +public final class RoutingReaderFactory implements ReaderFactory, Ipv4RoutingNodes, Ipv6RoutingNodes { + + @Inject + private RoutingConfiguration configuration; + + @Inject + @Named("interface-context") + private NamingContext interfaceContext; + + @Inject + @Named(RoutingConfiguration.ROUTING_PROTOCOL_CONTEXT) + private NamingContext routingProtocolContext; + + @Inject + @Named(RoutingConfiguration.ROUTE_CONTEXT) + private NamingContext routeContext; + + @Inject + @Named(RoutingConfiguration.ROUTE_HOP_CONTEXT) + private MultiNamingContext routeHopContext; + + @Inject + private FutureJVppCore vppApi; + + @Override + public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) { + final DumpCacheManager ipv4DumpManager = newIpv4RoutesDumpManager(vppApi); + final DumpCacheManager ipv6DumpManager = newIpv6RoutesDumpManager(vppApi); + + registry.addStructuralReader(RoutingIIds.ROUTING, RoutingBuilder.class); + registry.addStructuralReader(RoutingIIds.RT_CPS, ControlPlaneProtocolsBuilder.class); + registry.add(new GenericListReader<>(RoutingIIds.RT_CPS_CP, + new ControlPlaneProtocolCustomizer(routingProtocolContext, + ipv4DumpManager, + ipv6DumpManager))); + registry.addStructuralReader(RoutingIIds.RT_CPS_CP_SR, StaticRoutesBuilder.class); + + registerIpv4RoutesReaders(registry, ipv4DumpManager, configuration, routeHopContext, + interfaceContext, routeContext, routingProtocolContext); + registerIpv6RoutesReaders(registry, ipv6DumpManager, configuration, routeHopContext, + interfaceContext, routeContext, routingProtocolContext); + } + + private static InstanceIdentifier ipv4Identifier( + final InstanceIdentifier staticRoutes2InstanceIdentifier) { + return staticRoutes2InstanceIdentifier.child(Ipv4.class); + } + + private static InstanceIdentifier ipv6Identifier( + final InstanceIdentifier staticRoutes2InstanceIdentifier) { + return staticRoutes2InstanceIdentifier.child(Ipv6.class); + } + + private static InstanceIdentifier staticRoutesIpv4Iid() { + return RoutingIIds.RT_CPS_CP_SR.augmentation(StaticRoutes1.class); + } + + private static InstanceIdentifier staticRoutesIpv6Iid() { + return RoutingIIds.RT_CPS_CP_SR.augmentation( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1.class); + } + + private DumpCacheManager newIpv4RoutesDumpManager( + @Nonnull final FutureJVppCore vppApi) { + return new DumpCacheManager.DumpCacheManagerBuilder() + .withExecutor( + (identifier, params) -> getReplyForRead(vppApi.ipFibDump(new IpFibDump()).toCompletableFuture(), + identifier)) + .acceptOnly(IpFibDetailsReplyDump.class) + .build(); + } + + private DumpCacheManager newIpv6RoutesDumpManager( + @Nonnull final FutureJVppCore vppApi) { + return new DumpCacheManager.DumpCacheManagerBuilder() + .withExecutor( + (identifier, params) -> getReplyForRead( + vppApi.ip6FibDump(new Ip6FibDump()).toCompletableFuture(), identifier)) + .acceptOnly(Ip6FibDetailsReplyDump.class) + .build(); + } + + private void registerIpv4RoutesReaders(@Nonnull final ModifiableReaderRegistryBuilder registry, + @Nonnull final DumpCacheManager ipv4DumpManager, + @Nonnull final RoutingConfiguration configuration, + @Nonnull final MultiNamingContext routeHopContext, + @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext routeContext, + @Nonnull final NamingContext routingProtocolContext) { + + final InstanceIdentifier staticRoutes2InstanceIdentifier = + staticRoutesIpv4Iid(); + final InstanceIdentifier ipv4InstanceIdentifier = ipv4Identifier(staticRoutes2InstanceIdentifier); + + registry.addStructuralReader(staticRoutes2InstanceIdentifier, StaticRoutes1Builder.class); + + registry.addStructuralReader(ipv4InstanceIdentifier, Ipv4Builder.class); + registry.subtreeAdd(ipv4RoutingHandledChildren(InstanceIdentifier.create(Route.class)), + new GenericListReader<>(ipv4InstanceIdentifier.child(Route.class), + new Ipv4RouteCustomizer(ipv4DumpManager, configuration, + routeHopContext, interfaceContext, + routeContext, routingProtocolContext))); + } + + private void registerIpv6RoutesReaders(@Nonnull final ModifiableReaderRegistryBuilder registry, + @Nonnull final DumpCacheManager ipv6DumpManager, + @Nonnull final RoutingConfiguration configuration, + @Nonnull final MultiNamingContext routeHopContext, + @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext routeContext, + @Nonnull final NamingContext routingProtocolContext) { + + final InstanceIdentifier ipv6InstanceIdentifier = ipv6Identifier(staticRoutesIpv6Iid()); + + registry.addStructuralReader(staticRoutesIpv6Iid(), + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1Builder.class); + registry.addStructuralReader(ipv6InstanceIdentifier, Ipv6Builder.class); + registry.subtreeAdd(ipv6RoutingHandledChildren(InstanceIdentifier.create( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route.class)), + new GenericListReader<>(ipv6InstanceIdentifier.child( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route.class), + new Ipv6RouteCustomizer(ipv6DumpManager, configuration, + routeHopContext, interfaceContext, + routeContext, routingProtocolContext))); + } +} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizer.java deleted file mode 100644 index ce88825b7..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizer.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.read; - -import io.fd.hc2vpp.routing.write.Ipv4WriteRoutingNodes; -import io.fd.hc2vpp.routing.write.Ipv6WriteRoutingNodes; -import io.fd.honeycomb.translate.read.ReadContext; -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.Initialized; -import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer; -import java.util.List; -import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.RoutingBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.RoutingState; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.RoutingStateBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.StandardRoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.RoutingProtocolsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutesBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolStateVppAttr; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolVppAttr; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolVppAttrBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol.VppProtocolAttributesBuilder; -import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RoutingStateCustomizer - implements InitializingReaderCustomizer, Ipv4WriteRoutingNodes { - - private static final Logger LOG = LoggerFactory.getLogger(RoutingStateCustomizer.class); - - private static RoutingInstance mapRoutingInstances( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.RoutingInstance state) { - return new RoutingInstanceBuilder() - .setName(state.getName()) - .setEnabled(true) - .setRouterId(state.getRouterId()) - .setType(StandardRoutingInstance.class) - .setRoutingProtocols(RoutingStateCustomizer.mapRoutingProtocols(state.getRoutingProtocols())) - .build(); - } - - private static RoutingProtocols mapRoutingProtocols( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocols state) { - - if (state != null) { - return new RoutingProtocolsBuilder() - .setRoutingProtocol(state.getRoutingProtocol() != null - ? RoutingStateCustomizer.mapRoutingProtocol(state.getRoutingProtocol()) - : null) - .build(); - } else { - return null; - } - } - - private static List mapRoutingProtocol( - final List state) { - return state.stream() - .map(routingProtocol -> new RoutingProtocolBuilder() - .setName(routingProtocol.getName()) - .setEnabled(true) - .setType(routingProtocol.getType()) - .setStaticRoutes(RoutingStateCustomizer.mapStaticRoutes(routingProtocol.getStaticRoutes())) - .addAugmentation(RoutingProtocolVppAttr.class, - mapVppAttr(routingProtocol.getAugmentation(RoutingProtocolStateVppAttr.class))) - .build()) - .collect(Collectors.toList()); - } - - private static RoutingProtocolVppAttr mapVppAttr(final RoutingProtocolStateVppAttr attrState) { - return new RoutingProtocolVppAttrBuilder() - .setVppProtocolAttributes(attrState.getVppProtocolStateAttributes() == null - ? null - : - new VppProtocolAttributesBuilder() - .setPrimaryVrf(attrState.getVppProtocolStateAttributes().getPrimaryVrf()) - .build()) - .build(); - } - - private static StaticRoutes mapStaticRoutes( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutes state) { - return new StaticRoutesBuilder() - .addAugmentation(CONFIG_IPV4_AUG_CLASS, - Ipv4WriteRoutingNodes.INSTANCE.mapIpv4Augmentation(state.getAugmentation(STATE_IPV4_AUG_CLASS))) - .addAugmentation(Ipv6WriteRoutingNodes.CONFIG_IPV6_AUG_CLASS, - Ipv6WriteRoutingNodes.INSTANCE.mapIpv6Augmentation(state.getAugmentation( - Ipv6WriteRoutingNodes.STATE_IPV6_AUG_CLASS))) - .build(); - } - - @Nonnull - @Override - public RoutingStateBuilder getBuilder(@Nonnull final InstanceIdentifier instanceIdentifier) { - return new RoutingStateBuilder(); - } - - @Override - public void readCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, - @Nonnull final RoutingStateBuilder routingStateBuilder, - @Nonnull final ReadContext readContext) throws ReadFailedException { - // does nothing - LOG.info("Reading {}", instanceIdentifier); - } - - @Override - public void merge(@Nonnull final Builder builder, @Nonnull final RoutingState routingState) { - //Routing state is root - } - - @Nonnull - @Override - public Initialized init(@Nonnull final InstanceIdentifier id, - @Nonnull final RoutingState readValue, - @Nonnull final ReadContext ctx) { - - return Initialized.create(InstanceIdentifier.create(Routing.class), new RoutingBuilder() - .setRoutingInstance(readValue.getRoutingInstance() - .stream() - .map(routingInstance -> mapRoutingInstances(routingInstance)) - .collect(Collectors.toList())) - .build()); - } -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingStateReaderFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingStateReaderFactory.java deleted file mode 100644 index ad0bf7494..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/read/RoutingStateReaderFactory.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.read; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Inject; -import com.google.inject.name.Named; -import io.fd.hc2vpp.common.translate.util.MultiNamingContext; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.routing.RoutingConfiguration; -import io.fd.honeycomb.translate.impl.read.GenericListReader; -import io.fd.honeycomb.translate.impl.read.GenericReader; -import io.fd.honeycomb.translate.read.ReaderFactory; -import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; -import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; -import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.RoutingState; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocolsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutesBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolStateVppAttr; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol.VppProtocolStateAttributes; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Factory producing readers for routing plugin's data. - */ -public final class RoutingStateReaderFactory implements ReaderFactory, Ipv4ReadRoutingNodes, Ipv6ReadRoutingNodes { - - private static final InstanceIdentifier ROOT_STATE_CONTAINER_ID = - InstanceIdentifier.create(RoutingState.class); - - @Inject - private RoutingConfiguration configuration; - - @Inject - @Named("interface-context") - private NamingContext interfaceContext; - - @Inject - @Named(RoutingConfiguration.ROUTING_PROTOCOL_CONTEXT) - private NamingContext routingProtocolContext; - - @Inject - @Named(RoutingConfiguration.ROUTE_CONTEXT) - private NamingContext routeContext; - - @Inject - @Named(RoutingConfiguration.ROUTE_HOP_CONTEXT) - private MultiNamingContext routeHopContext; - - @Inject - private FutureJVppCore vppApi; - - @Override - public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) { - final DumpCacheManager ipv4DumpManager = newIpv4RoutesDumpManager(vppApi); - final DumpCacheManager ipv6DumpManager = newIpv6RoutesDumpManager(vppApi); - - final InstanceIdentifier routingInstanceInstanceIdentifier = - routingInstanceIdentifier(ROOT_STATE_CONTAINER_ID); - final InstanceIdentifier routingProtocolsInstanceIdentifier = - routingProtocolsId(routingInstanceInstanceIdentifier); - final InstanceIdentifier routingProtocolInstanceIdentifier = - routingProtocolInstanceIdentifier(routingProtocolsInstanceIdentifier); - final InstanceIdentifier staticRoutesInstanceIdentifier = - staticRoutesInstanceIdentifier(routingProtocolInstanceIdentifier); - - // RoutingState - registry.add(new GenericReader<>(ROOT_STATE_CONTAINER_ID, new RoutingStateCustomizer())); - // RoutingInstance - registry.add(new GenericListReader<>(routingInstanceInstanceIdentifier, - new RoutingInstanceCustomizer(configuration))); - - // RoutingProtocols - registry.addStructuralReader(routingProtocolsInstanceIdentifier, RoutingProtocolsBuilder.class); - - // RoutingProtocol - registry.subtreeAdd(routingProtocolHandledChildren(), new GenericListReader<>(routingProtocolInstanceIdentifier, - new RoutingProtocolCustomizer(routingProtocolContext, ipv4DumpManager, ipv6DumpManager))); - - // StaticRoutes - registry.addStructuralReader(staticRoutesInstanceIdentifier, StaticRoutesBuilder.class); - - registerIpv4Routes(staticRoutesInstanceIdentifier, registry, ipv4DumpManager, configuration, routeHopContext, - interfaceContext, routeContext, routingProtocolContext); - registerIpv6Routes(staticRoutesInstanceIdentifier, registry, ipv6DumpManager, configuration, routeHopContext, - interfaceContext, routeContext, routingProtocolContext); - } - - private static ImmutableSet> routingProtocolHandledChildren() { - return ImmutableSet - .of(InstanceIdentifier.create(RoutingProtocol.class).augmentation(RoutingProtocolStateVppAttr.class) - .child(VppProtocolStateAttributes.class)); - } - - private InstanceIdentifier staticRoutesInstanceIdentifier( - final InstanceIdentifier routingProtocolInstanceIdentifier) { - return routingProtocolInstanceIdentifier.child(StaticRoutes.class); - } - - private InstanceIdentifier routingProtocolInstanceIdentifier( - final InstanceIdentifier routingProtocolsInstanceIdentifier) { - return routingProtocolsInstanceIdentifier.child(RoutingProtocol.class); - } - - private InstanceIdentifier routingProtocolsId( - final InstanceIdentifier routingInstanceInstanceIdentifier) { - return routingInstanceInstanceIdentifier.child(RoutingProtocols.class); - } - - private InstanceIdentifier routingInstanceIdentifier( - final InstanceIdentifier routingStateId) { - return routingStateId.child(RoutingInstance.class); - } -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/Ipv4RoutePathParser.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/Ipv4RoutePathParser.java index 6f189af13..f1217ee73 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/Ipv4RoutePathParser.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/Ipv4RoutePathParser.java @@ -16,26 +16,34 @@ package io.fd.hc2vpp.routing.trait; +import static io.fd.hc2vpp.routing.trait.RouteMapper.isDefaultInterfaceIndex; + import io.fd.hc2vpp.common.translate.util.AddressTranslator; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.naming.Ipv4RouteNamesFactory; import io.fd.honeycomb.translate.MappingContext; import io.fd.vpp.jvpp.core.types.FibPath; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.NextHopOptions; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.*; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.NextHopListBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.table.lookup.TableLookupParamsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; - - - -import javax.annotation.Nonnull; import java.util.List; import java.util.stream.Collectors; - -import static io.fd.hc2vpp.routing.trait.RouteMapper.isDefaultInterfaceIndex; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.SimpleNextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.SimpleNextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.NextHopOptions; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopListBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SpecialNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SpecialNextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.TableLookupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentationBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; public interface Ipv4RoutePathParser extends RouteMapper { @@ -55,25 +63,23 @@ public interface Ipv4RoutePathParser extends RouteMapper { } static NextHopOptions tableLookup() { - return new TableLookupBuilder() - .setTableLookupParams( - new TableLookupParamsBuilder() - // TODO - https://jira.fd.io/browse/VPP-994 - .setSecondaryVrf(new VniReference(0L)) - .build() - ).build(); + return new TableLookupCaseBuilder() + // TODO - https://jira.fd.io/browse/VPP-994 + .setSecondaryVrf(new VniReference(0L)).build(); } static SpecialNextHop specialHop(final FibPath singlePath) { return new SpecialNextHopBuilder() - .setSpecialNextHop(RouteMapper.INSTANCE.specialHopType(singlePath)) + .setSpecialNextHopEnum(RouteMapper.INSTANCE.specialHopType(singlePath)) .build(); } static SimpleNextHop simpleHop(final FibPath path, final NamingContext interfaceContext, final MappingContext mappingContext) { return resolveInterfaceIfSpecified(new SimpleNextHopBuilder(), path.swIfIndex, interfaceContext, mappingContext) - .setNextHop(AddressTranslator.INSTANCE.arrayToIpv4AddressNoZone(path.nextHop)) + .addAugmentation(SimpleNextHop1.class, new SimpleNextHop1Builder() + .setNextHopAddress(AddressTranslator.INSTANCE.arrayToIpv4AddressNoZone(path.nextHop)) + .build()) .build(); } @@ -86,29 +92,44 @@ public interface Ipv4RoutePathParser extends RouteMapper { return builder; } - static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList hopList( - final String routeName, - final List parsedHops, - final NamingContext interfaceContext, - final MultiNamingContext routeHopContext, - final MappingContext mappingContext, - final Ipv4RouteNamesFactory namesFactory) { - return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopListBuilder() - .setNextHopList( - new NextHopListBuilder().setNextHop(parsedHops.stream() - .map(fibPath -> resolveInterfaceIfSpecified(new NextHopBuilder(), fibPath.swIfIndex, - interfaceContext, mappingContext) - .setId((long) (routeHopContext.getChildIndex(routeName, - namesFactory.uniqueRouteHopName(fibPath, mappingContext), - mappingContext))) - .setWeight(((short) fibPath.weight)) - .setAddress( - AddressTranslator.INSTANCE - .arrayToIpv4AddressNoZone(fibPath.nextHop)) - .build()) - .collect(Collectors.toList())) - .build()) - .build(); + static NextHopList hopList(final String routeName, final List parsedHops, + final NamingContext interfaceContext, final MultiNamingContext routeHopContext, + final MappingContext mappingContext, final Ipv4RouteNamesFactory namesFactory) { + + return new NextHopListBuilder().setNextHopList( + parseNextHopList(routeName, parsedHops, interfaceContext, routeHopContext, mappingContext, namesFactory)) + .build(); + } + + static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.NextHopList parseNextHopList( + String routeName, List parsedHops, NamingContext interfaceContext, MultiNamingContext routeHopContext, + MappingContext mappingContext, Ipv4RouteNamesFactory namesFactory) { + + List nextHops = parsedHops.stream() + .map(fibPath -> resolveInterfaceIfSpecified(new NextHopBuilder(), fibPath.swIfIndex, interfaceContext, + mappingContext).setIndex( + getRouteIndex(routeName, routeHopContext, mappingContext, namesFactory, fibPath)) + .addAugmentation(NextHop1.class, new NextHop1Builder().setNextHopAddress( + AddressTranslator.INSTANCE.arrayToIpv4AddressNoZone(fibPath.nextHop)).build()) + .addAugmentation(VppIpv4NextHopAugmentation.class, + new VppIpv4NextHopAugmentationBuilder().setWeight((short) fibPath.weight).build()) + .build()) + .collect(Collectors.toList()); + + return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.NextHopListBuilder() + .setNextHop(nextHops) + .build(); + } + + static String getRouteIndex(String routeName, MultiNamingContext routeHopContext, MappingContext mappingContext, + Ipv4RouteNamesFactory namesFactory, FibPath fibPath) { + if (routeName.contains("learned-route")) { + routeHopContext.addChild(routeName, namesFactory.uniqueRouteHopName(fibPath, mappingContext), + mappingContext); + } + return String.valueOf( + routeHopContext.getChildIndex(routeName, namesFactory.uniqueRouteHopName(fibPath, mappingContext), + mappingContext)); } static NextHopBuilder resolveInterfaceIfSpecified(final NextHopBuilder builder, final int index, @@ -120,15 +141,15 @@ public interface Ipv4RoutePathParser extends RouteMapper { return builder; } - default NextHopOptions resolveHopType(@Nonnull final String routeName, - final List parsedHops, - @Nonnull final NamingContext interfaceContext, - @Nonnull final MultiNamingContext routeHopContext, - @Nonnull final MappingContext mappingContext, - @Nonnull final Ipv4RouteNamesFactory namesFactory) { + default org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.NextHop resolveHopType( + @Nonnull final String routeName, final List parsedHops, @Nonnull final NamingContext interfaceContext, + @Nonnull final MultiNamingContext routeHopContext, @Nonnull final MappingContext mappingContext, + @Nonnull final Ipv4RouteNamesFactory namesFactory) { + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.NextHopBuilder + nextHopBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.NextHopBuilder(); - return parsedHops == null || parsedHops.isEmpty() - ? null - : resolveOption(routeName, parsedHops, interfaceContext, routeHopContext, mappingContext, namesFactory); + return parsedHops == null || parsedHops.isEmpty() ? null : nextHopBuilder.setNextHopOptions( + resolveOption(routeName, parsedHops, interfaceContext, routeHopContext, mappingContext, namesFactory)) + .build(); } } diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/Ipv6RoutePathParser.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/Ipv6RoutePathParser.java index 1c7243ce8..27b5edf5d 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/Ipv6RoutePathParser.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/Ipv6RoutePathParser.java @@ -16,26 +16,34 @@ package io.fd.hc2vpp.routing.trait; +import static io.fd.hc2vpp.routing.trait.RouteMapper.isDefaultInterfaceIndex; + import io.fd.hc2vpp.common.translate.util.AddressTranslator; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.naming.Ipv6RouteNamesFactory; import io.fd.honeycomb.translate.MappingContext; import io.fd.vpp.jvpp.core.types.FibPath; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.NextHopOptions; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.*; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.NextHopListBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.table.lookup.TableLookupParamsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; - - -import javax.annotation.Nonnull; import java.util.List; import java.util.stream.Collectors; - -import static io.fd.hc2vpp.routing.trait.RouteMapper.isDefaultInterfaceIndex; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.SimpleNextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.SimpleNextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.NextHopOptions; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopListBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SpecialNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SpecialNextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.TableLookupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentationBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; public interface Ipv6RoutePathParser extends RouteMapper { @@ -55,25 +63,23 @@ public interface Ipv6RoutePathParser extends RouteMapper { } static NextHopOptions tableLookup() { - return new TableLookupBuilder() - .setTableLookupParams( - new TableLookupParamsBuilder() - // TODO - https://jira.fd.io/browse/VPP-994 - .setSecondaryVrf(new VniReference(0L)) - .build() - ).build(); + return new TableLookupCaseBuilder() + // TODO - https://jira.fd.io/browse/VPP-994 + .setSecondaryVrf(new VniReference(0L)).build(); } static SpecialNextHop specialHop(final FibPath fibPath) { return new SpecialNextHopBuilder() - .setSpecialNextHop(INSTANCE.specialHopType(fibPath)) + .setSpecialNextHopEnum(INSTANCE.specialHopType(fibPath)) .build(); } static SimpleNextHop simpleHop(final FibPath path, final NamingContext interfaceContext, final MappingContext mappingContext) { return resolveInterfaceIfSpecified(new SimpleNextHopBuilder(), path.swIfIndex, interfaceContext, mappingContext) - .setNextHop(AddressTranslator.INSTANCE.arrayToIpv6AddressNoZone(path.nextHop)) + .addAugmentation(SimpleNextHop1.class, new SimpleNextHop1Builder() + .setNextHopAddress(AddressTranslator.INSTANCE.arrayToIpv6AddressNoZone(path.nextHop)) + .build()) .build(); } @@ -87,35 +93,33 @@ public interface Ipv6RoutePathParser extends RouteMapper { return builder; } - static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList hopList( - final String routeName, - final List parsedHops, - final NamingContext interfaceContext, - final MultiNamingContext routeHopContext, - final MappingContext mappingContext, - final Ipv6RouteNamesFactory namesFactory) { - return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopListBuilder() - .setNextHopList( + static NextHopList hopList(final String routeName, final List parsedHops, + final NamingContext interfaceContext, final MultiNamingContext routeHopContext, + final MappingContext mappingContext, final Ipv6RouteNamesFactory namesFactory) { + return new NextHopListBuilder() + .setNextHopList( buildNextHopList(routeName, parsedHops, interfaceContext, routeHopContext, mappingContext, namesFactory)) .build(); } - static NextHopList buildNextHopList(final String routeName, final List parsedHops, - final NamingContext interfaceContext, - final MultiNamingContext routeHopContext, - final MappingContext mappingContext, - final Ipv6RouteNamesFactory namesFactory) { - return new NextHopListBuilder().setNextHop(parsedHops.stream() - .map(fibPath -> resolveInterfaceIfSpecified(new NextHopBuilder(), fibPath.swIfIndex, interfaceContext, - mappingContext) - .setId(findIdWithinRouteContext(routeName, routeHopContext, mappingContext, fibPath, - namesFactory)) - .setWeight((short) fibPath.weight) - .setAddress(AddressTranslator.INSTANCE.arrayToIpv6AddressNoZone(fibPath.nextHop)) + static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.NextHopList buildNextHopList( + final String routeName, final List parsedHops, final NamingContext interfaceContext, + final MultiNamingContext routeHopContext, final MappingContext mappingContext, + final Ipv6RouteNamesFactory namesFactory) { + + return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.NextHopListBuilder().setNextHop(parsedHops.stream() + .map(fibPath -> resolveInterfaceIfSpecified(new NextHopBuilder(), fibPath.swIfIndex, + interfaceContext, mappingContext) + .setIndex(String.valueOf(findIdWithinRouteContext(routeName, routeHopContext, mappingContext, + fibPath, namesFactory))) + .addAugmentation(NextHop1.class, new NextHop1Builder() + .setNextHopAddress(AddressTranslator.INSTANCE.arrayToIpv6AddressNoZone(fibPath.nextHop)) .build()) - .collect(Collectors.toList())) - .build(); + .addAugmentation(VppIpv6NextHopAugmentation.class, + new VppIpv6NextHopAugmentationBuilder().setWeight((short) fibPath.weight).build()) + .build()) + .collect(Collectors.toList())).build(); } static NextHopBuilder resolveInterfaceIfSpecified(NextHopBuilder builder, final int index, @@ -135,15 +139,19 @@ public interface Ipv6RoutePathParser extends RouteMapper { .getChildIndex(routeName, namesFactory.uniqueRouteHopName(fibPath, mappingContext), mappingContext)); } - default NextHopOptions resolveHopType(@Nonnull final String routeName, - final List parsedHops, - @Nonnull final NamingContext interfaceContext, - @Nonnull final MultiNamingContext routeHopContext, - @Nonnull final MappingContext mappingContext, - @Nonnull final Ipv6RouteNamesFactory namesFactory) { + default NextHop resolveHopType(@Nonnull final String routeName, + final List parsedHops, + @Nonnull final NamingContext interfaceContext, + @Nonnull final MultiNamingContext routeHopContext, + @Nonnull final MappingContext mappingContext, + @Nonnull final Ipv6RouteNamesFactory namesFactory) { + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.NextHopBuilder + nextHopBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.NextHopBuilder(); return parsedHops == null || parsedHops.isEmpty() ? null - : resolveOption(routeName, parsedHops, interfaceContext, routeHopContext, mappingContext, namesFactory); + : nextHopBuilder.setNextHopOptions(resolveOption(routeName, parsedHops, interfaceContext, + routeHopContext, mappingContext, + namesFactory)).build(); } } diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/RouteMapper.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/RouteMapper.java index 8da15c1bd..14b4d0727 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/RouteMapper.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/trait/RouteMapper.java @@ -19,11 +19,8 @@ package io.fd.hc2vpp.routing.trait; import io.fd.hc2vpp.common.translate.util.AddressTranslator; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; import io.fd.vpp.jvpp.core.types.FibPath; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping; - import javax.annotation.Nonnull; -import java.util.Arrays; -import java.util.stream.IntStream; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop; public interface RouteMapper extends AddressTranslator, ByteDataTranslator { @@ -82,15 +79,15 @@ public interface RouteMapper extends AddressTranslator, ByteDataTranslator { return !isSpecialHop(path) && isArrayZeroed(path.nextHop); } - default SpecialNextHopGrouping.SpecialNextHop specialHopType(final FibPath singlePath) { + default SpecialNextHop.SpecialNextHopEnum specialHopType(final FibPath singlePath) { if (flagEnabled(singlePath.isDrop)) { - return SpecialNextHopGrouping.SpecialNextHop.Blackhole; + return SpecialNextHop.SpecialNextHopEnum.Blackhole; } else if (flagEnabled(singlePath.isLocal)) { - return SpecialNextHopGrouping.SpecialNextHop.Receive; + return SpecialNextHop.SpecialNextHopEnum.Receive; } else if (flagEnabled(singlePath.isProhibit)) { - return SpecialNextHopGrouping.SpecialNextHop.Prohibit; + return SpecialNextHop.SpecialNextHopEnum.Prohibit; } else if (flagEnabled(singlePath.isUnreach)) { - return SpecialNextHopGrouping.SpecialNextHop.Unreachable; + return SpecialNextHop.SpecialNextHopEnum.Unreachable; } else { throw new IllegalArgumentException( String.format("An attempt to resolve illegal path %s detected ", singlePath.toString())); diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizer.java new file mode 100644 index 000000000..0a0fa3e47 --- /dev/null +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizer.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.routing.write; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkState; + +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.MappingContext; +import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer; +import io.fd.honeycomb.translate.write.WriteContext; +import io.fd.honeycomb.translate.write.WriteFailedException; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.RoutingProtocolVppAttr; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +/** + * Customizer for handling of write operations for {@link ControlPlaneProtocol} + */ +final class ControlPlaneProtocolCustomizer + implements ListWriterCustomizer { + + private final NamingContext routingProtocolContext; + + ControlPlaneProtocolCustomizer(@Nonnull final NamingContext routingProtocolContext) { + this.routingProtocolContext = routingProtocolContext; + } + + @Override + public void writeCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, + @Nonnull final ControlPlaneProtocol routingProtocol, + @Nonnull final WriteContext writeContext) + throws WriteFailedException { + checkIsStatic(routingProtocol); + + final int tableId = extractTableId(routingProtocol); + final MappingContext mappingContext = writeContext.getMappingContext(); + final String newProtocolName = routingProtocol.getName(); + + // enclosed in synchronized block to prevent change of state after containsName/before addName + synchronized (routingProtocolContext) { + if (!routingProtocolContext.containsName(tableId, mappingContext)) { + // if not present in mapping,create assignment to table id. This works only with auto-create flag enabled + // while using ip_add_del_table + routingProtocolContext.addName(tableId, newProtocolName, mappingContext); + } else { + // prevent to fail while restoring data(trying to remap already mapped name) + if (!newProtocolName.equals(routingProtocolContext.getName(tableId, mappingContext))) { + throw new IllegalStateException(String.format( + "An attempt to assign protocol %s to table id %s. Table id already assigned to protocol %s", + newProtocolName, tableId, routingProtocolContext.getName(tableId, mappingContext))); + } + } + } + } + + @Override + public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, + @Nonnull final ControlPlaneProtocol routingProtocol, + @Nonnull final WriteContext writeContext) + throws WriteFailedException { + routingProtocolContext.removeName(routingProtocol.getName(), writeContext.getMappingContext()); + } + + /** + * Checks whether control plane protocol is static(we support only static ones for now) + */ + private void checkIsStatic(final ControlPlaneProtocol routingProtocol) { + checkArgument(routingProtocol.getType() == Static.class, "Only static routes are allowed"); + } + + private int extractTableId(final ControlPlaneProtocol protocol) { + final RoutingProtocolVppAttr vppAttr = protocol.getAugmentation(RoutingProtocolVppAttr.class); + + checkState(vppAttr != null && vppAttr.getVppProtocolAttributes() != null, + "Vpp routing protocol attributes not defined"); + + return vppAttr.getVppProtocolAttributes().getPrimaryVrf().getValue().intValue(); + } +} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizer.java index 72254d1f6..1eb249f04 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizer.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizer.java @@ -33,24 +33,23 @@ import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.vpp.jvpp.core.dto.IpAddDelRoute; import io.fd.vpp.jvpp.core.future.FutureJVppCore; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SimpleNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SpecialNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.TableLookup; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; - +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SpecialNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.TableLookupCase; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nonnull; -import java.util.List; -import java.util.stream.Collectors; - /** * Customizer for handling write operations for {@link Ipv4} according to ietf-ipv4-unicast-routing.yang */ @@ -59,7 +58,6 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer private static final Logger LOG = LoggerFactory.getLogger(Ipv4RouteCustomizer.class); - private final NamingContext routesContext; private final MultiNamingContext routesHopsContext; /** @@ -75,12 +73,12 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer */ private final Ipv4RouteNamesFactory routeNamesFactory; - public Ipv4RouteCustomizer(@Nonnull final FutureJVppCore futureJVppCore, - @Nonnull final NamingContext interfaceContext, - @Nonnull final NamingContext routesContext, - @Nonnull final NamingContext routingProtocolContext, - @Nonnull final MultiNamingContext routesHopsContext, - @Nonnull final VppClassifierContextManager classifierContextManager) { + Ipv4RouteCustomizer(@Nonnull final FutureJVppCore futureJVppCore, + @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext routesContext, + @Nonnull final NamingContext routingProtocolContext, + @Nonnull final MultiNamingContext routesHopsContext, + @Nonnull final VppClassifierContextManager classifierContextManager) { super(futureJVppCore); this.routesContext = routesContext; @@ -92,14 +90,15 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer specialNextHopRequestFactory = SpecialNextHopRequestFactory.forContexts(classifierContextManager, interfaceContext, routingProtocolContext); routeNamesFactory = new Ipv4RouteNamesFactory(interfaceContext, routingProtocolContext); - tableLookupRequestFactory = new TableLookupRequestFactory(classifierContextManager, interfaceContext, routingProtocolContext); + tableLookupRequestFactory = + new TableLookupRequestFactory(classifierContextManager, interfaceContext, routingProtocolContext); } @Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, @Nonnull final Route route, @Nonnull final WriteContext writeContext) throws WriteFailedException { - final String parentProtocolName = instanceIdentifier.firstKeyOf(RoutingProtocol.class).getName(); + final String parentProtocolName = instanceIdentifier.firstKeyOf(ControlPlaneProtocol.class).getName(); final String routeName = routeNamesFactory.uniqueRouteName(parentProtocolName, route); writeRoute(instanceIdentifier, parentProtocolName, routeName, route, writeContext, true); @@ -120,7 +119,7 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, @Nonnull final Route route, @Nonnull final WriteContext writeContext) throws WriteFailedException { - final String parentProtocolName = instanceIdentifier.firstKeyOf(RoutingProtocol.class).getName(); + final String parentProtocolName = instanceIdentifier.firstKeyOf(ControlPlaneProtocol.class).getName(); final String routeName = routeNamesFactory.uniqueRouteName(parentProtocolName, route); writeRoute(instanceIdentifier, parentProtocolName, routeName, route, writeContext, false); routesContext.removeName(routeName, writeContext.getMappingContext()); @@ -132,12 +131,12 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer @Nonnull final Route route, @Nonnull final WriteContext writeContext, final boolean isAdd) throws WriteFailedException { - if (route.getNextHopOptions() instanceof SimpleNextHop) { + if (route.getNextHop().getNextHopOptions() instanceof SimpleNextHop) { writeRoute( simpleHopRequestFactory.createIpv4SimpleHopRequest(isAdd, parentProtocolName, route, writeContext.getMappingContext()), identifier); - } else if (route.getNextHopOptions() instanceof NextHopList) { + } else if (route.getNextHop().getNextHopOptions() instanceof NextHopList) { final List createdHops = writeMultihopRoute(identifier, parentProtocolName, route, writeContext, isAdd); @@ -147,10 +146,14 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer } else { removeMappingForEachHop(routeName, writeContext, createdHops); } - } else if (route.getNextHopOptions() instanceof SpecialNextHop) { + } else if (route.getNextHop().getNextHopOptions() instanceof SpecialNextHop) { writeSpecialHopRoute(identifier, route, parentProtocolName, writeContext, isAdd); - } else if (route.getNextHopOptions() instanceof TableLookup) { - writeRoute(tableLookupRequestFactory.createV4TableLookupRouteRequest(isAdd, parentProtocolName, route, writeContext.getMappingContext()), identifier); + } else if (route.getNextHop().getNextHopOptions() instanceof TableLookupCase) { + writeRoute(tableLookupRequestFactory.createV4TableLookupRouteRequest(isAdd, + parentProtocolName, + route, + writeContext.getMappingContext()), + identifier); } else { throw new IllegalArgumentException("Unsupported next-hop type"); } @@ -166,26 +169,23 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer private void addMappingForEachHop(final @Nonnull String routeName, final @Nonnull WriteContext writeContext, final List createdHops) { createdHops.forEach(nextHop -> routesHopsContext.addChild(routeName, - nextHop.getId().intValue(), + Integer.valueOf(nextHop.getIndex()), routeNamesFactory.uniqueRouteHopName(nextHop), writeContext.getMappingContext())); } private List writeMultihopRoute(@Nonnull final InstanceIdentifier identifier, - @Nonnull final String parentProtocolName, - @Nonnull final Route route, - @Nonnull final WriteContext writeContext, - final boolean isAdd) + @Nonnull final String parentProtocolName, @Nonnull final Route route, + @Nonnull final WriteContext writeContext, final boolean isAdd) throws WriteFailedException { // list of next hops - final NextHopList hopList = NextHopList.class.cast(route.getNextHopOptions()); + final NextHopList hopList = NextHopList.class.cast(route.getNextHop().getNextHopOptions()); final MappingContext mappingContext = writeContext.getMappingContext(); LOG.debug("Writing hop list {} for route {}", hopList, identifier); // order hops to preserve order by ids(even that model is not ordered) - final List orderedHops = hopList.getNextHopList().getNextHop() - .stream() - .sorted((left, right) -> (int) (left.getId() - right.getId())) + final List orderedHops = hopList.getNextHopList().getNextHop().stream() + .sorted(Comparator.comparing(NextHop::getIndex)) .collect(Collectors.toList()); for (NextHop hop : orderedHops) { @@ -200,16 +200,16 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer return orderedHops; } - private void writeSpecialHopRoute(final @Nonnull InstanceIdentifier identifier, final @Nonnull Route route, - final @Nonnull String parentProtocolName, final @Nonnull WriteContext writeContext, - final boolean isAdd) + final @Nonnull String parentProtocolName, + final @Nonnull WriteContext writeContext, final boolean isAdd) throws WriteFailedException { - final SpecialNextHop hop = SpecialNextHop.class.cast(route.getNextHopOptions()); + final SpecialNextHop hop = SpecialNextHop.class.cast(route.getNextHop().getNextHopOptions()); final MappingContext mappingContext = writeContext.getMappingContext(); - final IpAddDelRoute request = specialNextHopRequestFactory - .createIpv4SpecialHopRequest(isAdd, parentProtocolName, route, mappingContext, hop.getSpecialNextHop()); + final IpAddDelRoute request = + specialNextHopRequestFactory.createIpv4SpecialHopRequest(isAdd, parentProtocolName, route, mappingContext, + hop.getSpecialNextHopEnum()); writeRoute(request, identifier); } diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4WriteRoutingNodes.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4WriteRoutingNodes.java deleted file mode 100644 index 292feb9e9..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4WriteRoutingNodes.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.write; - -import com.google.common.collect.ImmutableSet; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes1Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes2; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.NextHopOptions; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.VppIpv4Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.VppIpv4RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.*; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.table.lookup.TableLookupParams; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.table.lookup.TableLookupParamsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -public interface Ipv4WriteRoutingNodes { - - Ipv4WriteRoutingNodes INSTANCE = new Ipv4WriteRoutingNodes() { - }; - - Class CONFIG_IPV4_AUG_CLASS = StaticRoutes1.class; - Class STATE_IPV4_AUG_CLASS = StaticRoutes2.class; - - static Ipv4 mapIpv4( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4 state) { - return new Ipv4Builder() - .setRoute(state.getRoute() - .stream() - .map(route -> new RouteBuilder() - .setKey(new RouteKey(route.getKey().getId())) - .setDestinationPrefix(route.getDestinationPrefix()) - .setDescription(route.getDescription()) - .setId(route.getId()) - .setVppIpv4Route(mapVppIpv4Route(route.getVppIpv4RouteState())) - .setNextHopOptions(mapNextHopOptions(route.getNextHopOptions())) - .build()) - .collect(Collectors.toList())) - .build(); - } - - static VppIpv4Route mapVppIpv4Route( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.VppIpv4RouteState state) { - - return state == null - ? null - : new VppIpv4RouteBuilder() - // false is default - .setClassifyTable(state.getClassifyTable()) - .build(); - } - - static NextHopOptions mapNextHopOptions( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.NextHopOptions state) { - if (state instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SimpleNextHop) { - return mapSimpleNextHop( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SimpleNextHop.class - .cast(state)); - } else if (state instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList) { - return mapNextHopList( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList.class - .cast(state)); - } else if (state instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SpecialNextHop) { - return mapSpecialNextHop( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SpecialNextHop.class - .cast(state)); - } else if(state instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.TableLookup) - return mapTableLookup(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.TableLookup.class.cast(state)); - else { - throw new UnsupportedOperationException("Unsupported next hop type"); - } - } - - static TableLookup mapTableLookup(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.TableLookup state) { - return new TableLookupBuilder() - .setTableLookupParams( - Optional.ofNullable(state.getTableLookupParams()) - .map(params -> new TableLookupParamsBuilder().setSecondaryVrf(params.getSecondaryVrf()).build()) - .orElse(null)) - .build(); - } - - static SimpleNextHop mapSimpleNextHop( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SimpleNextHop hop) { - return new SimpleNextHopBuilder() - .setNextHop(hop.getNextHop()) - .setOutgoingInterface(hop.getOutgoingInterface()) - .build(); - } - - static NextHopList mapNextHopList( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList state) { - return new NextHopListBuilder() - .setNextHopList(mapNextHopListList(state.getNextHopList())) - .build(); - } - - static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.NextHopList mapNextHopListList( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.NextHopList state) { - return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.NextHopListBuilder() - .setNextHop(state.getNextHop() - .stream() - .map(nextHop -> new NextHopBuilder() - .setId(nextHop.getId()) - .setOutgoingInterface(nextHop.getOutgoingInterface()) - .setWeight(nextHop.getWeight()) - .setPriority(nextHop.getPriority()) - .setAddress(nextHop.getAddress()) - .setKey(new NextHopKey(nextHop.getKey().getId())) - .build()) - .collect(Collectors.toList())) - .build(); - } - - static SpecialNextHop mapSpecialNextHop( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SpecialNextHop hop) { - return new SpecialNextHopBuilder() - .setSpecialNextHop(hop.getSpecialNextHop()) - .build(); - } - - default InstanceIdentifier ipv4RouteIdentifier( - final InstanceIdentifier staticRoutesIdentifier) { - return staticRoutesIdentifier - .augmentation(StaticRoutes1.class) - .child(Ipv4.class) - .child(Route.class); - } - - default Set> ipv4RoutingHandledChildren(final InstanceIdentifier parent) { - return ImmutableSet.of( - parent.child(TableLookupParams.class), - parent.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.NextHopList.class), - parent.child( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.NextHopList.class) - .child(NextHop.class), - parent.child(VppIpv4Route.class)); - } - - default InstanceIdentifier ipv4RouteSubtree() { - return InstanceIdentifier.create(Route.class); - } - - default StaticRoutes1 mapIpv4Augmentation(final StaticRoutes2 state) { - if (state == null) { - return null; - } - return new StaticRoutes1Builder() - .setIpv4(mapIpv4(state.getIpv4())) - .build(); - } -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizer.java index 9d784e693..e30c38fae 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizer.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizer.java @@ -34,25 +34,23 @@ import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.vpp.jvpp.core.dto.IpAddDelRoute; import io.fd.vpp.jvpp.core.future.FutureJVppCore; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SimpleNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SpecialNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.TableLookup; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; - - +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SpecialNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.TableLookupCase; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nonnull; -import java.util.List; -import java.util.stream.Collectors; - /** * Customizer for handling write operations for {@link Ipv6} according to ietf-ipv6-unicast-routing.yang */ @@ -76,12 +74,12 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer */ private final Ipv6RouteNamesFactory namesFactory; - public Ipv6RouteCustomizer(@Nonnull final FutureJVppCore futureJVppCore, - @Nonnull final NamingContext interfaceContext, - @Nonnull final NamingContext routesContext, - @Nonnull final NamingContext routingProtocolContext, - @Nonnull final MultiNamingContext routesHopsContext, - @Nonnull final VppClassifierContextManager classifierContextManager) { + Ipv6RouteCustomizer(@Nonnull final FutureJVppCore futureJVppCore, + @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext routesContext, + @Nonnull final NamingContext routingProtocolContext, + @Nonnull final MultiNamingContext routesHopsContext, + @Nonnull final VppClassifierContextManager classifierContextManager) { super(futureJVppCore); this.routesContext = routesContext; @@ -90,9 +88,11 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer SimpleHopRequestFactory.forContexts(classifierContextManager, interfaceContext, routingProtocolContext); multipathHopRequestFactory = MultipathHopRequestFactory .forContexts(classifierContextManager, interfaceContext, routingProtocolContext); - specialNextHopRequestFactory = SpecialNextHopRequestFactory.forContexts(classifierContextManager, interfaceContext, - routingProtocolContext); - tableLookupRequestFactory = new TableLookupRequestFactory(classifierContextManager, interfaceContext, routingProtocolContext); + specialNextHopRequestFactory = + SpecialNextHopRequestFactory.forContexts(classifierContextManager, interfaceContext, + routingProtocolContext); + tableLookupRequestFactory = + new TableLookupRequestFactory(classifierContextManager, interfaceContext, routingProtocolContext); namesFactory = new Ipv6RouteNamesFactory(interfaceContext, routingProtocolContext); } @@ -100,7 +100,7 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer public void writeCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, @Nonnull final Route route, @Nonnull final WriteContext writeContext) throws WriteFailedException { - final String parentProtocolName = instanceIdentifier.firstKeyOf(RoutingProtocol.class).getName(); + final String parentProtocolName = instanceIdentifier.firstKeyOf(ControlPlaneProtocol.class).getName(); final String routeName = namesFactory.uniqueRouteName(parentProtocolName, route); writeRoute(instanceIdentifier, parentProtocolName, routeName, route, writeContext, true); @@ -112,7 +112,7 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, @Nonnull final Route route, @Nonnull final WriteContext writeContext) throws WriteFailedException { - final String parentProtocolName = instanceIdentifier.firstKeyOf(RoutingProtocol.class).getName(); + final String parentProtocolName = instanceIdentifier.firstKeyOf(ControlPlaneProtocol.class).getName(); final String routeName = namesFactory.uniqueRouteName(parentProtocolName, route); writeRoute(instanceIdentifier, parentProtocolName, routeName, route, writeContext, false); routesContext.removeName(routeName, writeContext.getMappingContext()); @@ -124,12 +124,12 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer @Nonnull final Route route, @Nonnull final WriteContext writeContext, final boolean isAdd) throws WriteFailedException { - if (route.getNextHopOptions() instanceof SimpleNextHop) { + if (route.getNextHop().getNextHopOptions() instanceof SimpleNextHop) { writeRoute( simpleHopRequestFactory.createIpv6SimpleHopRequest(isAdd, parentProtocolName, route, writeContext.getMappingContext()), identifier); - } else if (route.getNextHopOptions() instanceof NextHopList) { + } else if (route.getNextHop().getNextHopOptions() instanceof NextHopList) { final List createdHops = writeMultihopRoute(identifier, parentProtocolName, route, writeContext, isAdd); @@ -139,10 +139,12 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer } else { removeMappingForEachHop(routeName, writeContext, createdHops); } - } else if (route.getNextHopOptions() instanceof SpecialNextHop) { + } else if (route.getNextHop().getNextHopOptions() instanceof SpecialNextHop) { writeSpecialHopRoute(identifier, route, parentProtocolName, writeContext, isAdd); - } else if (route.getNextHopOptions() instanceof TableLookup) { - writeRoute(tableLookupRequestFactory.createV6TableLookupRouteRequest(isAdd, parentProtocolName, route, writeContext.getMappingContext()), identifier); + } else if (route.getNextHop().getNextHopOptions() instanceof TableLookupCase) { + writeRoute(tableLookupRequestFactory.createV6TableLookupRouteRequest(isAdd, parentProtocolName, route, + writeContext.getMappingContext()), + identifier); } else { throw new IllegalArgumentException("Unsupported next-hop type"); } @@ -154,14 +156,13 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer final WriteContext writeContext, final boolean isAdd) throws WriteFailedException { // list of next hops - final NextHopList hopList = NextHopList.class.cast(route.getNextHopOptions()); + final NextHopList hopList = NextHopList.class.cast(route.getNextHop().getNextHopOptions()); final MappingContext mappingContext = writeContext.getMappingContext(); LOG.debug("Writing hop list {} for route {}", hopList, identifier); // order hops to preserve order by ids(even that model is not ordered) - final List orderedHops = hopList.getNextHopList().getNextHop() - .stream() - .sorted((left, right) -> (int) (left.getId() - right.getId())) + final List orderedHops = hopList.getNextHopList().getNextHop().stream() + .sorted(Comparator.comparing(NextHop::getIndex)) .collect(Collectors.toList()); for (NextHop hop : orderedHops) { @@ -176,16 +177,16 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer return orderedHops; } - private void writeSpecialHopRoute(final @Nonnull InstanceIdentifier identifier, final @Nonnull Route route, - final @Nonnull String parentProtocolName, final @Nonnull WriteContext writeContext, - final boolean isAdd) + final @Nonnull String parentProtocolName, + final @Nonnull WriteContext writeContext, final boolean isAdd) throws WriteFailedException { - final SpecialNextHop hop = SpecialNextHop.class.cast(route.getNextHopOptions()); + final SpecialNextHop hop = SpecialNextHop.class.cast(route.getNextHop().getNextHopOptions()); final MappingContext mappingContext = writeContext.getMappingContext(); - final IpAddDelRoute request = specialNextHopRequestFactory - .createIpv6SpecialHopRequest(isAdd, parentProtocolName, route, mappingContext, hop.getSpecialNextHop()); + final IpAddDelRoute request = + specialNextHopRequestFactory.createIpv6SpecialHopRequest(isAdd, parentProtocolName, route, mappingContext, + hop.getSpecialNextHopEnum()); writeRoute(request, identifier); } @@ -206,7 +207,7 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer private void addMappingForEachHop(final @Nonnull String routeName, final @Nonnull WriteContext writeContext, final List createdHops) { createdHops.forEach(nextHop -> routesHopsContext.addChild(routeName, - nextHop.getId().intValue(), + Integer.valueOf(nextHop.getIndex()), namesFactory.uniqueRouteHopName(nextHop), writeContext.getMappingContext())); } diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6WriteRoutingNodes.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6WriteRoutingNodes.java deleted file mode 100644 index 14c70496b..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6WriteRoutingNodes.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.write; - -import com.google.common.collect.ImmutableSet; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes2; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.NextHopOptions; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.VppIpv6Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.VppIpv6RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.*; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.table.lookup.TableLookupParams; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.table.lookup.TableLookupParamsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - - -public interface Ipv6WriteRoutingNodes { - - Ipv6WriteRoutingNodes INSTANCE = new Ipv6WriteRoutingNodes() { - }; - - Class CONFIG_IPV6_AUG_CLASS = StaticRoutes1.class; - Class STATE_IPV6_AUG_CLASS = StaticRoutes2.class; - - static Ipv6 mapIpv6( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6 state) { - return new Ipv6Builder() - .setRoute(state.getRoute() - .stream() - .map(route -> new RouteBuilder() - .setKey(new RouteKey(route.getKey().getId())) - .setDestinationPrefix(route.getDestinationPrefix()) - .setDescription(route.getDescription()) - .setId(route.getId()) - .setVppIpv6Route(mapVppIpv6Route(route.getVppIpv6RouteState())) - .setNextHopOptions(mapNextHopOptions(route.getNextHopOptions())) - .build()) - .collect(Collectors.toList())) - .build(); - } - - static VppIpv6Route mapVppIpv6Route( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.VppIpv6RouteState state) { - return state == null - ? null - : new VppIpv6RouteBuilder() - .setClassifyTable(state.getClassifyTable()) - .build(); - } - - static NextHopOptions mapNextHopOptions( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.NextHopOptions state) { - if (state instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SimpleNextHop) { - return mapSimpleNextHop( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SimpleNextHop.class - .cast(state)); - } else if (state instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList) { - return mapNextHopList( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList.class - .cast(state)); - } else if (state instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SpecialNextHop) { - return mapSpecialNextHop( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SpecialNextHop.class - .cast(state)); - } else if (state instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.TableLookup) { - return mapTableLookup(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.TableLookup.class.cast(state)); - } else - throw new UnsupportedOperationException("Unsupported next hop type"); - } - - static TableLookup mapTableLookup(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.TableLookup state) { - return new TableLookupBuilder() - .setTableLookupParams(Optional.ofNullable(state.getTableLookupParams()) - .map(params -> new TableLookupParamsBuilder() - .setSecondaryVrf(params.getSecondaryVrf()) - .build()) - .orElse(null)) - .build(); - } - - static SimpleNextHop mapSimpleNextHop( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SimpleNextHop hop) { - return new SimpleNextHopBuilder() - .setNextHop(hop.getNextHop()) - .setOutgoingInterface(hop.getOutgoingInterface()) - .build(); - } - - static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList mapNextHopList( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList state) { - return new NextHopListBuilder() - .setNextHopList(mapNextHopListList(state.getNextHopList())) - .build(); - } - - static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.NextHopList mapNextHopListList( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.NextHopList state) { - return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.NextHopListBuilder() - .setNextHop(state.getNextHop() - .stream() - .map(nextHop -> new NextHopBuilder() - .setId(nextHop.getId()) - .setOutgoingInterface(nextHop.getOutgoingInterface()) - .setWeight(nextHop.getWeight()) - .setPriority(nextHop.getPriority()) - .setAddress(nextHop.getAddress()) - .setKey(new NextHopKey(nextHop.getKey().getId())) - .build()) - .collect(Collectors.toList())) - .build(); - } - - static SpecialNextHop mapSpecialNextHop( - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SpecialNextHop hop) { - return new SpecialNextHopBuilder() - .setSpecialNextHop(hop.getSpecialNextHop()) - .build(); - } - - default InstanceIdentifier ipv6RouteIdentifier( - final InstanceIdentifier staticRoutesIdentifier) { - return staticRoutesIdentifier - .augmentation(StaticRoutes1.class) - .child(Ipv6.class) - .child(Route.class); - } - - default InstanceIdentifier ipv6RouteSubtree() { - return InstanceIdentifier - .create(Route.class); - } - - default Set> ipv6RoutingHandledChildren( - final InstanceIdentifier parent) { - return ImmutableSet.of( - parent.child(TableLookupParams.class), - parent.child(NextHopList.class), - parent.child(NextHopList.class).child(NextHop.class), - parent.child(VppIpv6Route.class)); - } - - default org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1 mapIpv6Augmentation( - final StaticRoutes2 state) { - if (state == null) { - return null; - } - return new StaticRoutes1Builder() - .setIpv6(mapIpv6(state.getIpv6())) - .build(); - } -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/PrefixCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/PrefixCustomizer.java index 8ab73760b..ee34ee9fa 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/PrefixCustomizer.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/PrefixCustomizer.java @@ -30,13 +30,13 @@ import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaPrefix; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.prefix.list.Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.prefix.list.PrefixKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.prefix.list.prefix.ControlAdvPrefixes; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.prefix.list.prefix.control.adv.prefixes.Advertise; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.prefix.list.prefix.control.adv.prefixes.NoAdvertise; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev170502.ControlAdvPrefixesVppAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.prefix.list.Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.prefix.list.PrefixKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.prefix.list.prefix.ControlAdvPrefixes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.prefix.list.prefix.control.adv.prefixes.Advertise; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.prefix.list.prefix.control.adv.prefixes.NoAdvertise; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev180319.ControlAdvPrefixesVppAugmentation; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizer.java index b8c60ba51..3d43afbd4 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizer.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizer.java @@ -27,9 +27,9 @@ import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaConfig; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.Ipv6RouterAdvertisements; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev170502.Ipv6RouterAdvertisementsVppAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.Ipv6RouterAdvertisements; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev180319.Ipv6RouterAdvertisementsVppAugmentation; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingCustomizer.java index 0e99aeead..3a8d05c67 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingCustomizer.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingCustomizer.java @@ -20,7 +20,7 @@ import io.fd.honeycomb.translate.spi.write.WriterCustomizer; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Routing; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory; /** * Dummy customizer for Root node,to "handle" non-operational changes */ -public class RoutingCustomizer implements WriterCustomizer { +final class RoutingCustomizer implements WriterCustomizer { private static final Logger LOG = LoggerFactory.getLogger(RoutingCustomizer.class); @@ -37,6 +37,7 @@ public class RoutingCustomizer implements WriterCustomizer { @Nonnull final Routing routing, @Nonnull final WriteContext writeContext) throws WriteFailedException { LOG.debug("Writing {}", instanceIdentifier); + checkSingletonInstance(routing); } @Override @@ -44,5 +45,12 @@ public class RoutingCustomizer implements WriterCustomizer { @Nonnull final Routing routing, @Nonnull final WriteContext writeContext) throws WriteFailedException { LOG.debug("Removing {}", instanceIdentifier); + checkSingletonInstance(routing); + } + + private void checkSingletonInstance(final Routing data) { + if (data.getRouterId() != null) { + throw new UnsupportedOperationException("Setting RouterId is not supported."); + } } } diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizer.java deleted file mode 100644 index 7d63647e0..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizer.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.write; - -import static com.google.common.base.Preconditions.checkArgument; - -import io.fd.hc2vpp.routing.RoutingConfiguration; -import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer; -import io.fd.honeycomb.translate.write.WriteContext; -import io.fd.honeycomb.translate.write.WriteFailedException; -import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Only ensures that requests are written under singleton instance - */ -public class RoutingInstanceCustomizer implements ListWriterCustomizer { - - private final RoutingConfiguration configuration; - - public RoutingInstanceCustomizer(@Nonnull final RoutingConfiguration configuration) { - this.configuration = configuration; - } - - @Override - public void writeCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final RoutingInstance dataAfter, - @Nonnull final WriteContext writeContext) - throws WriteFailedException { - checkSingletonInstance(dataAfter); - } - - @Override - public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final RoutingInstance dataBefore, - @Nonnull final WriteContext writeContext) - throws WriteFailedException { - checkSingletonInstance(dataBefore); - } - - private void checkSingletonInstance(final RoutingInstance data) { - final String defaultRoutingInstanceName = configuration.getDefaultRoutingInstanceName(); - final String instanceName = data.getName(); - - checkArgument(defaultRoutingInstanceName.equals(instanceName), - "Attempt to write/delete data for different than default routing instance detected." + - "Vpp allows only single instance, configured with name %s, request contains name %s", - defaultRoutingInstanceName, instanceName); - } -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizer.java deleted file mode 100644 index e898c718c..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizer.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2017 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.write; - -import static com.google.common.base.Preconditions.checkArgument; - -import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer; -import io.fd.honeycomb.translate.write.WriteContext; -import io.fd.honeycomb.translate.write.WriteFailedException; -import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.InterfaceKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Dummy customizer for Interfaces node responsible for validation only. - */ -final class RoutingInterfaceCustomizer implements ListWriterCustomizer { - - private static final Logger LOG = LoggerFactory.getLogger(RoutingInterfaceCustomizer.class); - - @Override - public void writeCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final Interface after, @Nonnull final WriteContext writeContext) - throws WriteFailedException { - LOG.debug("Writing {} after={}", id, after); - checkIfcIsConfigured(after.getName(), writeContext); - } - - @Override - public void updateCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final Interface before, @Nonnull final Interface after, - @Nonnull final WriteContext writeContext) throws WriteFailedException { - LOG.debug("Updating {} before={} after={}", id, before, after); - checkIfcIsConfigured(after.getName(), writeContext); - } - - @Override - public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final Interface after, @Nonnull final WriteContext writeContext) - throws WriteFailedException { - LOG.debug("Removing {}", id); - // here we do not care if the ifc exists or not, because we are removing reference to it - } - - private static void checkIfcIsConfigured(@Nonnull final String ifcName, @Nonnull final WriteContext writeContext) { - final KeyedInstanceIdentifier - id = InstanceIdentifier.create(Interfaces.class) - .child( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface.class, - new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey( - ifcName)); - checkArgument(writeContext.readAfter(id).isPresent(), "Interface %s is not configured", ifcName); - } -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizer.java deleted file mode 100644 index 1db6338eb..000000000 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizer.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.write; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkState; - -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.honeycomb.translate.MappingContext; -import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer; -import io.fd.honeycomb.translate.write.WriteContext; -import io.fd.honeycomb.translate.write.WriteFailedException; -import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Static; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolVppAttr; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Customizer for handling of write operations for {@link RoutingProtocol} - */ -public class RoutingProtocolCustomizer - implements ListWriterCustomizer { - - private final NamingContext routingProtocolContext; - - public RoutingProtocolCustomizer(@Nonnull final NamingContext routingProtocolContext) { - this.routingProtocolContext = routingProtocolContext; - } - - @Override - public void writeCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, - @Nonnull final RoutingProtocol routingProtocol, - @Nonnull final WriteContext writeContext) - throws WriteFailedException { - checkIsStatic(routingProtocol); - - final int tableId = extractTableId(routingProtocol); - final MappingContext mappingContext = writeContext.getMappingContext(); - final String newProtocolName = routingProtocol.getName(); - - // enclosed in synchronized block to prevent change of state after containsName/before addName - synchronized (routingProtocolContext) { - if (!routingProtocolContext.containsName(tableId, mappingContext)) { - // if not present in mapping,create assignment to table id. This works only with auto-create flag enabled - // while using ip_add_del_table - routingProtocolContext.addName(tableId, newProtocolName, mappingContext); - } else { - // prevent to fail while restoring data(trying to remap already mapped name) - if (!newProtocolName.equals(routingProtocolContext.getName(tableId, mappingContext))) { - throw new IllegalStateException(String.format( - "An attempt to assign protocol %s to table id %s. Table id already assigned to protocol %s", - newProtocolName, tableId, routingProtocolContext.getName(tableId, mappingContext))); - } - } - } - } - - @Override - public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier instanceIdentifier, - @Nonnull final RoutingProtocol routingProtocol, - @Nonnull final WriteContext writeContext) - throws WriteFailedException { - routingProtocolContext.removeName(routingProtocol.getName(), writeContext.getMappingContext()); - } - - /** - * Checks whether routing protocol is static(we support only static ones for now) - */ - private void checkIsStatic(final RoutingProtocol routingProtocol) { - checkArgument(routingProtocol.getType() == Static.class, "Only static routes are allowed"); - } - - private int extractTableId(final RoutingProtocol protocol) { - final RoutingProtocolVppAttr vppAttr = protocol.getAugmentation(RoutingProtocolVppAttr.class); - - checkState(vppAttr != null && vppAttr.getVppProtocolAttributes() != null, - "Vpp routing protocol attributes not defined"); - - return vppAttr.getVppProtocolAttributes().getPrimaryVrf().getValue().intValue(); - } -} diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingWriterFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingWriterFactory.java index b3306d9a2..05d6916cb 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingWriterFactory.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingWriterFactory.java @@ -25,7 +25,10 @@ import com.google.inject.Inject; import com.google.inject.name.Named; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.routing.Ipv4RoutingNodes; +import io.fd.hc2vpp.routing.Ipv6RoutingNodes; import io.fd.hc2vpp.routing.RoutingConfiguration; +import io.fd.hc2vpp.routing.RoutingIIds; import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.impl.write.GenericWriter; import io.fd.honeycomb.translate.write.WriterFactory; @@ -33,37 +36,21 @@ import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.Set; import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.Interface1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.Ipv6RouterAdvertisements; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.PrefixList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.prefix.list.Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.Interfaces; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev170502.ControlAdvPrefixesVppAugmentation; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev170502.Ipv6RouterAdvertisementsVppAugmentation; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolVppAttr; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol.VppProtocolAttributes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.Ipv6RouterAdvertisements; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.prefix.list.Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Routing; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev180319.ControlAdvPrefixesVppAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev180319.Ipv6RouterAdvertisementsVppAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.RoutingProtocolVppAttr; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.routing.control.plane.protocols.control.plane.protocol.VppProtocolAttributes; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** * Factory producing writers for routing plugin's data. */ -public final class RoutingWriterFactory implements WriterFactory, Ipv4WriteRoutingNodes, Ipv6WriteRoutingNodes { - - private static final InstanceIdentifier ROOT_CONTAINER_ID = InstanceIdentifier.create(Routing.class); - private static final InstanceIdentifier ROUTING_INTERFACE_ID = - ROOT_CONTAINER_ID.child(RoutingInstance.class).child(Interfaces.class).child(Interface.class); - private static final InstanceIdentifier ROUTING_ADVERTISMENT_ID = - ROUTING_INTERFACE_ID.augmentation( - Interface1.class).child(Ipv6RouterAdvertisements.class); - private static final InstanceIdentifier PREFIX_ID = - ROUTING_ADVERTISMENT_ID.child(PrefixList.class).child(Prefix.class); +public final class RoutingWriterFactory implements WriterFactory, Ipv4RoutingNodes, Ipv6RoutingNodes { private static final InstanceIdentifier IFACE_ID = InstanceIdentifier.create(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces.class) @@ -98,54 +85,45 @@ public final class RoutingWriterFactory implements WriterFactory, Ipv4WriteRouti @Override public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) { - registry.subtreeAdd(rootNodeHandledChildren(ROOT_CONTAINER_ID), - new GenericWriter<>(ROOT_CONTAINER_ID, new RoutingCustomizer())); - - registry.add(new GenericWriter<>(routingInstanceIdentifier(), new RoutingInstanceCustomizer(configuration))); - - registry.subtreeAdd(routingProtocolHandledChildren(),new GenericWriter<>(routingProtocolIdentifier(), - new RoutingProtocolCustomizer(routingProtocolContext))); - - final InstanceIdentifier staticRoutesInstanceIdentifier = staticRoutesIdentifier(); - final InstanceIdentifier ipv4RouteIdentifier = ipv4RouteIdentifier(staticRoutesInstanceIdentifier); - final InstanceIdentifier - ipv6RouteIdentifier = ipv6RouteIdentifier(staticRoutesInstanceIdentifier); - registry.subtreeAddAfter(ipv4RoutingHandledChildren(ipv4RouteSubtree()), new GenericWriter<>(ipv4RouteIdentifier, - new Ipv4RouteCustomizer(vppApi, interfaceContext, routeContext, routingProtocolContext, routHopContext, - vppClassifierContextManager)), IFACE_ID); - registry.subtreeAddAfter(ipv6RoutingHandledChildren(ipv6RouteSubtree()), new GenericWriter<>(ipv6RouteIdentifier, - new Ipv6RouteCustomizer(vppApi, interfaceContext, routeContext, routingProtocolContext, routHopContext, - vppClassifierContextManager)), IFACE_ID); - registry.add(new GenericWriter<>(ROUTING_INTERFACE_ID, new RoutingInterfaceCustomizer())); - registry.subtreeAdd(raHandledChildren(), - new GenericWriter<>(ROUTING_ADVERTISMENT_ID, new RouterAdvertisementsCustomizer(vppApi, interfaceContext))); - registry.subtreeAdd(prefixHandledChildren(), - new GenericWriter<>(PREFIX_ID, new PrefixCustomizer(vppApi, interfaceContext))); + registry.subtreeAdd(rootNodeHandledChildren(RoutingIIds.ROUTING), + new GenericWriter<>(RoutingIIds.ROUTING, new RoutingCustomizer())); - } + registry.subtreeAdd(routingProtocolHandledChildren(),new GenericWriter<>(RoutingIIds.RT_CPS_CP, + new ControlPlaneProtocolCustomizer(routingProtocolContext))); - private static ImmutableSet> routingProtocolHandledChildren() { - return ImmutableSet - .of(InstanceIdentifier.create(RoutingProtocol.class).augmentation(RoutingProtocolVppAttr.class).child(VppProtocolAttributes.class)); - } + registry.subtreeAddAfter(ipv4RoutingHandledChildren(RoutingIIds.RT_CPS_CP_SR_SRV4_IPV4_RT_PARENT), + new GenericWriter<>(RoutingIIds.RT_CPS_CP_SR_SRV4_IPV4_RT, + new Ipv4RouteCustomizer(vppApi, interfaceContext, routeContext, + routingProtocolContext, routHopContext, + vppClassifierContextManager)), IFACE_ID); + registry.subtreeAddAfter(ipv6RoutingHandledChildren(RoutingIIds.RT_CPS_CP_SR_SRV6_IPV6_RT_PARENT), + new GenericWriter<>(RoutingIIds.RT_CPS_CP_SR_SRV6_IPV6_RT, + new Ipv6RouteCustomizer(vppApi, interfaceContext, routeContext, + routingProtocolContext, routHopContext, + vppClassifierContextManager)), IFACE_ID); - private static InstanceIdentifier routingInstanceIdentifier() { - return ROOT_CONTAINER_ID.child(RoutingInstance.class); - } - private static InstanceIdentifier routingProtocolIdentifier() { - return routingInstanceIdentifier().child(RoutingProtocols.class).child(RoutingProtocol.class); + //router advertisements + registry.subtreeAdd(raHandledChildren(), + new GenericWriter<>(RoutingIIds.IFCS_IFC_IFC1_IPV6_IPV61_RTADV, + new RouterAdvertisementsCustomizer(vppApi, interfaceContext))); + registry.subtreeAdd(prefixHandledChildren(), + new GenericWriter<>(RoutingIIds.IFCS_IFC_IFC1_IPV6_IPV61_RTADV_PRLST_PRFX, + new PrefixCustomizer(vppApi, interfaceContext))); } - private static InstanceIdentifier staticRoutesIdentifier() { - return routingProtocolIdentifier().child(StaticRoutes.class); + private static ImmutableSet> routingProtocolHandledChildren() { + return ImmutableSet.of(InstanceIdentifier.create(ControlPlaneProtocol.class) + .augmentation(RoutingProtocolVppAttr.class) + .child(VppProtocolAttributes.class)); } private static Set> rootNodeHandledChildren(final InstanceIdentifier parent) { - return ImmutableSet.of(parent.child(RoutingInstance.class).child(RoutingProtocols.class)); + return ImmutableSet.of(parent.child(ControlPlaneProtocols.class)); } private static Set> raHandledChildren() { - final InstanceIdentifier raIID = InstanceIdentifier.create(Ipv6RouterAdvertisements.class); + final InstanceIdentifier raIID = + InstanceIdentifier.create(Ipv6RouterAdvertisements.class); return ImmutableSet.of(raIID.augmentation(Ipv6RouterAdvertisementsVppAugmentation.class)); } diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactory.java index bad51478d..62e4f4525 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactory.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactory.java @@ -22,16 +22,20 @@ import io.fd.hc2vpp.routing.write.trait.RouteRequestProducer; import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.MappingContext; import io.fd.vpp.jvpp.core.dto.IpAddDelRoute; +import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; 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.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.VppIpv4Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.VppIpv6Route; - -import javax.annotation.Nonnull; - +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4RouteAttributesAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.VppIpv4Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6RouteAttributesAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.VppIpv6Route; /** * Factory for creating requests to create route with multiple hops @@ -53,10 +57,12 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement public IpAddDelRoute createIpv4MultipathHopRequest(final boolean add, @Nonnull final String parentProtocolName, - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route route, + @Nonnull final Route route, @Nonnull final NextHop hop, @Nonnull final MappingContext mappingContext) { - final VppIpv4Route routingAttributes = route.getVppIpv4Route(); + + final VppIpv4Route routingAttributes = route.getAugmentation(VppIpv4RouteAttributesAugmentation.class) != null ? + route.getAugmentation(VppIpv4RouteAttributesAugmentation.class).getVppIpv4Route() : null; final int nextHopInterfaceIndex = getInterfaceNamingContext().getIndex(hop.getOutgoingInterface(), mappingContext); @@ -66,8 +72,8 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement return getMultipathHopRequest(add, route.getDestinationPrefix(), nextHopInterfaceIndex, - hop.getAddress(), - hop.getWeight().byteValue(), + hop.getAugmentation(NextHop1.class).getNextHopAddress(), + hop.getAugmentation(VppIpv4NextHopAugmentation.class).getWeight().byteValue(), getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext), DEFAULT_VNI, classifyTableIndex(routingAttributes.getClassifyTable(), getVppClassifierContextManager(), @@ -77,8 +83,8 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement return getMultipathHopRequest(add, route.getDestinationPrefix(), nextHopInterfaceIndex, - hop.getAddress(), - hop.getWeight().byteValue(), + hop.getAugmentation(NextHop1.class).getNextHopAddress(), + hop.getAugmentation(VppIpv4NextHopAugmentation.class).getWeight().byteValue(), getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext), DEFAULT_VNI, 0, @@ -88,10 +94,11 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement public IpAddDelRoute createIpv6MultipathHopRequest(final boolean add, @Nonnull final String parentProtocolName, - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route route, - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop hop, + @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route route, + @Nonnull final NextHop hop, @Nonnull final MappingContext mappingContext) { - final VppIpv6Route routingAttributes = route.getVppIpv6Route(); + final VppIpv6Route routingAttributes = route.getAugmentation(VppIpv6RouteAttributesAugmentation.class) != null ? + route.getAugmentation(VppIpv6RouteAttributesAugmentation.class).getVppIpv6Route() : null; final int nextHopInterfaceIndex = getInterfaceNamingContext().getIndex(hop.getOutgoingInterface(), mappingContext); @@ -101,8 +108,8 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement return getMultipathHopRequest(add, route.getDestinationPrefix(), nextHopInterfaceIndex, - hop.getAddress(), - hop.getWeight().byteValue(), + hop.getAugmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1.class).getNextHopAddress(), + hop.getAugmentation(VppIpv6NextHopAugmentation.class).getWeight().byteValue(), getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext), DEFAULT_VNI, classifyTableIndex(routingAttributes.getClassifyTable(), getVppClassifierContextManager(), @@ -112,8 +119,8 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement return getMultipathHopRequest(add, route.getDestinationPrefix(), nextHopInterfaceIndex, - hop.getAddress(), - hop.getWeight().byteValue(), + hop.getAugmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1.class).getNextHopAddress(), + hop.getAugmentation(VppIpv6NextHopAugmentation.class).getWeight().byteValue(), getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext), DEFAULT_VNI, 0, diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactory.java index 6e404923f..079c953a3 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactory.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactory.java @@ -22,17 +22,18 @@ import io.fd.hc2vpp.routing.write.trait.RouteRequestProducer; import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.MappingContext; import io.fd.vpp.jvpp.core.dto.IpAddDelRoute; - import javax.annotation.Nonnull; - import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; 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.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.VppIpv4Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SimpleNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.VppIpv6Route; - +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.SimpleNextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4RouteAttributesAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.VppIpv4Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6RouteAttributesAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.VppIpv6Route; /** * Factory for creating requests to create route with hop simple hop @@ -54,31 +55,35 @@ public class SimpleHopRequestFactory extends BasicHopRequestFactory implements R public IpAddDelRoute createIpv4SimpleHopRequest(final boolean add, @Nonnull final String parentProtocolName, - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route route, + @Nonnull final Route route, @Nonnull final MappingContext mappingContext) { + SimpleNextHop simpleNextHop = (SimpleNextHop) route.getNextHop().getNextHopOptions(); + SimpleNextHop1 hop = simpleNextHop.getAugmentation(SimpleNextHop1.class); - final SimpleNextHop hop = SimpleNextHop.class.cast(route.getNextHopOptions()); - final VppIpv4Route routingAttributes = route.getVppIpv4Route(); final int nextHopInterfaceIndex = - getInterfaceNamingContext().getIndex(hop.getOutgoingInterface(), mappingContext); + getInterfaceNamingContext().getIndex(simpleNextHop.getOutgoingInterface(), mappingContext); + + final VppIpv4Route routingAttributes = + route.getAugmentation(VppIpv4RouteAttributesAugmentation.class) != null ? + route.getAugmentation(VppIpv4RouteAttributesAugmentation.class).getVppIpv4Route() : null; if (routingAttributes != null && classifyTablePresent(routingAttributes.getClassifyTable(), getVppClassifierContextManager(), mappingContext)) { return getSimpleHopRequest(add, - route.getDestinationPrefix(), - nextHopInterfaceIndex, - hop.getNextHop(), - getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext), - DEFAULT_VNI, - classifyTableIndex(routingAttributes.getClassifyTable(), getVppClassifierContextManager(), - mappingContext), - true); + route.getDestinationPrefix(), + nextHopInterfaceIndex, + hop.getNextHopAddress(), + getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext), + DEFAULT_VNI, + classifyTableIndex(routingAttributes.getClassifyTable(), + getVppClassifierContextManager(), mappingContext), + true); } else { return getSimpleHopRequest(add, route.getDestinationPrefix(), nextHopInterfaceIndex, - hop.getNextHop(), + hop.getNextHopAddress(), getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext), DEFAULT_VNI, 0, @@ -88,15 +93,17 @@ public class SimpleHopRequestFactory extends BasicHopRequestFactory implements R public IpAddDelRoute createIpv6SimpleHopRequest(final boolean add, @Nonnull final String parentProtocolName, - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route route, + @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route route, @Nonnull final MappingContext mappingContext) { - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SimpleNextHop - hop = - (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SimpleNextHop) route - .getNextHopOptions(); - final VppIpv6Route routingAttributes = route.getVppIpv6Route(); + SimpleNextHop simpleNextHop = (SimpleNextHop) route.getNextHop().getNextHopOptions(); + final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.SimpleNextHop1 + hop = simpleNextHop.getAugmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.SimpleNextHop1.class); final int nextHopInterfaceIndex = - getInterfaceNamingContext().getIndex(hop.getOutgoingInterface(), mappingContext); + getInterfaceNamingContext().getIndex(simpleNextHop.getOutgoingInterface(), mappingContext); + + VppIpv6Route routingAttributes = + route.getAugmentation(VppIpv6RouteAttributesAugmentation.class) != null ? route.getAugmentation( + VppIpv6RouteAttributesAugmentation.class).getVppIpv6Route() : null; if (routingAttributes != null && classifyTablePresent(routingAttributes.getClassifyTable(), getVppClassifierContextManager(), @@ -104,7 +111,7 @@ public class SimpleHopRequestFactory extends BasicHopRequestFactory implements R return getSimpleHopRequest(add, route.getDestinationPrefix(), nextHopInterfaceIndex, - hop.getNextHop(), + hop.getNextHopAddress(), getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext), DEFAULT_VNI, classifyTableIndex(routingAttributes.getClassifyTable(), getVppClassifierContextManager(), @@ -114,7 +121,7 @@ public class SimpleHopRequestFactory extends BasicHopRequestFactory implements R return getSimpleHopRequest(add, route.getDestinationPrefix(), nextHopInterfaceIndex, - hop.getNextHop(), + hop.getNextHopAddress(), getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext), DEFAULT_VNI, 0, diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactory.java index 10e0fc555..85b998204 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactory.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactory.java @@ -16,19 +16,19 @@ package io.fd.hc2vpp.routing.write.factory; +import static com.google.common.base.Preconditions.checkNotNull; + import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.write.factory.base.BasicHopRequestFactory; import io.fd.hc2vpp.routing.write.trait.RouteRequestProducer; import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.MappingContext; import io.fd.vpp.jvpp.core.dto.IpAddDelRoute; +import javax.annotation.Nonnull; 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; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping; - -import javax.annotation.Nonnull; - -import static com.google.common.base.Preconditions.checkNotNull; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop; public class SpecialNextHopRequestFactory extends BasicHopRequestFactory implements RouteRequestProducer { @@ -48,9 +48,9 @@ public class SpecialNextHopRequestFactory extends BasicHopRequestFactory public IpAddDelRoute createIpv4SpecialHopRequest(final boolean add, @Nonnull final String parentProtocolName, - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route route, + @Nonnull final Route route, @Nonnull final MappingContext mappingContext, - @Nonnull final SpecialNextHopGrouping.SpecialNextHop flagsVariant) { + @Nonnull final SpecialNextHop.SpecialNextHopEnum flagsVariant) { checkNotNull(route, "Route cannot be null"); checkNotNull(mappingContext, "Mapping Context cannot be null"); checkNotNull(flagsVariant, "Flags variant cannot be null"); @@ -61,9 +61,9 @@ public class SpecialNextHopRequestFactory extends BasicHopRequestFactory public IpAddDelRoute createIpv6SpecialHopRequest(final boolean add, @Nonnull final String parentProtocolName, - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route route, + @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route route, @Nonnull final MappingContext mappingContext, - @Nonnull final SpecialNextHopGrouping.SpecialNextHop flagsVariant) { + @Nonnull final SpecialNextHop.SpecialNextHopEnum flagsVariant) { checkNotNull(route, "Route cannot be null"); checkNotNull(mappingContext, "Mapping Context cannot be null"); @@ -89,7 +89,7 @@ public class SpecialNextHopRequestFactory extends BasicHopRequestFactory } private IpAddDelRoute resolveFlags(IpAddDelRoute request, - final SpecialNextHopGrouping.SpecialNextHop flagsVariant) { + final SpecialNextHop.SpecialNextHopEnum flagsVariant) { switch (flagsVariant) { case Blackhole: return resolveAsBlackholeVariant(request); diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/TableLookupRequestFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/TableLookupRequestFactory.java index 231ffcaf4..8a11adc8f 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/TableLookupRequestFactory.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/TableLookupRequestFactory.java @@ -22,16 +22,19 @@ import io.fd.hc2vpp.routing.write.trait.RouteRequestProducer; import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.MappingContext; import io.fd.vpp.jvpp.core.dto.IpAddDelRoute; +import java.util.Optional; +import javax.annotation.Nonnull; 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; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.TableLookup; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.table.lookup.TableLookupParams; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VppRouteAttributes; - - -import javax.annotation.Nonnull; -import java.util.Optional; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.NextHopOptions; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.TableLookupCase; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4RouteAttributesAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.VppIpv4Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6RouteAttributesAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.VppIpv6Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.VppRouteAttributes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; public class TableLookupRequestFactory extends BasicHopRequestFactory implements RouteRequestProducer { @@ -46,23 +49,26 @@ public class TableLookupRequestFactory extends BasicHopRequestFactory implements public IpAddDelRoute createV4TableLookupRouteRequest(final boolean add, @Nonnull final String parentProtocolName, - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route route, + @Nonnull final Route route, @Nonnull final MappingContext mappingContext) { final Ipv4Prefix prefix = route.getDestinationPrefix(); final byte[] destinationAddress = ipv4AddressPrefixToArray(prefix); final byte destinationPrefix = extractPrefix(prefix); final int primaryTableId = getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext); - final byte secondaryTableId = Optional.ofNullable(route.getNextHopOptions()) - .filter(nextHopOptions -> nextHopOptions instanceof TableLookup) - .map(TableLookup.class::cast) - .map(TableLookup::getTableLookupParams) - .map(TableLookupParams::getSecondaryVrf) + final byte secondaryTableId = Optional.ofNullable(route.getNextHop().getNextHopOptions()) + .filter(nextHopOptions -> nextHopOptions instanceof TableLookupCase) + .map(TableLookupCase.class::cast) + .map(TableLookupCase::getSecondaryVrf) .map(VniReference::getValue) .map(Long::byteValue) .orElseThrow(() -> new IllegalArgumentException("Table lookup option not specified correctly")); - final Optional optClassifyTable = Optional.ofNullable(route.getVppIpv4Route()) + VppIpv4Route vppIpv4Route = + route.getAugmentation(VppIpv4RouteAttributesAugmentation.class) != null ? route.getAugmentation( + VppIpv4RouteAttributesAugmentation.class).getVppIpv4Route() : null; + + final Optional optClassifyTable = Optional.ofNullable(vppIpv4Route) .map(VppRouteAttributes::getClassifyTable); final byte classifyTableSet = booleanToByte(optClassifyTable.isPresent()); final byte classifyTableIndex = optClassifyTable.map(tableName -> classifyTableIndex(tableName, getVppClassifierContextManager(), mappingContext)) @@ -75,23 +81,25 @@ public class TableLookupRequestFactory extends BasicHopRequestFactory implements public IpAddDelRoute createV6TableLookupRouteRequest(final boolean add, @Nonnull final String parentProtocolName, - @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route route, + @Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route route, @Nonnull final MappingContext mappingContext) { final Ipv6Prefix prefix = route.getDestinationPrefix(); final byte[] destinationAddress = ipv6AddressPrefixToArray(prefix); final byte destinationPrefix = extractPrefix(prefix); final int primaryTableId = getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext); - final byte secondaryTableId = Optional.ofNullable(route.getNextHopOptions()) - .filter(nextHopOptions -> nextHopOptions instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.TableLookup) - .map(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.TableLookup.class::cast) - .map(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.TableLookup::getTableLookupParams) - .map(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.table.lookup.TableLookupParams::getSecondaryVrf) + final byte secondaryTableId = Optional.ofNullable(route.getNextHop().getNextHopOptions()) + .filter(nextHopOptions -> nextHopOptions instanceof TableLookupCase) + .map(TableLookupCase.class::cast) + .map(TableLookupCase::getSecondaryVrf) .map(VniReference::getValue) .map(Long::byteValue) .orElseThrow(() -> new IllegalArgumentException("Table lookup option not specified correctly")); - final Optional optClassifyTable = Optional.ofNullable(route.getVppIpv6Route()) + VppIpv6Route vppIpv6Route = route.getAugmentation(VppIpv6RouteAttributesAugmentation.class) != null + ? route.getAugmentation(VppIpv6RouteAttributesAugmentation.class).getVppIpv6Route() : null; + + final Optional optClassifyTable = Optional.ofNullable(vppIpv6Route) .map(VppRouteAttributes::getClassifyTable); final byte classifyTableSet = booleanToByte(optClassifyTable.isPresent()); final byte classifyTableIndex = optClassifyTable.map(tableName -> classifyTableIndex(tableName, getVppClassifierContextManager(), mappingContext)) diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/trait/RouteRequestProducer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/trait/RouteRequestProducer.java index 97adb3589..f1a97aa22 100644 --- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/trait/RouteRequestProducer.java +++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/trait/RouteRequestProducer.java @@ -32,7 +32,7 @@ import java.util.Set; import java.util.regex.Pattern; 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; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; /** diff --git a/routing/routing-impl/src/main/resources/honeycomb-minimal-resources/config/routing.json b/routing/routing-impl/src/main/resources/honeycomb-minimal-resources/config/routing.json index 95f85414f..5b7fe6de7 100644 --- a/routing/routing-impl/src/main/resources/honeycomb-minimal-resources/config/routing.json +++ b/routing/routing-impl/src/main/resources/honeycomb-minimal-resources/config/routing.json @@ -1,4 +1,3 @@ { - "default-routing-instance-name": "vpp-routing-instance", "learned-route-name-prefix": "learned-route" -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java index 3e0c311df..25a1f5640 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java @@ -34,8 +34,13 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +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.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentationBuilder; @RunWith(HoneycombTestRunner.class) public class Ipv4RouteNamesFactoryTest @@ -73,19 +78,27 @@ public class Ipv4RouteNamesFactoryTest @Test public void testUniqueRouteName( @InjectTestData(resourcePath = "/ipv4/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) - StaticRoutes data) { - assertEquals("tst-protocol_19216821_24", - factory.uniqueRouteName(ROUTE_PROTOCOL_NAME, getIpv4RouteWithId(data, 1L))); - assertEquals("tst-protocol_19216821_24", factory.uniqueRouteName(vppRoute, mappingContext)); + StaticRoutes data) { + assertEquals("tst-protocol_192-168-2-1_24", + factory.uniqueRouteName(ROUTE_PROTOCOL_NAME, + getIpv4RouteWithId(data, new Ipv4Prefix("192.168.2.1/24")))); + assertEquals("tst-protocol_192-168-2-1_24", factory.uniqueRouteName(vppRoute, mappingContext)); } @Test public void testUniqueRouteHopName() { - assertEquals("iface_19216821_3", factory.uniqueRouteHopName(new NextHopBuilder() - .setAddress(new Ipv4Address("192.168.2.1")) - .setWeight((short) 3) + assertEquals("iface_192-168-2-1_3", factory.uniqueRouteHopName( + new NextHopBuilder() .setOutgoingInterface("iface") + .addAugmentation(NextHop1.class, + new NextHop1Builder() + .setNextHopAddress(new Ipv4Address("192.168.2.1")) + .build()) + .addAugmentation(VppIpv4NextHopAugmentation.class, + new VppIpv4NextHopAugmentationBuilder() + .setWeight((short) 3) + .build()) .build())); - assertEquals("iface_19216821_3", factory.uniqueRouteHopName(vppPath, mappingContext)); + assertEquals("iface_192-168-2-1_3", factory.uniqueRouteHopName(vppPath, mappingContext)); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java index 0e5ecd942..098055812 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java @@ -18,8 +18,8 @@ package io.fd.hc2vpp.routing; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteBuilder; public class Ipv6RouteData { diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java index c7e5a0bd4..2acf9fe4f 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java @@ -35,8 +35,13 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentationBuilder; @RunWith(HoneycombTestRunner.class) public class Ipv6RouteNamesFactoryTest implements RoutingRequestTestHelper, SchemaContextTestHelper, @@ -73,20 +78,30 @@ public class Ipv6RouteNamesFactoryTest implements RoutingRequestTestHelper, Sche @Test public void testUniqueRouteName( @InjectTestData(resourcePath = "/ipv6/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) - StaticRoutes data) { - assertEquals("tst-protocol_2001db8a0b12f01_64", - factory.uniqueRouteName(ROUTE_PROTOCOL_NAME, getIpv6RouteWithId(data, 1L))); - assertEquals("tst-protocol_2001db8a0b12f01_64", factory.uniqueRouteName(vppRoute, mappingContext)); + StaticRoutes data) { + assertEquals("tst-protocol_2001-db8-a0b-12f0--1_64", + factory.uniqueRouteName(ROUTE_PROTOCOL_NAME, + getIpv6RouteWithId(data, + new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64")))); + assertEquals("tst-protocol_2001-db8-a0b-12f0--1_64", factory.uniqueRouteName(vppRoute, mappingContext)); } @Test public void testUniqueRouteHopName() { - assertEquals("iface_2001db8a0b12f01_3", factory.uniqueRouteHopName(new NextHopBuilder() - .setAddress(new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001")) - .setWeight((short) 3) + assertEquals("iface_2001-db8-a0b-12f0--1_3", factory.uniqueRouteHopName( + new NextHopBuilder() .setOutgoingInterface("iface") - .build())); - assertEquals("iface_2001db8a0b12f01_3", + .setIndex("1") + .addAugmentation(NextHop1.class, + new NextHop1Builder() + .setNextHopAddress(new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001")) + .build()) + .addAugmentation(VppIpv6NextHopAugmentation.class, + new VppIpv6NextHopAugmentationBuilder() + .setWeight((short) 3) + .build()) + .build())); + assertEquals("iface_2001-db8-a0b-12f0--1_3", factory.uniqueRouteHopName(vppPath, mappingContext)); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java index d8159818b..679b90316 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java @@ -31,7 +31,7 @@ import com.google.inject.name.Named; import com.google.inject.testing.fieldbinder.Bind; import com.google.inject.testing.fieldbinder.BoundFieldModule; import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.routing.read.RoutingStateReaderFactory; +import io.fd.hc2vpp.routing.read.RoutingReaderFactory; import io.fd.hc2vpp.routing.write.RoutingWriterFactory; import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuilder; @@ -94,7 +94,7 @@ public class RoutingModuleTest { readerFactories.stream().forEach(factory -> factory.init(registryBuilder)); assertNotNull(registryBuilder.build()); assertEquals(1, readerFactories.size()); - assertTrue(readerFactories.iterator().next() instanceof RoutingStateReaderFactory); + assertTrue(readerFactories.iterator().next() instanceof RoutingReaderFactory); } @Test diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java index 6ca6bdd8b..fa166cb44 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java @@ -17,7 +17,7 @@ package io.fd.hc2vpp.routing.helpers; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -32,10 +32,13 @@ import io.fd.vpp.jvpp.core.dto.IpAddDelRouteReply; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.List; import org.mockito.ArgumentCaptor; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +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; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProducer, RouteMapper { @@ -43,9 +46,9 @@ public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProd String ROUTE_PROTOCOL_NAME_2 = "tst-protocol-2"; String ROUTE_NAME = "tst-route"; String STATIC_ROUTE_PATH = "/hc2vpp-ietf-routing:routing" + - "/hc2vpp-ietf-routing:routing-instance[hc2vpp-ietf-routing:name='" + ROUTE_PROTOCOL_NAME + "']" + - "/hc2vpp-ietf-routing:routing-protocols" + - "/hc2vpp-ietf-routing:routing-protocol[hc2vpp-ietf-routing:name='" + ROUTE_NAME + "']" + + "/hc2vpp-ietf-routing:control-plane-protocols" + + "/hc2vpp-ietf-routing:control-plane-protocol" + + "[hc2vpp-ietf-routing:name='" + ROUTE_NAME + "'][hc2vpp-ietf-routing:type='static']" + "/hc2vpp-ietf-routing:static-routes"; default IpAddDelRoute desiredFlaglessResult(final int add, final int ipv6, final int isMultipath, @@ -75,8 +78,9 @@ public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProd final int protocolTableId, final int secondaryTableId) { // verifiaction of special request that has only destination address and flag - return desiredResult(add, ipv6, 0, destinationAddress, destinationPrefixLength, null, 0, 0, protocolTableId, secondaryTableId, 0, 0, - isDrop, isReceive, isUnreach, isProhibit); + return desiredResult(add, ipv6, 0, destinationAddress, destinationPrefixLength, null, 0, 0, + protocolTableId, secondaryTableId, 0, 0, isDrop, + isReceive, isUnreach, isProhibit); } default IpAddDelRoute desiredResult(final int add, final int ipv6, final int isMultipath, @@ -136,34 +140,33 @@ public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProd when(api.ipAddDelRoute(any())).thenReturn(future(new IpAddDelRouteReply())); } - default Route getIpv4RouteWithId(final StaticRoutes staticRoutes, final long id) { + default Route getIpv4RouteWithId(final StaticRoutes staticRoutes, final Ipv4Prefix id) { return staticRoutes.getAugmentation(StaticRoutes1.class) .getIpv4() .getRoute() .stream() - .filter(route -> route.getId() == id) + .filter(route -> route.getDestinationPrefix().getValue().equals(id.getValue())) .collect(RWUtils.singleItemCollector()); } default NextHop getHopWithId( final Route route, final int id) { - return org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList.class - .cast(route.getNextHopOptions()) - .getNextHopList() - .getNextHop() + return NextHopList.class + .cast(route.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop() .stream() - .filter(nextHop -> nextHop.getKey().getId().intValue() == id) + .filter(nextHop -> Integer.valueOf(nextHop.getKey().getIndex()) == id) .collect(RWUtils.singleItemCollector()); } - default org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route getIpv6RouteWithId( - final StaticRoutes staticRoutes, final long id) { + default org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route getIpv6RouteWithId( + final StaticRoutes staticRoutes, final Ipv6Prefix id) { return staticRoutes.getAugmentation( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1.class) + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1.class) .getIpv6() .getRoute() .stream() - .filter(route -> route.getId() == id) + .filter(route -> route.getDestinationPrefix().getValue().equals(id.getValue())) .collect(RWUtils.singleItemCollector()); } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java index 7ae84854d..9a0073580 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java @@ -26,26 +26,33 @@ public interface SchemaContextTestHelper extends InjectablesProcessor { @SchemaContextProvider default ModuleInfoBackedContext getSchemaContext() { return provideSchemaContextFor(ImmutableSet.of( + // Default interfaces + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.$YangModuleInfoImpl + .getInstance(), // Default ietf-ip org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.$YangModuleInfoImpl - .getInstance(), + .getInstance(), // Default ietf-routing - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.$YangModuleInfoImpl - .getInstance(), - // Ipv4 augmentations - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.$YangModuleInfoImpl - .getInstance(), + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.$YangModuleInfoImpl + .getInstance(), // Ipv4 augmentations - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.$YangModuleInfoImpl - .getInstance(), + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.$YangModuleInfoImpl + .getInstance(), + // Ipv6 augmentations + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.$YangModuleInfoImpl + .getInstance(), // Vpp routing - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.$YangModuleInfoImpl - .getInstance(), - // Vpp routing RA - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev170502.$YangModuleInfoImpl + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.$YangModuleInfoImpl + .getInstance(), + // Vpp IPv4 augmentations + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.$YangModuleInfoImpl .getInstance(), - // Table lookup - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.table.lookup.rev170917.$YangModuleInfoImpl.getInstance() + // Vpp IPv6 augmentations + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.$YangModuleInfoImpl + .getInstance(), + // Vpp routing RA + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev180319.$YangModuleInfoImpl + .getInstance() )); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/ControlPlaneProtocolCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/ControlPlaneProtocolCustomizerTest.java new file mode 100644 index 000000000..43ec73bd1 --- /dev/null +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/ControlPlaneProtocolCustomizerTest.java @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.routing.read; + +import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.core.IsCollectionContaining.hasItems; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.routing.Ipv4RouteData; +import io.fd.hc2vpp.routing.Ipv6RouteData; +import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; +import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; +import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; +import io.fd.vpp.jvpp.core.dto.Ip6FibDetails; +import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.IpFibDetails; +import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; +import io.fd.vpp.jvpp.core.types.FibPath; +import java.util.Arrays; +import java.util.List; +import org.junit.Test; +import org.mockito.Mock; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocolsBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class ControlPlaneProtocolCustomizerTest + extends ListReaderCustomizerTest + implements ByteDataTranslator { + + private static final String VPP_PROTOCOL_PREFIX = "vpp-protocol"; + + @Mock + private EntityDumpExecutor ipv4Executor; + + @Mock + private EntityDumpExecutor ipv6Executor; + private DumpCacheManager ipv4RoutesDumpManager; + private DumpCacheManager ipv6RoutesDumpManager; + + private NamingContext routingProtocolContext; + + public ControlPlaneProtocolCustomizerTest() { super(ControlPlaneProtocol.class, ControlPlaneProtocolsBuilder.class); + } + + @Override + protected void setUp() throws Exception { + when(ipv4Executor.executeDump(any(), any())).thenReturn(replyDumpIpv4()); + when(ipv6Executor.executeDump(any(), any())).thenReturn(replyDumpIpv6()); + when(ctx.getModificationCache()).thenReturn(cache); + + ipv4RoutesDumpManager = new DumpCacheManager.DumpCacheManagerBuilder() + .withExecutor(ipv4Executor) + .acceptOnly(IpFibDetailsReplyDump.class) + .build(); + + ipv6RoutesDumpManager = new DumpCacheManager.DumpCacheManagerBuilder() + .withExecutor(ipv6Executor) + .acceptOnly(Ip6FibDetailsReplyDump.class) + .build(); + + routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context"); + defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); + defineMapping(mappingContext, "tst-protocol-2", 2, "routing-protocol-context"); + defineMapping(mappingContext, "tst-protocol-3", 3, "routing-protocol-context"); + } + + @Test + public void getAllIds() throws Exception { + final List keys = + getCustomizer().getAllIds(InstanceIdentifier.create(ControlPlaneProtocol.class), ctx); + + assertThat(keys, hasSize(3)); + assertThat(keys, hasItems(new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class), + new ControlPlaneProtocolKey("tst-protocol-2", Static.class), + new ControlPlaneProtocolKey("tst-protocol-3", Static.class))); + } + + @Test + public void readCurrentAttributes() throws Exception { + final InstanceIdentifier identifier = + InstanceIdentifier.create(ControlPlaneProtocols.class) + .child(ControlPlaneProtocol.class, new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class)); + + final ControlPlaneProtocolBuilder builder = new ControlPlaneProtocolBuilder(); + getCustomizer().readCurrentAttributes(identifier, builder, ctx); + + assertEquals(ROUTE_PROTOCOL_NAME, builder.getName()); + assertEquals(ROUTE_PROTOCOL_NAME, builder.getKey().getName()); + assertEquals(Static.class, builder.getType()); + } + + @Override + protected ReaderCustomizer initCustomizer() { + return new ControlPlaneProtocolCustomizer(routingProtocolContext, ipv4RoutesDumpManager, ipv6RoutesDumpManager); + } + + private Ip6FibDetailsReplyDump replyDumpIpv6() { + Ip6FibDetailsReplyDump replyDump = new Ip6FibDetailsReplyDump(); + + // first is special + Ip6FibDetails detail1 = new Ip6FibDetails(); + detail1.tableId = 1; + detail1.address = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY; + detail1.addressLength = 24; + + FibPath path1 = new FibPath(); + path1.isLocal = 1; + detail1.path = new FibPath[]{path1}; + + + //second is simple + Ip6FibDetails detail2 = new Ip6FibDetails(); + detail2.tableId = 2; + detail2.address = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY; + detail2.addressLength = 22; + detail2.path = new FibPath[]{}; + + FibPath path2 = new FibPath(); + path2.weight = 3; + path2.nextHop = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY; + path2.afi = 0; + path2.swIfIndex = 1; + detail2.path = new FibPath[]{path2}; + + // third is list + Ip6FibDetails detail3 = new Ip6FibDetails(); + detail3.tableId = 1; + detail3.address = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY; + detail3.addressLength = 16; + + FibPath path3 = new FibPath(); + path3.swIfIndex = 1; + path3.weight = 1; + path3.nextHop = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY; + path3.afi = 0; + + FibPath path4 = new FibPath(); + path4.swIfIndex = 1; + path4.weight = 2; + path4.nextHop = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY; + path4.afi = 0; + + detail3.path = new FibPath[]{path3, path4}; + + replyDump.ip6FibDetails = Arrays.asList(detail1, detail2, detail3); + return replyDump; + } + + private IpFibDetailsReplyDump replyDumpIpv4() { + IpFibDetailsReplyDump replyDump = new IpFibDetailsReplyDump(); + + // first is special + IpFibDetails detail1 = new IpFibDetails(); + detail1.tableId = 1; + detail1.address = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; + detail1.addressLength = 24; + + FibPath path1 = new FibPath(); + path1.isLocal = 1; + detail1.path = new FibPath[]{path1}; + + + //second is simple + IpFibDetails detail2 = new IpFibDetails(); + detail2.tableId = 3; + detail2.address = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; + detail2.addressLength = 22; + detail2.path = new FibPath[]{}; + + FibPath path2 = new FibPath(); + path2.weight = 3; + path2.nextHop = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; + path2.afi = 0; + path2.swIfIndex = 1; + detail2.path = new FibPath[]{path2}; + + // third is list + IpFibDetails detail3 = new IpFibDetails(); + detail3.tableId = 1; + detail3.address = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; + detail3.addressLength = 16; + + FibPath path3 = new FibPath(); + path3.swIfIndex = 1; + path3.weight = 1; + path3.nextHop = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; + path3.afi = 0; + + FibPath path4 = new FibPath(); + path4.swIfIndex = 1; + path4.weight = 2; + path4.nextHop = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; + path4.afi = 0; + + detail3.path = new FibPath[]{path3, path4}; + + replyDump.ipFibDetails = Arrays.asList(detail1, detail2, detail3); + return replyDump; + } +} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java index a0c890b9b..5e319e370 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java @@ -16,13 +16,24 @@ package io.fd.hc2vpp.routing.read; +import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Receive; + import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.Ipv4RouteData; import io.fd.hc2vpp.routing.RoutingConfiguration; +import io.fd.hc2vpp.routing.helpers.ClassifyTableTestHelper; import io.fd.hc2vpp.routing.naming.Ipv4RouteNamesFactory; import io.fd.hc2vpp.routing.trait.RouteMapper; +import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; @@ -30,49 +41,46 @@ import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; import io.fd.vpp.jvpp.core.dto.IpFibDetails; import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; import io.fd.vpp.jvpp.core.types.FibPath; +import java.util.Arrays; +import java.util.List; import org.apache.commons.lang3.builder.EqualsBuilder; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; 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.ipv4.unicast.routing.rev170917.StaticRoutes2; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.NextHopOptions; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SimpleNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SpecialNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.SimpleNextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.NextHopOptions; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SpecialNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentationBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import java.util.Arrays; -import java.util.List; - -import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest - implements RouteMapper { + implements RouteMapper, ClassifyTableTestHelper { - private final InstanceIdentifier ipv4InstanceIdentifier = InstanceIdentifier.create(RoutingProtocols.class) - .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME)) + private final InstanceIdentifier ipv4InstanceIdentifier = + InstanceIdentifier.create(ControlPlaneProtocols.class) + .child(ControlPlaneProtocol.class, new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class)) .child(StaticRoutes.class) - .augmentation(StaticRoutes2.class) + .augmentation(StaticRoutes1.class) .child(Ipv4.class); private DumpCacheManager manager; @Mock @@ -81,12 +89,18 @@ public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest executor; + @Mock + private VppClassifierContextManager classifyManager; + private NamingContext interfaceContext = new NamingContext("ifaces", "interface-context"); private NamingContext routesContext = new NamingContext("routes", "route-context"); private NamingContext routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context"); - private InstanceIdentifier routeIdSpecialHop = ipv4InstanceIdentifier.child(Route.class, new RouteKey(1L)); - private InstanceIdentifier routeIdSimpleHop = ipv4InstanceIdentifier.child(Route.class, new RouteKey(2L)); - private InstanceIdentifier routeIdListHop = ipv4InstanceIdentifier.child(Route.class, new RouteKey(3L)); + private InstanceIdentifier routeIdSpecialHop = + ipv4InstanceIdentifier.child(Route.class, new RouteKey(new Ipv4Prefix("192.168.2.1/24"))); + private InstanceIdentifier routeIdSimpleHop = + ipv4InstanceIdentifier.child(Route.class, new RouteKey(new Ipv4Prefix("192.168.2.2/22"))); + private InstanceIdentifier routeIdListHop = + ipv4InstanceIdentifier.child(Route.class, new RouteKey(new Ipv4Prefix("192.168.2.2/16"))); public Ipv4RouteCustomizerTest() { @@ -118,6 +132,9 @@ public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest keys = getCustomizer().getAllIds(routeIdSpecialHop, ctx); assertThat(keys, hasSize(3)); - assertThat(keys, hasItems(new RouteKey(1L), new RouteKey(2L), new RouteKey(3L))); + assertThat(keys, hasItems(new RouteKey(new Ipv4Prefix("192.168.2.1/24")), + new RouteKey(new Ipv4Prefix("192.168.2.2/22")), + new RouteKey(new Ipv4Prefix("192.168.2.2/16")))); } @Test @@ -189,15 +208,13 @@ public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest initCustomizer() { return new Ipv4RouteCustomizer(manager, configuration, routeHopContext, interfaceContext, - routesContext, routingProtocolContext); + routesContext, routingProtocolContext); } } \ No newline at end of file diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java index 3626056b8..503c01914 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java @@ -23,14 +23,17 @@ import static org.hamcrest.collection.IsCollectionWithSize.hasSize; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Receive; import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.Ipv6RouteData; import io.fd.hc2vpp.routing.RoutingConfiguration; +import io.fd.hc2vpp.routing.helpers.ClassifyTableTestHelper; import io.fd.hc2vpp.routing.naming.Ipv6RouteNamesFactory; import io.fd.hc2vpp.routing.trait.RouteMapper; +import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.ModificationCache; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; @@ -45,28 +48,34 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes2; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.NextHopOptions; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SimpleNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SpecialNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.SimpleNextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.NextHopOptions; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SpecialNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentationBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest - implements RouteMapper { + implements RouteMapper, ClassifyTableTestHelper { private static final String ROUTING_PROTOCOL_PREFIX = "route-p-"; private DumpCacheManager manager; @@ -83,6 +92,9 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest ipv6InstanceIdentifier = InstanceIdentifier.create(RoutingProtocols.class) - .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME)) + final InstanceIdentifier ipv6InstanceIdentifier = InstanceIdentifier.create(ControlPlaneProtocols.class) + .child(ControlPlaneProtocol.class, new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class)) .child(StaticRoutes.class) - .augmentation(StaticRoutes2.class) + .augmentation(StaticRoutes1.class) .child(Ipv6.class); - routeIdSpecialHop = ipv6InstanceIdentifier.child(Route.class, new RouteKey(1L)); - routeIdSimpleHop = ipv6InstanceIdentifier.child(Route.class, new RouteKey(2L)); - routeIdListHop = ipv6InstanceIdentifier.child(Route.class, new RouteKey(3L)); + routeIdSpecialHop = + ipv6InstanceIdentifier.child(Route.class, new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::1/24"))); + routeIdSimpleHop = + ipv6InstanceIdentifier.child(Route.class, new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::2/22"))); + routeIdListHop = + ipv6InstanceIdentifier.child(Route.class, new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::2/16"))); factory = new Ipv6RouteNamesFactory(interfaceContext, routingProtocolContext); @@ -136,6 +151,8 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest keys = getCustomizer().getAllIds(routeIdSpecialHop, ctx); assertThat(keys, hasSize(3)); - assertThat(keys, hasItems(new RouteKey(1L), new RouteKey(2L), new RouteKey(3L))); + assertThat(keys, hasItems(new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::1/24")), + new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::2/22")), + new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::2/16")))); } @Test @@ -209,15 +228,14 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest initCustomizer() { return new Ipv6RouteCustomizer(manager, configuration, routeHopContext, - interfaceContext, routesContext, routingProtocolContext); + interfaceContext, routesContext, routingProtocolContext); } } \ No newline at end of file diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizerTest.java deleted file mode 100644 index 1d0057cf2..000000000 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizerTest.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.read; - -import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.IsCollectionContaining.hasItems; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - -import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; -import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.routing.Ipv4RouteData; -import io.fd.hc2vpp.routing.Ipv6RouteData; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; -import io.fd.vpp.jvpp.core.dto.Ip6FibDetails; -import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.IpFibDetails; -import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; -import io.fd.vpp.jvpp.core.types.FibPath; -import java.util.Arrays; -import java.util.List; -import org.junit.Test; -import org.mockito.Mock; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Static; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocolsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class RoutingProtocolCustomizerTest - extends ListReaderCustomizerTest - implements ByteDataTranslator { - - private static final String VPP_PROTOCOL_PREFIX = "vpp-protocol"; - - @Mock - private EntityDumpExecutor ipv4Executor; - - @Mock - private EntityDumpExecutor ipv6Executor; - private DumpCacheManager ipv4RoutesDumpManager; - private DumpCacheManager ipv6RoutesDumpManager; - - private NamingContext routingProtocolContext; - - public RoutingProtocolCustomizerTest() { - super(RoutingProtocol.class, RoutingProtocolsBuilder.class); - } - - @Override - protected void setUp() throws Exception { - when(ipv4Executor.executeDump(any(), any())).thenReturn(replyDumpIpv4()); - when(ipv6Executor.executeDump(any(), any())).thenReturn(replyDumpIpv6()); - when(ctx.getModificationCache()).thenReturn(cache); - - ipv4RoutesDumpManager = new DumpCacheManager.DumpCacheManagerBuilder() - .withExecutor(ipv4Executor) - .acceptOnly(IpFibDetailsReplyDump.class) - .build(); - - ipv6RoutesDumpManager = new DumpCacheManager.DumpCacheManagerBuilder() - .withExecutor(ipv6Executor) - .acceptOnly(Ip6FibDetailsReplyDump.class) - .build(); - - routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context"); - defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); - defineMapping(mappingContext, "tst-protocol-2", 2, "routing-protocol-context"); - defineMapping(mappingContext, "tst-protocol-3", 3, "routing-protocol-context"); - } - - @Test - public void getAllIds() throws Exception { - final List keys = - getCustomizer().getAllIds(InstanceIdentifier.create(RoutingProtocol.class), ctx); - - assertThat(keys, hasSize(3)); - assertThat(keys, hasItems(new RoutingProtocolKey(ROUTE_PROTOCOL_NAME), new RoutingProtocolKey("tst-protocol-2"), - new RoutingProtocolKey("tst-protocol-3"))); - } - - @Test - public void readCurrentAttributes() throws Exception { - final InstanceIdentifier identifier = InstanceIdentifier.create(RoutingProtocols.class) - .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME)); - - final RoutingProtocolBuilder builder = new RoutingProtocolBuilder(); - getCustomizer().readCurrentAttributes(identifier, builder, ctx); - - assertEquals(ROUTE_PROTOCOL_NAME, builder.getName()); - assertEquals(ROUTE_PROTOCOL_NAME, builder.getKey().getName()); - assertEquals(Static.class, builder.getType()); - } - - @Override - protected ReaderCustomizer initCustomizer() { - return new RoutingProtocolCustomizer(routingProtocolContext, ipv4RoutesDumpManager, ipv6RoutesDumpManager); - } - - private Ip6FibDetailsReplyDump replyDumpIpv6() { - Ip6FibDetailsReplyDump replyDump = new Ip6FibDetailsReplyDump(); - - // first is special - Ip6FibDetails detail1 = new Ip6FibDetails(); - detail1.tableId = 1; - detail1.address = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY; - detail1.addressLength = 24; - - FibPath path1 = new FibPath(); - path1.isLocal = 1; - detail1.path = new FibPath[]{path1}; - - - //second is simple - Ip6FibDetails detail2 = new Ip6FibDetails(); - detail2.tableId = 2; - detail2.address = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY; - detail2.addressLength = 22; - detail2.path = new FibPath[]{}; - - FibPath path2 = new FibPath(); - path2.weight = 3; - path2.nextHop = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY; - path2.afi = 0; - path2.swIfIndex = 1; - detail2.path = new FibPath[]{path2}; - - // third is list - Ip6FibDetails detail3 = new Ip6FibDetails(); - detail3.tableId = 1; - detail3.address = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY; - detail3.addressLength = 16; - - FibPath path3 = new FibPath(); - path3.swIfIndex = 1; - path3.weight = 1; - path3.nextHop = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY; - path3.afi = 0; - - FibPath path4 = new FibPath(); - path4.swIfIndex = 1; - path4.weight = 2; - path4.nextHop = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY; - path4.afi = 0; - - detail3.path = new FibPath[]{path3, path4}; - - replyDump.ip6FibDetails = Arrays.asList(detail1, detail2, detail3); - return replyDump; - } - - private IpFibDetailsReplyDump replyDumpIpv4() { - IpFibDetailsReplyDump replyDump = new IpFibDetailsReplyDump(); - - // first is special - IpFibDetails detail1 = new IpFibDetails(); - detail1.tableId = 1; - detail1.address = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; - detail1.addressLength = 24; - - FibPath path1 = new FibPath(); - path1.isLocal = 1; - detail1.path = new FibPath[]{path1}; - - - //second is simple - IpFibDetails detail2 = new IpFibDetails(); - detail2.tableId = 3; - detail2.address = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; - detail2.addressLength = 22; - detail2.path = new FibPath[]{}; - - FibPath path2 = new FibPath(); - path2.weight = 3; - path2.nextHop = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; - path2.afi = 0; - path2.swIfIndex = 1; - detail2.path = new FibPath[]{path2}; - - // third is list - IpFibDetails detail3 = new IpFibDetails(); - detail3.tableId = 1; - detail3.address = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; - detail3.addressLength = 16; - - FibPath path3 = new FibPath(); - path3.swIfIndex = 1; - path3.weight = 1; - path3.nextHop = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; - path3.afi = 0; - - FibPath path4 = new FibPath(); - path4.swIfIndex = 1; - path4.weight = 2; - path4.nextHop = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; - path4.afi = 0; - - detail3.path = new FibPath[]{path3, path4}; - - replyDump.ipFibDetails = Arrays.asList(detail1, detail2, detail3); - return replyDump; - } -} \ No newline at end of file diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java deleted file mode 100644 index 7bece735b..000000000 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.read; - - -import static org.junit.Assert.assertEquals; - -import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper; -import io.fd.honeycomb.test.tools.HoneycombTestRunner; -import io.fd.honeycomb.test.tools.annotations.InjectTestData; -import io.fd.honeycomb.translate.read.ReadContext; -import io.fd.honeycomb.translate.spi.read.Initialized; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.RoutingState; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@RunWith(HoneycombTestRunner.class) -public class RoutingStateCustomizerTest implements SchemaContextTestHelper { - - @InjectTestData(resourcePath = "/init/config-data.json") - private Routing config; - - @InjectTestData(resourcePath = "/init/state-data.json") - private RoutingState state; - - @Mock - private ReadContext readContext; - - @Before - public void init() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testInit() { - final InstanceIdentifier identifier = InstanceIdentifier.create(RoutingState.class); - final Initialized initilized = - new RoutingStateCustomizer().init(identifier, state, readContext); - - final Routing initializedRouting = Routing.class.cast(initilized.getData()); - - assertEquals(config, initializedRouting); - } -} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java new file mode 100644 index 000000000..fa25520ca --- /dev/null +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.routing.write; + +import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME; +import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME_2; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.write.WriteFailedException; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Direct; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.RoutingProtocolVppAttr; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.RoutingProtocolVppAttrBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.routing.control.plane.protocols.control.plane.protocol.VppProtocolAttributesBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class ControlPlaneProtocolCustomizerTest extends WriterCustomizerTest { + + private InstanceIdentifier validId; + private ControlPlaneProtocol validData; + private ControlPlaneProtocol validData2; + private ControlPlaneProtocol invalidData; + private ControlPlaneProtocolCustomizer customizer; + private NamingContext routingProtocolContext; + + @Before + public void init() { + validId = InstanceIdentifier.create(ControlPlaneProtocol.class); + validData = new ControlPlaneProtocolBuilder() + .setName(ROUTE_PROTOCOL_NAME) + .setType(Static.class) + .addAugmentation(RoutingProtocolVppAttr.class, new RoutingProtocolVppAttrBuilder() + .setVppProtocolAttributes(new VppProtocolAttributesBuilder() + .setPrimaryVrf(new VniReference(1L)) + .build()) + .build()) + .build(); + + validData2= new ControlPlaneProtocolBuilder() + .setName(ROUTE_PROTOCOL_NAME_2) + .setType(Static.class) + .addAugmentation(RoutingProtocolVppAttr.class, new RoutingProtocolVppAttrBuilder() + .setVppProtocolAttributes(new VppProtocolAttributesBuilder() + .setPrimaryVrf(new VniReference(1L)) + .build()) + .build()) + .build(); + + invalidData = new ControlPlaneProtocolBuilder() + .setType(Direct.class) + .build(); + + routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context"); + customizer = new ControlPlaneProtocolCustomizer(routingProtocolContext); + } + + @Test + public void testWriteIsStatic() throws WriteFailedException { + noMappingDefined(mappingContext, ROUTE_PROTOCOL_NAME, "routing-protocol-context"); + try { + customizer.writeCurrentAttributes(validId, validData, writeContext); + } catch (Exception e) { + fail("Test should have passed without throwing exception"); + } + } + + /** + * Should not fail, just ignore re-mapping same name + * */ + @Test + public void testWriteIsStaticSameAllreadyExist() throws WriteFailedException { + defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); + try { + customizer.writeCurrentAttributes(validId, validData, writeContext); + } catch (Exception e) { + fail("Test should have passed without throwing exception"); + } + } + + /** + * Should fail, because of attempt to map different name to same index + * */ + @Test + public void testWriteIsStaticOtherAllreadyExist() throws WriteFailedException { + defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); + try { + customizer.writeCurrentAttributes(validId, validData2, writeContext); + } catch (Exception e) { + assertTrue(e instanceof IllegalStateException); + return; + } + fail("Test should have thrown exception"); + } + + @Test + public void testWriteIsntStatic() throws WriteFailedException { + try { + customizer.writeCurrentAttributes(validId, invalidData, writeContext); + } catch (Exception e) { + assertTrue(e instanceof IllegalArgumentException); + return; + } + fail("Test should have thrown exception"); + } + + @Test(expected = UnsupportedOperationException.class) + public void testUpdate() throws WriteFailedException { + customizer.updateCurrentAttributes(validId, validData, validData, writeContext); + } +} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java index b97658669..41a1ae6d1 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java @@ -16,6 +16,14 @@ package io.fd.hc2vpp.routing.write; +import static io.fd.hc2vpp.routing.Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; +import static io.fd.hc2vpp.routing.Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; +import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_INDEX; +import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_NAME; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import com.google.common.collect.ImmutableList; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; @@ -36,32 +44,21 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; 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.ipv4.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.TableLookupBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.table.lookup.TableLookupParamsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; - - - +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.TableLookupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import static io.fd.hc2vpp.routing.Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; -import static io.fd.hc2vpp.routing.Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; -import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_INDEX; -import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_NAME; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - @RunWith(HoneycombTestRunner.class) public class Ipv4RouteCustomizerTest extends WriterCustomizerTest implements ClassifyTableTestHelper, RoutingRequestTestHelper, SchemaContextTestHelper { @@ -89,8 +86,8 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest new NamingContext("route", "route-context"), routingProtocolContext, routeHopContext, classifyManager); - validId = InstanceIdentifier.create(RoutingProtocols.class) - .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME)) + validId = InstanceIdentifier.create(ControlPlaneProtocols.class) + .child(ControlPlaneProtocol.class, new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class)) .child(StaticRoutes.class) .augmentation(StaticRoutes1.class) .child(Ipv4.class) @@ -108,7 +105,7 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest public void testWriteSingleHop( @InjectTestData(resourcePath = "/ipv4/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { - final Route route1 = getIpv4RouteWithId(route, 1L); + final Route route1 = getIpv4RouteWithId(route, new Ipv4Prefix("192.168.2.1/24")); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context"); customizer.writeCurrentAttributes(validId, route1, writeContext); @@ -123,13 +120,12 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest @Test public void testWriteTableLookup() throws WriteFailedException { final Route route = new RouteBuilder() - .setKey(new RouteKey(2L)) + .setKey(new RouteKey(new Ipv4Prefix("192.168.2.1/24"))) .setDestinationPrefix(new Ipv4Prefix("192.168.2.1/24")) - .setNextHopOptions(new TableLookupBuilder() - .setTableLookupParams(new TableLookupParamsBuilder() - .setSecondaryVrf(new VniReference(4L)) - .build()) - .build()) + .setNextHop(new NextHopBuilder().setNextHopOptions( + new TableLookupCaseBuilder() + .setSecondaryVrf(new VniReference(4L)) + .build()).build()) .build(); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route), "route-context"); customizer.writeCurrentAttributes(validId, route, writeContext); @@ -142,9 +138,10 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest @Test public void testWriteHopList( - @InjectTestData(resourcePath = "/ipv4/multihop/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) + @InjectTestData(resourcePath = "/ipv4/multihop/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) + StaticRoutes route) throws WriteFailedException { - final Route route1 = getIpv4RouteWithId(route, 1L); + final Route route1 = getIpv4RouteWithId(route, new Ipv4Prefix("192.168.2.1/24")); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context"); customizer.writeCurrentAttributes(validId, route1, writeContext); @@ -174,21 +171,24 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest public void testWriteSpecialHop( @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { - final Route route1 = getIpv4RouteWithId(route, 1L); + final Route route1 = getIpv4RouteWithId(route, new Ipv4Prefix("192.168.2.1/24")); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context"); customizer.writeCurrentAttributes(validId, route1, writeContext); verifyInvocation(1, ImmutableList - .of(desiredSpecialResult(1, 0, FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, - requestCaptor); + .of(desiredSpecialResult(1, 0, FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, + ROUTE_PROTOCOL_INDEX, 0)), + api, requestCaptor); } @Test public void testUpdate( @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) { try { - customizer.updateCurrentAttributes(validId, new RouteBuilder().build(), getIpv4RouteWithId(route, 1L), - writeContext); + customizer.updateCurrentAttributes(validId, + new RouteBuilder().build(), + getIpv4RouteWithId(route, + new Ipv4Prefix("192.168.2.1/24")), writeContext); } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof UnsupportedOperationException); verifyNotInvoked(api); @@ -202,18 +202,21 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest public void testDeleteSingleHop( @InjectTestData(resourcePath = "/ipv4/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { - customizer.deleteCurrentAttributes(validId, getIpv4RouteWithId(route, 1L), writeContext); + customizer.deleteCurrentAttributes(validId, + getIpv4RouteWithId(route, + new Ipv4Prefix("192.168.2.1/24")), writeContext); verifyInvocation(1, ImmutableList .of(desiredFlaglessResult(0, 0, 0, FIRST_ADDRESS_AS_ARRAY, 24, SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, - 0, ROUTE_PROTOCOL_INDEX, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor); + 0, ROUTE_PROTOCOL_INDEX, 0, CLASSIFY_TABLE_INDEX, 1)), + api, requestCaptor); } @Test public void testDeleteHopList( @InjectTestData(resourcePath = "/ipv4/multihop/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { - final Route route1 = getIpv4RouteWithId(route, 1L); + final Route route1 = getIpv4RouteWithId(route, new Ipv4Prefix("192.168.2.1/24")); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context"); customizer.deleteCurrentAttributes(validId, route1, writeContext); @@ -242,10 +245,11 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest public void testDeleteSpecialHop( @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { - customizer.deleteCurrentAttributes(validId, getIpv4RouteWithId(route, 1L), writeContext); + customizer.deleteCurrentAttributes(validId, getIpv4RouteWithId(route, new Ipv4Prefix("192.168.2.1/24")), writeContext); verifyInvocation(1, - ImmutableList.of(desiredSpecialResult(0, 0, FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, - requestCaptor); + ImmutableList.of(desiredSpecialResult(0, 0, FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, + ROUTE_PROTOCOL_INDEX, 0)), + api, requestCaptor); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java index a68fa57c4..171b59786 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java @@ -16,6 +16,9 @@ package io.fd.hc2vpp.routing.write; +import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_INDEX; +import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_NAME; + import com.google.common.collect.ImmutableList; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; @@ -36,28 +39,27 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.TableLookupBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.table.lookup.TableLookupParamsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.TableLookupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_INDEX; -import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_NAME; - @RunWith(HoneycombTestRunner.class) public class Ipv6RouteCustomizerTest extends WriterCustomizerTest implements RoutingRequestTestHelper, ClassifyTableTestHelper, SchemaContextTestHelper { private static final int ROUTE_PROTOCOL_INDEX = 1; + public static final Ipv6Prefix IPV_6_PREFIX = new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64"); @Captor private ArgumentCaptor requestCaptor; @@ -84,8 +86,8 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest new Ipv6RouteCustomizer(api, interfaceContext, routeContext, routingProtocolContext, routeHopContext, classifyManager); - validId = InstanceIdentifier.create(RoutingProtocols.class) - .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME)) + validId = InstanceIdentifier.create(ControlPlaneProtocols.class) + .child(ControlPlaneProtocol.class, new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class)) .child(StaticRoutes.class) .augmentation(StaticRoutes1.class) .child(Ipv6.class) @@ -103,7 +105,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); + customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(1, ImmutableList .of(desiredFlaglessResult(1, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, ROUTE_PROTOCOL_INDEX, @@ -114,19 +116,17 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @Test public void testWriteTableLookup() throws WriteFailedException { final Route route = new RouteBuilder() - .setKey(new RouteKey(2L)) - .setDestinationPrefix(new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/24")) - .setNextHopOptions(new TableLookupBuilder() - .setTableLookupParams(new TableLookupParamsBuilder() - .setSecondaryVrf(new VniReference(4L)) - .build()) - .build()) + .setKey(new RouteKey(IPV_6_PREFIX)) + .setDestinationPrefix(IPV_6_PREFIX) + .setNextHop(new NextHopBuilder().setNextHopOptions(new TableLookupCaseBuilder() + .setSecondaryVrf(new VniReference(4L)) + .build()).build()) .build(); whenAddRouteThenSuccess(api); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route), "route-context"); customizer.writeCurrentAttributes(validId, route, writeContext); verifyInvocation(1, ImmutableList - .of(desiredFlaglessResult(1, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, + .of(desiredFlaglessResult(1, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, new byte[4], ~0, 0, ROUTE_PROTOCOL_INDEX, 4, 0, 0)), api, requestCaptor); @@ -137,7 +137,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/multihop/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); + customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(2, ImmutableList.of( desiredFlaglessResult(1, 1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, @@ -160,11 +160,12 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), + customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(1, ImmutableList - .of(desiredSpecialResult(0, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, - requestCaptor); + .of(desiredSpecialResult(0, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, + 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), + api, requestCaptor); } @Test @@ -172,7 +173,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); + customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(1, ImmutableList .of(desiredFlaglessResult(0, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, @@ -184,7 +185,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/multihop/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); + customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(2, ImmutableList.of( desiredFlaglessResult(0, 1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, @@ -201,10 +202,11 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), + customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(1, ImmutableList - .of(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, - requestCaptor); + .of(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, + 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), + api, requestCaptor); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java index 86c2df115..7321acde5 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java @@ -31,41 +31,43 @@ import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaPrefix; import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaPrefixReply; import org.junit.Test; import org.junit.runner.RunWith; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.Interface1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.Ipv6RouterAdvertisements; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.PrefixList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.prefix.list.Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.Interfaces; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.Ipv61; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.Ipv6RouterAdvertisements; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.PrefixList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.prefix.list.Prefix; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @RunWith(HoneycombTestRunner.class) public class PrefixCustomizerTest extends WriterCustomizerTest implements SchemaContextTestHelper { - private static final String INSTANCE_NAME = "tst-protocol"; private static final String CTX_NAME = "interface-context"; private static final String IFC_NAME = "eth0"; private static final int IFC_INDEX = 1; - private static final InstanceIdentifier IID = InstanceIdentifier.create(Routing.class) - .child(RoutingInstance.class, new RoutingInstanceKey(INSTANCE_NAME)).child(Interfaces.class) - .child(Interface.class, new InterfaceKey(IFC_NAME)).augmentation( - Interface1.class).child(Ipv6RouterAdvertisements.class).child(PrefixList.class).child(Prefix.class); + private static final InstanceIdentifier IID = InstanceIdentifier + .create(Interfaces.class) + .child(Interface.class, new InterfaceKey(IFC_NAME)) + .augmentation(Interface1.class) + .child(Ipv6.class) + .augmentation(Ipv61.class) + .child(Ipv6RouterAdvertisements.class) + .child(PrefixList.class) + .child(Prefix.class); - private static final String RA_PATH = "/hc2vpp-ietf-routing:routing" + - "/hc2vpp-ietf-routing:routing-instance[hc2vpp-ietf-routing:name='" + INSTANCE_NAME + "']" + - "/hc2vpp-ietf-routing:interfaces" + - "/hc2vpp-ietf-routing:interface[hc2vpp-ietf-routing:name='" + IFC_NAME + "']" + + private static final String RA_PATH = "/ietf-interfaces:interfaces" + + "/ietf-interfaces:interface[ietf-interfaces:name='" + IFC_NAME + "']" + + "/ietf-ip:ipv6" + "/hc2vpp-ietf-ipv6-unicast-routing:ipv6-router-advertisements/hc2vpp-ietf-ipv6-unicast-routing:prefix-list"; private PrefixCustomizer customizer; private NamingContext interfaceContext = new NamingContext("ifaces", CTX_NAME); @Override - protected void setUpTest() throws Exception { + protected void setUpTest() { customizer = new PrefixCustomizer(api, interfaceContext); defineMapping(mappingContext, IFC_NAME, IFC_INDEX, CTX_NAME); when(api.swInterfaceIp6NdRaPrefix(any())).thenReturn(future(new SwInterfaceIp6NdRaPrefixReply())); @@ -80,7 +82,8 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema request.swIfIndex = IFC_INDEX; // 2001:0db8:0a0b:12f0:0000:0000:0000:0002/64 - request.address = new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; + request.address = + new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; request.addressLength = 64; request.valLifetime = 2592000; // default value request.prefLifetime = 604800; // default value @@ -96,7 +99,8 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema request.swIfIndex = IFC_INDEX; // 2001:0db8:0a0b:12f0:0000:0000:0000:0002/64 - request.address = new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; + request.address = + new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; request.addressLength = 64; request.noAdvertise = 1; request.noAutoconfig = 1; @@ -113,7 +117,8 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema final SwInterfaceIp6NdRaPrefix request = new SwInterfaceIp6NdRaPrefix(); request.swIfIndex = IFC_INDEX; // 2001:0db8:0a0b:12f0:0000:0000:0000:0002/64 - request.address = new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; + request.address = + new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; request.addressLength = 64; request.isNo = 1; verify(api).swInterfaceIp6NdRaPrefix(request); @@ -122,4 +127,4 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema private static Prefix getPrefix(final PrefixList prefixList) { return prefixList.getPrefix().get(0); } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizerTest.java index dc7dddbca..7e92d1654 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizerTest.java @@ -31,38 +31,37 @@ import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaConfig; import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaConfigReply; import org.junit.Test; import org.junit.runner.RunWith; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.Interface1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.Ipv6RouterAdvertisements; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.Interfaces; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.Ipv61; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.Ipv6RouterAdvertisements; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @RunWith(HoneycombTestRunner.class) public class RouterAdvertisementsCustomizerTest extends WriterCustomizerTest implements SchemaContextTestHelper { - private static final String INSTANCE_NAME = "tst-protocol"; private static final String CTX_NAME = "interface-context"; private static final String IFC_NAME = "eth0"; private static final int IFC_INDEX = 1; - private static final InstanceIdentifier IID = InstanceIdentifier.create(Routing.class) - .child(RoutingInstance.class, new RoutingInstanceKey(INSTANCE_NAME)).child(Interfaces.class) - .child(Interface.class, new InterfaceKey(IFC_NAME)).augmentation( - Interface1.class).child(Ipv6RouterAdvertisements.class); + private static final InstanceIdentifier IID = InstanceIdentifier + .create(Interfaces.class) + .child(Interface.class, new InterfaceKey(IFC_NAME)) + .augmentation(Interface1.class) + .child(Ipv6.class) + .augmentation(Ipv61.class) + .child(Ipv6RouterAdvertisements.class); - private static final String RA_PATH = "/hc2vpp-ietf-routing:routing" + - "/hc2vpp-ietf-routing:routing-instance[hc2vpp-ietf-routing:name='" + INSTANCE_NAME + "']" + - "/hc2vpp-ietf-routing:interfaces"; + private static final String RA_PATH = "/ietf-interfaces:interfaces"; private RouterAdvertisementsCustomizer customizer; private NamingContext interfaceContext = new NamingContext("ifaces", CTX_NAME); @Override - protected void setUpTest() throws Exception { + protected void setUpTest() { customizer = new RouterAdvertisementsCustomizer(api, interfaceContext); defineMapping(mappingContext, IFC_NAME, IFC_INDEX, CTX_NAME); when(api.swInterfaceIp6NdRaConfig(any())).thenReturn(future(new SwInterfaceIp6NdRaConfigReply())); @@ -106,6 +105,11 @@ public class RouterAdvertisementsCustomizerTest extends WriterCustomizerTest imp } private static Ipv6RouterAdvertisements getRA(final Interfaces ifc) { - return ifc.getInterface().get(0).getAugmentation(Interface1.class).getIpv6RouterAdvertisements(); + return ifc.getInterface() + .get(0) + .getAugmentation(Interface1.class) + .getIpv6() + .getAugmentation(Ipv61.class) + .getIpv6RouterAdvertisements(); } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java deleted file mode 100644 index 2e073d726..000000000 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.fd.hc2vpp.routing.write; - -import static org.junit.Assert.fail; -import static org.mockito.Mockito.when; - -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; -import io.fd.hc2vpp.routing.RoutingConfiguration; -import org.junit.Test; -import org.mockito.Mock; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class RoutingInstanceCustomizerTest extends WriterCustomizerTest { - - private static final String VALID_NAME = "valid-name"; - private static final String INVALID_NAME = "invalid-name"; - - @Mock - private RoutingConfiguration configuration; - - private RoutingInstanceCustomizer customizer; - private InstanceIdentifier id; - - private RoutingInstance validData; - private RoutingInstance invalidData; - - @Override - protected void setUpTest() throws Exception { - customizer = new RoutingInstanceCustomizer(configuration); - - when(configuration.getDefaultRoutingInstanceName()).thenReturn(VALID_NAME); - - id = InstanceIdentifier.create(RoutingInstance.class); - validData = new RoutingInstanceBuilder().setName(VALID_NAME).build(); - invalidData = new RoutingInstanceBuilder().setName(INVALID_NAME).build(); - } - - @Test - public void writeCurrentAttributesValid() throws Exception { - try { - customizer.writeCurrentAttributes(id, validData, writeContext); - } catch (Exception e) { - fail("Test should passed without exception"); - } - } - - @Test(expected = IllegalArgumentException.class) - public void writeCurrentAttributesInvalid() throws Exception { - customizer.writeCurrentAttributes(id, invalidData, writeContext); - } - - @Test(expected = UnsupportedOperationException.class) - public void updateCurrentAttributes() throws Exception { - customizer.updateCurrentAttributes(id, validData, validData, writeContext); - } - - @Test - public void deleteCurrentAttributesValid() throws Exception { - try { - customizer.deleteCurrentAttributes(id, validData, writeContext); - } catch (Exception e) { - fail("Test should passed without exception"); - } - } - - @Test(expected = IllegalArgumentException.class) - public void deleteCurrentAttributesInvalid() throws Exception { - customizer.deleteCurrentAttributes(id, invalidData, writeContext); - } - -} \ No newline at end of file diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizerTest.java deleted file mode 100644 index 608e727e5..000000000 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizerTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2017 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.write; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -import com.google.common.base.Optional; -import io.fd.honeycomb.translate.write.WriteContext; -import io.fd.honeycomb.translate.write.WriteFailedException; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.Interfaces; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.InterfaceKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; - -public class RoutingInterfaceCustomizerTest { - private static final String IFC_NAME = "eth0"; - - @Mock - private WriteContext ctx; - private RoutingInterfaceCustomizer customizer; - - @Before - public final void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - customizer = new RoutingInterfaceCustomizer(); - - when(ctx.readAfter(any())).thenReturn(Optional.absent()); - final KeyedInstanceIdentifier - id = InstanceIdentifier.create( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces.class) - .child( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface.class, - new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey( - IFC_NAME)); - when(ctx.readAfter(id)).thenReturn(Optional.of(mock(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface.class))); - } - - @Test(expected = IllegalArgumentException.class) - public void testWriteIfcNotConfigured() throws WriteFailedException { - final String nonExistingIfcName = "someIfc"; - final Interface ifc = mock(Interface.class); - when(ifc.getName()).thenReturn(nonExistingIfcName); - customizer.writeCurrentAttributes(getId(nonExistingIfcName), ifc, ctx); - } - - @Test - public void testUpdate() throws WriteFailedException { - final Interface ifc = mock(Interface.class); - when(ifc.getName()).thenReturn(IFC_NAME); - customizer.updateCurrentAttributes(getId(IFC_NAME), ifc, ifc, ctx); - } - - @Test - public void testDelete() throws WriteFailedException { - final Interface ifc = mock(Interface.class); - when(ifc.getName()).thenReturn(IFC_NAME); - customizer.deleteCurrentAttributes(getId(IFC_NAME), ifc, ctx); - verifyZeroInteractions(ctx); - } - - private InstanceIdentifier getId(final String ifcName) { - return InstanceIdentifier.create(Routing.class) - .child(RoutingInstance.class, new RoutingInstanceKey("routingInstance")).child(Interfaces.class) - .child(Interface.class, new InterfaceKey(ifcName)); - } -} \ No newline at end of file diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java deleted file mode 100644 index c283ac726..000000000 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.write; - -import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME; -import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME_2; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.honeycomb.translate.write.WriteFailedException; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Direct; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Static; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolVppAttr; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolVppAttrBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol.VppProtocolAttributesBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class RoutingProtocolCustomizerTest extends WriterCustomizerTest { - - private InstanceIdentifier validId; - private RoutingProtocol validData; - private RoutingProtocol validData2; - private RoutingProtocol invalidData; - private RoutingProtocolCustomizer customizer; - private NamingContext routingProtocolContext; - - @Before - public void init() { - validId = InstanceIdentifier.create(RoutingProtocol.class); - validData = new RoutingProtocolBuilder() - .setName(ROUTE_PROTOCOL_NAME) - .setType(Static.class) - .addAugmentation(RoutingProtocolVppAttr.class, new RoutingProtocolVppAttrBuilder() - .setVppProtocolAttributes(new VppProtocolAttributesBuilder() - .setPrimaryVrf(new VniReference(1L)) - .build()) - .build()) - .build(); - - validData2= new RoutingProtocolBuilder() - .setName(ROUTE_PROTOCOL_NAME_2) - .setType(Static.class) - .addAugmentation(RoutingProtocolVppAttr.class, new RoutingProtocolVppAttrBuilder() - .setVppProtocolAttributes(new VppProtocolAttributesBuilder() - .setPrimaryVrf(new VniReference(1L)) - .build()) - .build()) - .build(); - - invalidData = new RoutingProtocolBuilder() - .setType(Direct.class) - .build(); - - routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context"); - customizer = new RoutingProtocolCustomizer(routingProtocolContext); - } - - @Test - public void testWriteIsStatic() throws WriteFailedException { - noMappingDefined(mappingContext, ROUTE_PROTOCOL_NAME, "routing-protocol-context"); - try { - customizer.writeCurrentAttributes(validId, validData, writeContext); - } catch (Exception e) { - fail("Test should have passed without throwing exception"); - } - } - - /** - * Should not fail, just ignore re-mapping same name - * */ - @Test - public void testWriteIsStaticSameAllreadyExist() throws WriteFailedException { - defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); - try { - customizer.writeCurrentAttributes(validId, validData, writeContext); - } catch (Exception e) { - fail("Test should have passed without throwing exception"); - } - } - - /** - * Should fail, because of attempt to map different name to same index - * */ - @Test - public void testWriteIsStaticOtherAllreadyExist() throws WriteFailedException { - defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); - try { - customizer.writeCurrentAttributes(validId, validData2, writeContext); - } catch (Exception e) { - assertTrue(e instanceof IllegalStateException); - return; - } - fail("Test should have thrown exception"); - } - - @Test - public void testWriteIsntStatic() throws WriteFailedException { - try { - customizer.writeCurrentAttributes(validId, invalidData, writeContext); - } catch (Exception e) { - assertTrue(e instanceof IllegalArgumentException); - return; - } - fail("Test should have thrown exception"); - } - - @Test(expected = UnsupportedOperationException.class) - public void testUpdate() throws WriteFailedException { - customizer.updateCurrentAttributes(validId, validData, validData, writeContext); - } -} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java index a17dfa3fb..b4ec3d91d 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java @@ -16,7 +16,6 @@ package io.fd.hc2vpp.routing.write.factory; - import static org.junit.Assert.assertEquals; import io.fd.hc2vpp.common.translate.util.NamingContext; @@ -36,10 +35,11 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +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.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class MultipathHopRequestFactoryIpv4Test @@ -85,26 +85,32 @@ public class MultipathHopRequestFactoryIpv4Test defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context"); defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); - ipv4MutlipathRouteWithClassifier = getIpv4RouteWithId(ipv4StaticRoutesWithClassifier, 1L); + ipv4MutlipathRouteWithClassifier = getIpv4RouteWithId(ipv4StaticRoutesWithClassifier, + new Ipv4Prefix("192.168.2.1/24")); final List ipv4HopsClassified = - NextHopList.class.cast(ipv4MutlipathRouteWithClassifier.getNextHopOptions()).getNextHopList() - .getNextHop(); + NextHopList.class.cast(ipv4MutlipathRouteWithClassifier.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop(); ipv4nextHopWithClassifier = - ipv4HopsClassified.stream().filter(nextHop -> nextHop.getId() == 1L).findFirst().get(); + ipv4HopsClassified.stream().filter(nextHop -> Integer.valueOf(nextHop.getIndex()) == 1L) + .findFirst().get(); - ipv4MutlipathRouteWithoutClassifier = getIpv4RouteWithId(ipv4StaticRoutesWithoutClassifier, 1L); + ipv4MutlipathRouteWithoutClassifier = getIpv4RouteWithId(ipv4StaticRoutesWithoutClassifier, + new Ipv4Prefix("192.168.2.1/24")); final List ipv4HopsNonClassified = - NextHopList.class.cast(ipv4MutlipathRouteWithoutClassifier.getNextHopOptions()).getNextHopList() - .getNextHop(); + NextHopList.class.cast(ipv4MutlipathRouteWithoutClassifier.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop(); ipv4nextHopWithoutClassifier = - ipv4HopsNonClassified.stream().filter(nextHop -> nextHop.getId() == 1L).findFirst().get(); + ipv4HopsNonClassified.stream().filter(nextHop -> Integer.valueOf(nextHop.getIndex()) == 1L) + .findFirst().get(); - ipv4MutlipathRouteWithoutRouteAtts = getIpv4RouteWithId(ipv4StaticRoutesWithoutRouteAttrs, 1L); + ipv4MutlipathRouteWithoutRouteAtts = getIpv4RouteWithId(ipv4StaticRoutesWithoutRouteAttrs, + new Ipv4Prefix("192.168.2.1/24")); final List ipv4HopsNonRouteAttrs = - NextHopList.class.cast(ipv4MutlipathRouteWithoutRouteAtts.getNextHopOptions()).getNextHopList() - .getNextHop(); + NextHopList.class.cast(ipv4MutlipathRouteWithoutRouteAtts.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop(); ipv4nextHopWithoutRouteAtts = - ipv4HopsNonClassified.stream().filter(nextHop -> nextHop.getId() == 1L).findFirst().get(); + ipv4HopsNonClassified.stream().filter(nextHop -> Integer.valueOf(nextHop.getIndex()) == 1L) + .findFirst().get(); } @Test diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java index 50bd106ed..50ada6ef3 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java @@ -35,10 +35,11 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class MultipathHopRequestFactoryIpv6Test @@ -78,22 +79,26 @@ public class MultipathHopRequestFactoryIpv6Test defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context"); defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); - ipv6MultipathRouteWithClassifier = getIpv6RouteWithId(ipv6StaticRoutesWithClassifier, 1L); - ipv6MultipathRouteWithoutClassifier = getIpv6RouteWithId(ipv6StaticRoutesWithoutClassifier, 1L); + ipv6MultipathRouteWithClassifier = + getIpv6RouteWithId(ipv6StaticRoutesWithClassifier, + new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64")); + ipv6MultipathRouteWithoutClassifier = + getIpv6RouteWithId(ipv6StaticRoutesWithoutClassifier, + new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64")); final List ipv6HopsClassified = - NextHopList.class.cast(ipv6MultipathRouteWithClassifier.getNextHopOptions()).getNextHopList() - .getNextHop(); + NextHopList.class.cast(ipv6MultipathRouteWithClassifier.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop(); final List ipv6HopsNonClassified = - NextHopList.class.cast(ipv6MultipathRouteWithoutClassifier.getNextHopOptions()).getNextHopList() - .getNextHop(); + NextHopList.class.cast(ipv6MultipathRouteWithoutClassifier.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop(); ipv6nextHopForClassified = ipv6HopsClassified.stream() - .filter(nextHop -> nextHop.getId() == 1L) + .filter(nextHop -> Integer.valueOf(nextHop.getIndex()) == 1L) .findFirst().get(); ipv6nextHopForNonClassified = ipv6HopsNonClassified.stream() - .filter(nextHop -> nextHop.getId() == 1L) + .filter(nextHop -> Integer.valueOf(nextHop.getIndex()) == 1L) .findFirst().get(); } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java index 15951f48e..6457feba2 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java @@ -34,8 +34,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +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.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class SimpleHopRequestFactoryIpv4Test @@ -66,10 +67,10 @@ public class SimpleHopRequestFactoryIpv4Test @Test public void testIpv4WithClassifier( @InjectTestData(resourcePath = "/ipv4/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) - StaticRoutes ipv4StaticRouteWithClassifier) { + StaticRoutes ipv4StaticRouteWithClassifier) { final IpAddDelRoute request = factory.createIpv4SimpleHopRequest(false, ROUTE_PROTOCOL_NAME, - getIpv4RouteWithId(ipv4StaticRouteWithClassifier, 1L), + getIpv4RouteWithId(ipv4StaticRouteWithClassifier, new Ipv4Prefix("192.168.2.1/24")), mappingContext); assertEquals(desiredFlaglessResult(0, 0, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, @@ -88,7 +89,8 @@ public class SimpleHopRequestFactoryIpv4Test assertEquals( desiredFlaglessResult(0, 0, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, - Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 0, 0, 0), request); + Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 0, 0, 0), + request); } @Test @@ -102,6 +104,7 @@ public class SimpleHopRequestFactoryIpv4Test assertEquals( desiredFlaglessResult(0, 0, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, - Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 0, 0, 0), request); + Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 0, 0, 0), + request); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java index c50a14ab4..eadb3995d 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java @@ -34,8 +34,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class SimpleHopRequestFactoryIpv6Test diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java index 7fcc77737..bce1b5167 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java @@ -18,9 +18,10 @@ package io.fd.hc2vpp.routing.write.factory; import static io.fd.hc2vpp.routing.write.factory.SpecialNextHopRequestFactory.forContexts; import static org.junit.Assert.assertEquals; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Prohibit; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Receive; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Unreachable; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Blackhole; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Prohibit; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Receive; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Unreachable; import io.fd.hc2vpp.common.test.util.NamingContextHelper; import io.fd.hc2vpp.common.translate.util.NamingContext; @@ -40,10 +41,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +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.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class SpecialNextHopRequestFactoryIpv4Test @@ -52,6 +53,8 @@ public class SpecialNextHopRequestFactoryIpv4Test private static final String PARENT_PROTOCOL_4 = "parent-protocol-4"; private static final int PARENT_PROTOCOL_4_INDEX = 4; + public static final Ipv4Prefix IPV_4_PREFIX = new Ipv4Prefix("192.168.2.1/24"); + public static final int DST_PREFIX = 24; @Mock private VppClassifierContextManager classifierContextManager; @@ -79,12 +82,14 @@ public class SpecialNextHopRequestFactoryIpv4Test @Test public void testIpv4WithClassifierBlackhole( @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) - StaticRoutes routes) { + StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, - SpecialNextHopGrouping.SpecialNextHop.Blackhole); + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, IPV_4_PREFIX), + mappingContext, Blackhole); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 1, 0, 0, 0, + PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), + request); } @Test @@ -92,9 +97,12 @@ public class SpecialNextHopRequestFactoryIpv4Test @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteReceive.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, Receive); + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, IPV_4_PREFIX), + mappingContext, Receive); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 1, 0, 0, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 1, 0, 0, + PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), + request); } @Test @@ -102,9 +110,12 @@ public class SpecialNextHopRequestFactoryIpv4Test @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteUnreachable.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, Unreachable); + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, IPV_4_PREFIX), + mappingContext, Unreachable); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 1, 0, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 0, 1, 0, + PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), + request); } @Test @@ -112,14 +123,17 @@ public class SpecialNextHopRequestFactoryIpv4Test @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteProhibited.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true,PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, Prohibit); + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, IPV_4_PREFIX), + mappingContext, Prohibit); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 0, 1, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 0, 0, 1, + PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), + request); } - private Route extractSingleRoute(final StaticRoutes staticRoutes, final long id) { + private Route extractSingleRoute(final StaticRoutes staticRoutes, final Ipv4Prefix id) { return staticRoutes.getAugmentation(StaticRoutes1.class).getIpv4().getRoute().stream() - .filter(route -> route.getId() == id) + .filter(route -> route.getDestinationPrefix().getValue().equals(id.getValue())) .collect(RWUtils.singleItemCollector()); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java index 9ebe1145f..4e0a0efd5 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java @@ -18,10 +18,10 @@ package io.fd.hc2vpp.routing.write.factory; import static io.fd.hc2vpp.routing.write.trait.RouteRequestProducer.DEFAULT_VNI; import static org.junit.Assert.assertEquals; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Blackhole; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Prohibit; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Receive; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Unreachable; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Blackhole; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Prohibit; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Receive; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Unreachable; import io.fd.hc2vpp.common.test.util.NamingContextHelper; import io.fd.hc2vpp.common.translate.util.NamingContext; @@ -40,9 +40,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class SpecialNextHopRequestFactoryIpv6Test @@ -50,6 +51,8 @@ public class SpecialNextHopRequestFactoryIpv6Test private static final String PARENT_PROTOCOL_6 = "parent-protocol-6"; private static final int PARENT_PROTOCOL_6_INDEX = 6; + public static final Ipv6Prefix IPV_6_PREFIX = new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64"); + public static final int DST_PREFIX = 64; @Mock private VppClassifierContextManager classifierContextManager; @@ -66,8 +69,10 @@ public class SpecialNextHopRequestFactoryIpv6Test public void init() { MockitoAnnotations.initMocks(this); interfaceContext = new NamingContext("iface", "interface-context"); - routingProtocolContextContext = new NamingContext("routingProtocol", "routing-protocol-context"); - factory = SpecialNextHopRequestFactory.forContexts(classifierContextManager, interfaceContext, routingProtocolContextContext); + routingProtocolContextContext = + new NamingContext("routingProtocol", "routing-protocol-context"); + factory = SpecialNextHopRequestFactory.forContexts(classifierContextManager, interfaceContext, + routingProtocolContextContext); addMapping(classifierContextManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext); defineMapping(mappingContext, PARENT_PROTOCOL_6, PARENT_PROTOCOL_6_INDEX, "routing-protocol-context"); @@ -76,12 +81,14 @@ public class SpecialNextHopRequestFactoryIpv6Test @Test public void testIpv6Blackhole( @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) - StaticRoutes routes) { + StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Blackhole); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, IPV_6_PREFIX), + mappingContext, Blackhole); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), - request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 1, 0, 0, 0, + PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), + request); } @Test @@ -89,9 +96,12 @@ public class SpecialNextHopRequestFactoryIpv6Test @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteReceive.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Receive); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, IPV_6_PREFIX), + mappingContext, Receive); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 1, 0, 0, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 1, 0, 0, + PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), + request); } @Test @@ -99,9 +109,12 @@ public class SpecialNextHopRequestFactoryIpv6Test @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteUnreachable.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Unreachable); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, IPV_6_PREFIX), + mappingContext, Unreachable); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 1, 0, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 0, 1, 0, + PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), + request); } @Test @@ -109,14 +122,17 @@ public class SpecialNextHopRequestFactoryIpv6Test @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteProhibited.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Prohibit); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, IPV_6_PREFIX), + mappingContext, Prohibit); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 0, 1, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 0, 0, 1, + PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), + request); } - private Route extractSingleRoute(final StaticRoutes staticRoutes, final long id) { + private Route extractSingleRoute(final StaticRoutes staticRoutes, final Ipv6Prefix id) { return staticRoutes.getAugmentation(StaticRoutes1.class).getIpv6().getRoute().stream() - .filter(route -> route.getId() == id).collect( + .filter(route -> route.getDestinationPrefix().getValue().equals(id.getValue())).collect( RWUtils.singleItemCollector()); } diff --git a/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithClassifier.json b/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithClassifier.json index 99c987e03..5b4012d83 100644 --- a/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithClassifier.json +++ b/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithClassifier.json @@ -3,29 +3,30 @@ "ipv4": { "route": [ { - "id": 1, "destination-prefix": "192.168.2.1/24", - "vpp-ipv4-route": { + "vpp-v4ur:vpp-ipv4-route": { "classify-table": "classify-table-one" }, - "next-hop-list": { - "next-hop": [ - { - "id": "1", - "address": "192.168.2.1", - "outgoing-interface": "iface", - "weight": "2" - }, - { - "id": "2", - "address": "192.168.2.2", - "outgoing-interface": "iface", - "weight": "3" - } - ] + "next-hop":{ + "next-hop-list": { + "next-hop": [ + { + "index": "1", + "next-hop-address": "192.168.2.1", + "outgoing-interface": "iface", + "weight": "2" + }, + { + "index": "2", + "next-hop-address": "192.168.2.2", + "outgoing-interface": "iface", + "weight": "3" + } + ] + } } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithNoRouteAttrs.json b/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithNoRouteAttrs.json index 71cefa6cb..a509076aa 100644 --- a/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithNoRouteAttrs.json +++ b/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithNoRouteAttrs.json @@ -3,26 +3,27 @@ "ipv4": { "route": [ { - "id": 1, "destination-prefix": "192.168.2.1/24", - "next-hop-list": { - "next-hop": [ - { - "id": "1", - "address": "192.168.2.1", - "outgoing-interface": "iface", - "weight": "2" - }, - { - "id": "2", - "address": "192.168.2.2", - "outgoing-interface": "iface", - "weight": "3" - } - ] + "next-hop": { + "next-hop-list": { + "next-hop": [ + { + "index": "1", + "next-hop-address": "192.168.2.1", + "outgoing-interface": "iface", + "weight": "2" + }, + { + "index": "2", + "next-hop-address": "192.168.2.2", + "outgoing-interface": "iface", + "weight": "3" + } + ] + } } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithoutClassifier.json b/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithoutClassifier.json index d4d4a0693..4c49ba9a8 100644 --- a/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithoutClassifier.json +++ b/routing/routing-impl/src/test/resources/ipv4/multihop/multiHopRouteWithoutClassifier.json @@ -3,28 +3,29 @@ "ipv4": { "route": [ { - "id": 1, "destination-prefix": "192.168.2.1/24", - "vpp-ipv4-route": { + "vpp-v4ur:vpp-ipv4-route": { }, - "next-hop-list": { - "next-hop": [ - { - "id": "1", - "address": "192.168.2.1", - "outgoing-interface": "iface", - "weight": "2" - }, - { - "id": "2", - "address": "192.168.2.2", - "outgoing-interface": "iface", - "weight": "3" - } - ] + "next-hop": { + "next-hop-list": { + "next-hop": [ + { + "index": "1", + "next-hop-address": "192.168.2.1", + "outgoing-interface": "iface", + "weight": "2" + }, + { + "index": "2", + "next-hop-address": "192.168.2.2", + "outgoing-interface": "iface", + "weight": "3" + } + ] + } } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteNoRouteAttrs.json b/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteNoRouteAttrs.json index d987bb6b1..b28ff6e9b 100644 --- a/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteNoRouteAttrs.json +++ b/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteNoRouteAttrs.json @@ -3,10 +3,11 @@ "ipv4": { "route": [ { - "id": 1, "destination-prefix": "192.168.2.1/24", - "next-hop": "192.168.2.2", - "outgoing-interface": "iface" + "next-hop": { + "next-hop-address" : "192.168.2.2", + "outgoing-interface": "iface" + } } ] } diff --git a/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteWithClassifier.json b/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteWithClassifier.json index d00d9a06a..369ddd828 100644 --- a/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteWithClassifier.json +++ b/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteWithClassifier.json @@ -3,13 +3,14 @@ "ipv4": { "route": [ { - "id": 1, "destination-prefix": "192.168.2.1/24", - "vpp-ipv4-route": { - "classify-table": "classify-table-one" + "next-hop": { + "next-hop-address" : "192.168.2.2", + "outgoing-interface": "iface" }, - "next-hop": "192.168.2.2", - "outgoing-interface": "iface" + "vpp-ipv4-route" : { + "classify-table": "classify-table-one" + } } ] } diff --git a/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteWithoutClassifier.json b/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteWithoutClassifier.json index 0ef7cf765..9080943c8 100644 --- a/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteWithoutClassifier.json +++ b/routing/routing-impl/src/test/resources/ipv4/simplehop/simpleHopRouteWithoutClassifier.json @@ -3,12 +3,13 @@ "ipv4": { "route": [ { - "id": 1, "destination-prefix": "192.168.2.1/24", - "vpp-ipv4-route": { + "next-hop": { + "next-hop-address" : "192.168.2.2", + "outgoing-interface": "iface" }, - "next-hop": "192.168.2.2", - "outgoing-interface": "iface" + "vpp-v4ur:vpp-ipv4-route": { + } } ] } diff --git a/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteBlackhole.json b/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteBlackhole.json index b2ddc238b..04972478e 100644 --- a/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteBlackhole.json +++ b/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteBlackhole.json @@ -3,9 +3,10 @@ "ipv4": { "route": [ { - "id": 1, "destination-prefix": "192.168.2.1/24", - "special-next-hop": "blackhole" + "next-hop": { + "special-next-hop-enum": "blackhole" + } } ] } diff --git a/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteProhibited.json b/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteProhibited.json index fe9faf44c..cee2e1977 100644 --- a/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteProhibited.json +++ b/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteProhibited.json @@ -3,9 +3,10 @@ "ipv4": { "route": [ { - "id": 1, "destination-prefix": "192.168.2.1/24", - "special-next-hop": "prohibit" + "next-hop": { + "special-next-hop-enum": "prohibit" + } } ] } diff --git a/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteReceive.json b/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteReceive.json index c967aa542..8000df11d 100644 --- a/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteReceive.json +++ b/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteReceive.json @@ -3,9 +3,10 @@ "ipv4": { "route": [ { - "id": 1, "destination-prefix": "192.168.2.1/24", - "special-next-hop": "receive" + "next-hop": { + "special-next-hop-enum": "receive" + } } ] } diff --git a/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteUnreachable.json b/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteUnreachable.json index bae467fbd..b52982c47 100644 --- a/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteUnreachable.json +++ b/routing/routing-impl/src/test/resources/ipv4/specialhop/specialHopRouteUnreachable.json @@ -3,11 +3,12 @@ "ipv4": { "route": [ { - "id": 1, "destination-prefix": "192.168.2.1/24", - "special-next-hop": "unreachable" + "next-hop": { + "special-next-hop-enum": "unreachable" + } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithClassifier.json b/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithClassifier.json index c8b1e208e..17fe9d67e 100644 --- a/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithClassifier.json +++ b/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithClassifier.json @@ -3,29 +3,30 @@ "ipv6": { "route": [ { - "id": 1, "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64", "vpp-ipv6-route": { "classify-table": "classify-table-one" }, - "next-hop-list": { - "next-hop": [ - { - "id": "1", - "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", - "outgoing-interface": "iface", - "weight": "2" - }, - { - "id": "2", - "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", - "outgoing-interface": "iface", - "weight": "2" - } - ] + "next-hop": { + "next-hop-list": { + "next-hop": [ + { + "index": "1", + "next-hop-address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", + "outgoing-interface": "iface", + "weight": "2" + }, + { + "index": "2", + "next-hop-address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", + "outgoing-interface": "iface", + "weight": "2" + } + ] + } } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithoutClassifier.json b/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithoutClassifier.json index 2e44ebcf5..612db90c0 100644 --- a/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithoutClassifier.json +++ b/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithoutClassifier.json @@ -3,28 +3,29 @@ "ipv6": { "route": [ { - "id": 1, "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64", "vpp-ipv6-route": { }, - "next-hop-list": { - "next-hop": [ - { - "id": "1", - "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", - "outgoing-interface": "iface", - "weight": "2" - }, - { - "id": "2", - "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", - "outgoing-interface": "iface", - "weight": "2" - } - ] + "next-hop": { + "next-hop-list": { + "next-hop": [ + { + "index": "1", + "next-hop-address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", + "outgoing-interface": "iface", + "weight": "2" + }, + { + "index": "2", + "next-hop-address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", + "outgoing-interface": "iface", + "weight": "2" + } + ] + } } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithoutRouteAttrs.json b/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithoutRouteAttrs.json index f85b1b716..f34084238 100644 --- a/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithoutRouteAttrs.json +++ b/routing/routing-impl/src/test/resources/ipv6/multihop/multiHopRouteWithoutRouteAttrs.json @@ -3,26 +3,27 @@ "ipv6": { "route": [ { - "id": 1, "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64", - "next-hop-list": { - "next-hop": [ - { - "id": "1", - "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", - "outgoing-interface": "iface", - "weight": "2" - }, - { - "id": "2", - "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", - "outgoing-interface": "iface", - "weight": "2" - } - ] + "next-hop": { + "next-hop-list": { + "next-hop": [ + { + "index": "1", + "next-hop-address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", + "outgoing-interface": "iface", + "weight": "2" + }, + { + "index": "2", + "next-hop-address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", + "outgoing-interface": "iface", + "weight": "2" + } + ] + } } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithClassifier.json b/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithClassifier.json index c011a8d01..7f09a590e 100644 --- a/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithClassifier.json +++ b/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithClassifier.json @@ -3,15 +3,16 @@ "ipv6": { "route": [ { - "id": 1, "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64", - "vpp-ipv6-route": { - "classify-table": "classify-table-one" + "next-hop": { + "next-hop-address" : "2001:0db8:0a0b:12f0:0000:0000:0000:0002", + "outgoing-interface": "iface" }, - "next-hop": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", - "outgoing-interface": "iface" + "vpp-ipv6-route" : { + "classify-table": "classify-table-one" + } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithoutClassifier.json b/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithoutClassifier.json index 1cb663ca7..feca92c88 100644 --- a/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithoutClassifier.json +++ b/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithoutClassifier.json @@ -3,14 +3,15 @@ "ipv6": { "route": [ { - "id": 1, "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64", - "vpp-ipv6-route": { + "next-hop": { + "next-hop-address" : "2001:0db8:0a0b:12f0:0000:0000:0000:0002", + "outgoing-interface": "iface" }, - "next-hop": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", - "outgoing-interface": "iface" + "vpp-v6ur:vpp-ipv6-route": { + } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithoutRouteAttrs.json b/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithoutRouteAttrs.json index a735c193c..fd66f2283 100644 --- a/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithoutRouteAttrs.json +++ b/routing/routing-impl/src/test/resources/ipv6/simplehop/simpleHopRouteWithoutRouteAttrs.json @@ -3,12 +3,13 @@ "ipv6": { "route": [ { - "id": 1, "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64", - "next-hop": "2001:0db8:0a0b:12f0:0000:0000:0000:0002", - "outgoing-interface": "iface" + "next-hop": { + "next-hop-address" : "2001:0db8:0a0b:12f0:0000:0000:0000:0002", + "outgoing-interface": "iface" + } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteBlackhole.json b/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteBlackhole.json index 1cc319107..43e8366ff 100644 --- a/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteBlackhole.json +++ b/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteBlackhole.json @@ -3,9 +3,10 @@ "ipv6": { "route": [ { - "id": 1, - "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/24", - "special-next-hop": "blackhole" + "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64", + "next-hop": { + "special-next-hop-enum": "blackhole" + } } ] } diff --git a/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteProhibited.json b/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteProhibited.json index d69e817d7..e8f0a0e2e 100644 --- a/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteProhibited.json +++ b/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteProhibited.json @@ -3,9 +3,10 @@ "ipv6": { "route": [ { - "id": 1, - "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/24", - "special-next-hop": "prohibit" + "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64", + "next-hop": { + "special-next-hop-enum": "prohibit" + } } ] } diff --git a/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteReceive.json b/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteReceive.json index 50d447de0..5296e3f01 100644 --- a/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteReceive.json +++ b/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteReceive.json @@ -3,9 +3,10 @@ "ipv6": { "route": [ { - "id": 1, - "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/24", - "special-next-hop": "receive" + "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64", + "next-hop": { + "special-next-hop-enum": "receive" + } } ] } diff --git a/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteUnreachable.json b/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteUnreachable.json index c874549d1..2d351956d 100644 --- a/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteUnreachable.json +++ b/routing/routing-impl/src/test/resources/ipv6/specialhop/specialHopRouteUnreachable.json @@ -3,11 +3,12 @@ "ipv6": { "route": [ { - "id": 1, - "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/24", - "special-next-hop": "unreachable" + "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64", + "next-hop": { + "special-next-hop-enum": "unreachable" + } } ] } } -} \ No newline at end of file +} diff --git a/routing/routing-impl/src/test/resources/ra/complexRa.json b/routing/routing-impl/src/test/resources/ra/complexRa.json index 05079c656..5e9122354 100644 --- a/routing/routing-impl/src/test/resources/ra/complexRa.json +++ b/routing/routing-impl/src/test/resources/ra/complexRa.json @@ -3,14 +3,16 @@ "interface": [ { "name": "eth0", - "ipv6-router-advertisements": { - "send-advertisements": "true", - "min-rtr-adv-interval": "20", - "max-rtr-adv-interval": "100", - "default-lifetime": "601", - "vpp-routing-ra:suppress-link-layer": "false", - "vpp-routing-ra:initial-count": "2", - "vpp-routing-ra:initial-interval": "15" + "ipv6" :{ + "ipv6-router-advertisements": { + "send-advertisements": "true", + "min-rtr-adv-interval": "20", + "max-rtr-adv-interval": "100", + "default-lifetime": "601", + "vpp-routing-ra:suppress-link-layer": "false", + "vpp-routing-ra:initial-count": "2", + "vpp-routing-ra:initial-interval": "15" + } } } ] diff --git a/routing/routing-impl/src/test/resources/ra/simpleRa.json b/routing/routing-impl/src/test/resources/ra/simpleRa.json index 4a7ce3464..ef81309da 100644 --- a/routing/routing-impl/src/test/resources/ra/simpleRa.json +++ b/routing/routing-impl/src/test/resources/ra/simpleRa.json @@ -3,9 +3,11 @@ "interface": [ { "name": "eth0", - "ipv6-router-advertisements": { - "send-advertisements": "true", - "managed-flag": "true" + "ietf-ip:ipv6": { + "hc2vpp-ietf-ipv6-unicast-routing:ipv6-router-advertisements": { + "send-advertisements": "true", + "managed-flag": "true" + } } } ] diff --git a/routing/routing-impl/src/test/resources/routing.json b/routing/routing-impl/src/test/resources/routing.json index 95f85414f..2da6abc3e 100644 --- a/routing/routing-impl/src/test/resources/routing.json +++ b/routing/routing-impl/src/test/resources/routing.json @@ -1,4 +1,4 @@ { - "default-routing-instance-name": "vpp-routing-instance", + "default-routing-id": "0.0.0.0", "learned-route-name-prefix": "learned-route" -} \ No newline at end of file +} diff --git a/routing/routing_adv_postman_collection.json b/routing/routing_adv_postman_collection.json deleted file mode 100644 index acb2dc1c7..000000000 --- a/routing/routing_adv_postman_collection.json +++ /dev/null @@ -1,201 +0,0 @@ -{ - "id": "a7d15cf2-4a27-a054-f07e-f63f4b3bb919", - "name": "Routing Advertisments", - "description": "Example requests describing how to configure RA using Honeycomb", - "order": [ - "0b83d874-bd02-fe68-f4af-432ffb83f6c5", - "2bd7e446-4623-f3d7-a3ad-e56b0301cf8c", - "d04acc7c-fe95-5a47-7a8c-08fe72db3e93", - "34c30f01-c6f2-ac1c-d2c3-11232906494b", - "68ac1ddf-ec9e-e81b-5eb2-9c57116f02b5", - "76fbfaf3-6725-b4f0-7b80-42c73d7c65a7", - "ac92137a-e9e6-6a2f-ba8b-46f04e72f480", - "8493360f-78eb-45d9-7a82-431325de0bd8", - "96b3f794-030d-21b3-6dc1-f833b61be5e2" - ], - "folders": [], - "timestamp": 1486571916567, - "owner": "567303", - "public": false, - "requests": [ - { - "id": "0b83d874-bd02-fe68-f4af-432ffb83f6c5", - "name": "Enable GigabitEthernet0/8/0", - "dataMode": "raw", - "data": [], - "rawModeData": "{\r\n \r\n \"interface\": [\r\n {\r\n \"name\": \"GigabitEthernet0/8/0\",\r\n \"type\": \"iana-if-type:ethernetCsmacd\",\r\n \"v3po:ethernet\": {\r\n \"mtu\": 9216\r\n },\r\n \"enabled\": true\r\n \r\n }\r\n ]\r\n \r\n}", - "descriptionFormat": null, - "description": "Interface needs to be enabled before configuring RA.", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "method": "PUT", - "pathVariables": {}, - "url": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0", - "preRequestScript": null, - "tests": null, - "currentHelper": "normal", - "helperAttributes": "{}", - "responses": [], - "collectionId": "a7d15cf2-4a27-a054-f07e-f63f4b3bb919" - }, - { - "id": "2bd7e446-4623-f3d7-a3ad-e56b0301cf8c", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6", - "preRequestScript": null, - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "tests": null, - "currentHelper": "normal", - "helperAttributes": "{}", - "time": 1483432018047, - "name": "Add ipv6", - "description": "IP6 needs to be enabled (e.g. by adding ip6 address) before configuring RA.", - "collectionId": "a7d15cf2-4a27-a054-f07e-f63f4b3bb919", - "responses": [], - "rawModeData": "{\r\n \r\n \"ipv6\":{\r\n \"address\":{\r\n \"ip\":\"2001:0db8:0a0b:12f0:0000:0000:0000:0001\",\r\n \"prefix-length\":64\r\n }\r\n \r\n }\r\n}" - }, - { - "id": "34c30f01-c6f2-ac1c-d2c3-11232906494b", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6-router-advertisements/prefix-list/prefix/2001:0db8:0a0b:12f0:0000:0000:0000:0002%2F64", - "preRequestScript": null, - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1486726576152, - "name": "Add prefix1", - "description": "Equivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 prefix 2001:db8:a0b:12f0::2/64 infinite\n\ncan be verified with\n\nvppctl show ip6 interface GigabitEthernet0/8/0", - "collectionId": "a7d15cf2-4a27-a054-f07e-f63f4b3bb919", - "responses": [], - "rawModeData": "{\n\t\"prefix\": [\n\t\t{\n\t\t\t\"prefix-spec\" : \"2001:0db8:0a0b:12f0:0000:0000:0000:0002/64\",\n\t\t\t\"autonomous-flag\" : \"true\",\n\t\t\t \"vpp-routing-ra:advertise-router-address\" : \"true\"\n\t\t}\n\t]\n}" - }, - { - "id": "68ac1ddf-ec9e-e81b-5eb2-9c57116f02b5", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6-router-advertisements/prefix-list/prefix/2002:0db8:0a0b:12f0:0000:0000:0000:0002%2F64", - "preRequestScript": null, - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1486746563556, - "name": "Add prefix2", - "description": "Equivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 prefix 2002:db8:a0b:12f0::2/64 infinite\n\ncan be verified with\n\nvppctl show ip6 interface GigabitEthernet0/8/0", - "collectionId": "a7d15cf2-4a27-a054-f07e-f63f4b3bb919", - "responses": [], - "rawModeData": "{\n\t\"prefix\": [\n\t\t{\n\t\t\t\"prefix-spec\" : \"2002:0db8:0a0b:12f0:0000:0000:0000:0002/64\",\n\t\t\t\"valid-lifetime\" : \"0xffffffff\"\n\t\t}\n\t]\n}" - }, - { - "id": "76fbfaf3-6725-b4f0-7b80-42c73d7c65a7", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6-router-advertisements/prefix-list/prefix/2001:0db8:0a0b:12f0:0000:0000:0000:0002%2F64", - "preRequestScript": null, - "pathVariables": {}, - "method": "DELETE", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": "{}", - "time": 1486571273944, - "name": "Delete prefix1", - "description": "Equivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 no prefix 2001:db8:a0b:12f0::2/64\n\ncan be verified with\n\nvppctl show ip6 interface GigabitEthernet0/8/0", - "collectionId": "a7d15cf2-4a27-a054-f07e-f63f4b3bb919", - "responses": [], - "rawModeData": "" - }, - { - "id": "8493360f-78eb-45d9-7a82-431325de0bd8", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6-router-advertisements", - "preRequestScript": null, - "pathVariables": {}, - "method": "DELETE", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1486572797497, - "name": "Disable RA", - "description": "Suppresses sending RA messages for GigabitEthernet0/8/0\n\nEquivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 ra-suppress", - "collectionId": "a7d15cf2-4a27-a054-f07e-f63f4b3bb919", - "responses": [], - "rawModeData": "" - }, - { - "id": "96b3f794-030d-21b3-6dc1-f833b61be5e2", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/interfaces/interface/GigabitEthernet0%2F8%2F0", - "pathVariables": {}, - "preRequestScript": null, - "method": "GET", - "collectionId": "a7d15cf2-4a27-a054-f07e-f63f4b3bb919", - "data": [], - "dataMode": "raw", - "name": "Read RA config for GigabitEthernet0/8/0", - "description": "", - "descriptionFormat": "html", - "time": 1486746630156, - "version": 2, - "responses": [], - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "rawModeData": "{\n\t\"interface\": [\n\t\t{\n\t\t\t\"name\" : \"GigabitEthernet0/8/0\",\n\t\t\t\"ipv6-router-advertisements\" : {\n\t\t\t\t\"send-advertisements\" : \"true\",\n\t\t\t\t\"min-rtr-adv-interval\" : \"20\",\n\t\t\t\t\"max-rtr-adv-interval\" : \"100\",\n\t\t\t\t\"default-lifetime\" : \"601\",\n\t\t\t\t\"vpp-routing-ra:suppress-link-layer\" : \"false\",\n\t\t\t\t\"vpp-routing-ra:initial-count\" : \"2\",\n\t\t\t\t\"vpp-routing-ra:initial-interval\" : \"15\"\n\t\t\t}\n\t\t}\n\t]\n}" - }, - { - "id": "ac92137a-e9e6-6a2f-ba8b-46f04e72f480", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6-router-advertisements/prefix-list/prefix/2002:0db8:0a0b:12f0:0000:0000:0000:0002%2F64", - "preRequestScript": null, - "pathVariables": {}, - "method": "DELETE", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": "{}", - "time": 1486571321824, - "name": "Delete prefix2", - "description": "Equivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 no prefix 2002:db8:a0b:12f0::2/64\n\ncan be verified with\n\nvppctl show ip6 interface GigabitEthernet0/8/0", - "collectionId": "a7d15cf2-4a27-a054-f07e-f63f4b3bb919", - "responses": [], - "rawModeData": "" - }, - { - "id": "d04acc7c-fe95-5a47-7a8c-08fe72db3e93", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/interfaces/interface/GigabitEthernet0%2F8%2F0", - "preRequestScript": null, - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1486709825728, - "name": "Configure RA", - "description": "Equivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 ra-interval 100 20 ra-lifetime 6001\n\ncan be verified with\n\nvppctl show ip6 interface GigabitEthernet0/8/0", - "collectionId": "a7d15cf2-4a27-a054-f07e-f63f4b3bb919", - "responses": [], - "rawModeData": "{\n\t\"interface\": [\n\t\t{\n\t\t\t\"name\" : \"GigabitEthernet0/8/0\",\n\t\t\t\"ipv6-router-advertisements\" : {\n\t\t\t\t\"send-advertisements\" : \"true\",\n\t\t\t\t\"min-rtr-adv-interval\" : \"20\",\n\t\t\t\t\"max-rtr-adv-interval\" : \"100\",\n\t\t\t\t\"default-lifetime\" : \"601\",\n\t\t\t\t\"vpp-routing-ra:suppress-link-layer\" : \"false\",\n\t\t\t\t\"vpp-routing-ra:initial-count\" : \"2\",\n\t\t\t\t\"vpp-routing-ra:initial-interval\" : \"15\"\n\t\t\t}\n\t\t}\n\t]\n}" - } - ] -} \ No newline at end of file diff --git a/routing/routing_advertisements_postman_collection.json b/routing/routing_advertisements_postman_collection.json new file mode 100755 index 000000000..84e007677 --- /dev/null +++ b/routing/routing_advertisements_postman_collection.json @@ -0,0 +1,409 @@ +{ + "info": { + "_postman_id": "1e67602e-acf4-4487-8173-410d11672369", + "name": "Routing Advertisments", + "description": "Example requests describing how to configure RA using Honeycomb", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Enable GigabitEthernet0/8/0", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"interface\": [\n {\n \"name\": \"GigabitEthernet0/8/0\",\n \"type\": \"iana-if-type:ethernetCsmacd\",\n \"enabled\": true,\n \"v3po:ethernet\": {\n \"mtu\": 9216\n }\n }\n ]\n}" + }, + "url": { + "raw": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8183", + "path": [ + "restconf", + "config", + "ietf-interfaces:interfaces", + "interface", + "GigabitEthernet0%2F8%2F0" + ] + }, + "description": "Interface needs to be enabled before configuring RA." + }, + "response": [] + }, + { + "name": "Add ipv6", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \r\n \"ipv6\":{\r\n \"address\":{\r\n \"ip\":\"2001:0db8:0a0b:12f0:0000:0000:0000:0001\",\r\n \"prefix-length\":64\r\n }\r\n \r\n }\r\n}" + }, + "url": { + "raw": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8183", + "path": [ + "restconf", + "config", + "ietf-interfaces:interfaces", + "interface", + "GigabitEthernet0%2F8%2F0", + "ipv6" + ] + }, + "description": "IP6 needs to be enabled (e.g. by adding ip6 address) before configuring RA." + }, + "response": [] + }, + { + "name": "Configure RA", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"ipv6-router-advertisements\" : {\n\t\t\"send-advertisements\" : \"true\",\n\t\t\"min-rtr-adv-interval\" : \"20\",\n\t\t\"max-rtr-adv-interval\" : \"100\",\n\t\t\"default-lifetime\" : \"601\",\n\t\t\"vpp-routing-ra:suppress-link-layer\" : \"false\",\n\t\t\"vpp-routing-ra:initial-count\" : \"2\",\n\t\t\"vpp-routing-ra:initial-interval\" : \"15\"\n\t}\n}" + }, + "url": { + "raw": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6/ipv6-router-advertisements/", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8183", + "path": [ + "restconf", + "config", + "ietf-interfaces:interfaces", + "interface", + "GigabitEthernet0%2F8%2F0", + "ipv6", + "ipv6-router-advertisements", + "" + ] + }, + "description": "Equivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 ra-interval 100 20 ra-lifetime 6001\n\ncan be verified with\n\nvppctl show ip6 interface GigabitEthernet0/8/0" + }, + "response": [] + }, + { + "name": "Add prefix1", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"prefix\": [\n\t\t{\n\t\t\t\"prefix-spec\" : \"2001:0db8:0a0b:12f0:0000:0000:0000:0002/64\",\n\t\t\t\"autonomous-flag\" : \"true\",\n\t\t\t \"vpp-routing-ra:advertise-router-address\" : \"true\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6/ipv6-router-advertisements/prefix-list/prefix/2001:0db8:0a0b:12f0:0000:0000:0000:0002%2F64", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8183", + "path": [ + "restconf", + "config", + "ietf-interfaces:interfaces", + "interface", + "GigabitEthernet0%2F8%2F0", + "ipv6", + "ipv6-router-advertisements", + "prefix-list", + "prefix", + "2001:0db8:0a0b:12f0:0000:0000:0000:0002%2F64" + ] + }, + "description": "Equivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 prefix 2001:db8:a0b:12f0::2/64 infinite\n\ncan be verified with\n\nvppctl show ip6 interface GigabitEthernet0/8/0" + }, + "response": [] + }, + { + "name": "Add prefix2", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"prefix\": [\n\t\t{\n\t\t\t\"prefix-spec\" : \"2002:0db8:0a0b:12f0:0000:0000:0000:0002/64\",\n\t\t\t\"valid-lifetime\" : \"0xffffffff\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6/ipv6-router-advertisements/prefix-list/prefix/2002:0db8:0a0b:12f0:0000:0000:0000:0002%2F64", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8183", + "path": [ + "restconf", + "config", + "ietf-interfaces:interfaces", + "interface", + "GigabitEthernet0%2F8%2F0", + "ipv6", + "ipv6-router-advertisements", + "prefix-list", + "prefix", + "2002:0db8:0a0b:12f0:0000:0000:0000:0002%2F64" + ] + }, + "description": "Equivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 prefix 2002:db8:a0b:12f0::2/64 infinite\n\ncan be verified with\n\nvppctl show ip6 interface GigabitEthernet0/8/0" + }, + "response": [] + }, + { + "name": "Delete prefix1", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6/ipv6-router-advertisements/prefix-list/prefix/2001:0db8:0a0b:12f0:0000:0000:0000:0002%2F64", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8183", + "path": [ + "restconf", + "config", + "ietf-interfaces:interfaces", + "interface", + "GigabitEthernet0%2F8%2F0", + "ipv6", + "ipv6-router-advertisements", + "prefix-list", + "prefix", + "2001:0db8:0a0b:12f0:0000:0000:0000:0002%2F64" + ] + }, + "description": "Equivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 no prefix 2001:db8:a0b:12f0::2/64\n\ncan be verified with\n\nvppctl show ip6 interface GigabitEthernet0/8/0" + }, + "response": [] + }, + { + "name": "Delete prefix2", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6/ipv6-router-advertisements/prefix-list/prefix/2002:0db8:0a0b:12f0:0000:0000:0000:0002%2F64", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8183", + "path": [ + "restconf", + "config", + "ietf-interfaces:interfaces", + "interface", + "GigabitEthernet0%2F8%2F0", + "ipv6", + "ipv6-router-advertisements", + "prefix-list", + "prefix", + "2002:0db8:0a0b:12f0:0000:0000:0000:0002%2F64" + ] + }, + "description": "Equivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 no prefix 2002:db8:a0b:12f0::2/64\n\ncan be verified with\n\nvppctl show ip6 interface GigabitEthernet0/8/0" + }, + "response": [] + }, + { + "name": "Disable RA", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6/ipv6-router-advertisements/", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8183", + "path": [ + "restconf", + "config", + "ietf-interfaces:interfaces", + "interface", + "GigabitEthernet0%2F8%2F0", + "ipv6", + "ipv6-router-advertisements", + "" + ] + }, + "description": "Suppresses sending RA messages for GigabitEthernet0/8/0\n\nEquivalent of\n\nvppctl ip6 nd GigabitEthernet0/8/0 ra-suppress" + }, + "response": [] + }, + { + "name": "Read RA config for GigabitEthernet0/8/0", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"interface\": [\n\t\t{\n\t\t\t\"name\" : \"GigabitEthernet0/8/0\",\n\t\t\t\"ipv6-router-advertisements\" : {\n\t\t\t\t\"send-advertisements\" : \"true\",\n\t\t\t\t\"min-rtr-adv-interval\" : \"20\",\n\t\t\t\t\"max-rtr-adv-interval\" : \"100\",\n\t\t\t\t\"default-lifetime\" : \"601\",\n\t\t\t\t\"vpp-routing-ra:suppress-link-layer\" : \"false\",\n\t\t\t\t\"vpp-routing-ra:initial-count\" : \"2\",\n\t\t\t\t\"vpp-routing-ra:initial-interval\" : \"15\"\n\t\t\t}\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0/ipv6/ipv6-router-advertisements/", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8183", + "path": [ + "restconf", + "config", + "ietf-interfaces:interfaces", + "interface", + "GigabitEthernet0%2F8%2F0", + "ipv6", + "ipv6-router-advertisements", + "" + ] + } + }, + "response": [] + }, + { + "name": "Read GigabitEthernet0/8/0", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"interface\": [\n\t\t{\n\t\t\t\"name\" : \"GigabitEthernet0/8/0\",\n\t\t\t\"ipv6-router-advertisements\" : {\n\t\t\t\t\"send-advertisements\" : \"true\",\n\t\t\t\t\"min-rtr-adv-interval\" : \"20\",\n\t\t\t\t\"max-rtr-adv-interval\" : \"100\",\n\t\t\t\t\"default-lifetime\" : \"601\",\n\t\t\t\t\"vpp-routing-ra:suppress-link-layer\" : \"false\",\n\t\t\t\t\"vpp-routing-ra:initial-count\" : \"2\",\n\t\t\t\t\"vpp-routing-ra:initial-interval\" : \"15\"\n\t\t\t}\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "http://localhost:8183/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0/", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8183", + "path": [ + "restconf", + "config", + "ietf-interfaces:interfaces", + "interface", + "GigabitEthernet0%2F8%2F0", + "" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/routing/routing_postman_collection.json b/routing/routing_postman_collection.json old mode 100644 new mode 100755 index 2838dae8a..de9a02e2c --- a/routing/routing_postman_collection.json +++ b/routing/routing_postman_collection.json @@ -1,242 +1,869 @@ { - "id": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "name": "Routing", - "description": "", - "order": [ - "c5701b6a-a684-0a4f-9991-6f1a866baddd", - "e8216de3-757d-ce34-87e4-8e25ee6b1f44", - "e3510e60-17e7-887b-6a55-5e0f651512b0", - "2bf3def8-ef34-fa83-0789-ecebb03f297f", - "ea4e8b3d-2333-6c17-1da2-32fd0b88da96", - "86b915a1-f85c-939a-0814-fd98b1154162", - "41585a9d-5067-05d8-2dc1-3ace153a70b6", - "6244bd7f-dedd-bd6d-45c3-00b0fd10bb21", - "260fce67-2d84-8557-ff03-b4371fc62cdb", - "c50cc4a4-a760-f91a-fe66-dd8a66d6085b", - "de73785a-6784-b280-a9bc-6d6e48199f09" - ], - "folders": [], - "timestamp": 1476089780702, - "owner": "658985", - "public": false, - "requests": [ + "info": { + "_postman_id": "926b89ec-267c-68e1-a4ba-0373a956f692", + "name": "Routing", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ { - "id": "260fce67-2d84-8557-ff03-b4371fc62cdb", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing", - "preRequestScript": null, - "pathVariables": {}, - "method": "GET", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1476096572969, - "name": "Get Routes", - "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\n\t\"routing-instance\":\n\t{\n\t\t\"name\":\"routing-1\",\n\t\t\"enabled\":\"true\",\n\t\t\"router-id\":\"192.168.2.1\",\n\t\t\"description\":\"Test routing instance\",\n\t\t\"routing-protocols\":{\n\t\t\t\"routing-protocol\":[\n\t\t\t\t{\n\t\t\t\t\t\"name\":\"test-routing-protocol\",\n\t\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\t\"enabled\":\"true\",\n\t\t\t\t\t\"type\":\"static\",\n\t\t\t\t\t\"static-routes\":{\n\t\t\t\t\t\t\"ipv4\":{\n\t\t\t\t\t\t\t\"route\":[\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"id\":1,\n\t\t\t\t\t\t\t\t\t\"description\":\"Test static route\",\n\t\t\t\t\t\t\t\t\t\"destination-prefix\":\"192.168.2.3/32\",\n\t\t\t\t\t\t\t\t\t\"next-hop\":\"192.168.2.8\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\t\n\t\t\t]\n\t\t}\n\t}\t\n}" - }, - { - "id": "2bf3def8-ef34-fa83-0789-ecebb03f297f", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/routing-protocols/routing-protocol/test-routing-protocol-2", - "preRequestScript": null, - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1480502653953, - "name": "Add multi hop ipv4", - "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\n\t\"routing-protocol\":[\n\t\t{\n\t\t\t\"name\":\"test-routing-protocol-2\",\n\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\"enabled\":\"true\",\n\t\t\t\"type\":\"static\",\n\t\t\t\"vpp-protocol-attributes\": {\n\t \"primary-vrf\": \"2\"\n },\n\t\t\t\"static-routes\":{\n\t\t\t\t\"ipv4\":{\n\t\t\t\t\t\"route\":{\n\t\t\t\t\t\t\t\"id\":2,\n\t\t\t\t\t\t\t\"description\":\"Test static route multi hop ipv4\",\n\t\t\t\t\t\t\t\"destination-prefix\":\"192.168.2.4/32\",\n\t\t\t\t\t\t\t\"vpp-ipv4-route\":{\n\t\t\t\t\t\t\t\t\"secondary-vrf\":2\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"next-hop-list\":{\n\t\t\t\t\t\t\t\t\"next-hop\":[\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"id\":\"1\",\n\t\t\t\t\t\t\t\t\t\"address\":\"192.168.2.5\",\n\t\t\t\t\t\t\t\t\t\"outgoing-interface\":\"local0\",\n\t\t\t\t\t\t\t\t\t\"weight\":\"1\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"id\":\"2\",\n\t\t\t\t\t\t\t\t\t\"address\":\"192.168.2.6\",\n\t\t\t\t\t\t\t\t\t\"outgoing-interface\":\"local0\",\n\t\t\t\t\t\t\t\t\t\"weight\":\"2\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}\n" - }, - { - "id": "41585a9d-5067-05d8-2dc1-3ace153a70b6", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/routing-protocols/routing-protocol/test-routing-protocol-5", - "preRequestScript": null, - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1480502689477, - "name": "Add multi hop ipv6", + "name": "IPv4", "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\n\t\"routing-protocol\":[\n\t\t{\n\t\t\t\"name\":\"test-routing-protocol-5\",\n\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\"enabled\":\"true\",\n\t\t\t\"type\":\"static\",\n\t\t\t\"vpp-protocol-attributes\": {\n\t \"primary-vrf\": \"5\"\n },\n\t\t\t\"static-routes\":{\n\t\t\t\t\"ipv6\":{\n\t\t\t\t\t\"route\":{\n\t\t\t\t\t\t\t\"id\":2,\n\t\t\t\t\t\t\t\"description\":\"Test static route multi hop ipv6\",\n\t\t\t\t\t\t\t\"destination-prefix\":\"2001:0db8:0a0b:12f0:0000:0000:0000:0001/64\",\n\t\t\t\t\t\t\t\"vpp-ipv6-route\":{\n\t\t\t\t\t\t\t\t\"secondary-vrf\":\"1\"\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"next-hop-list\":{\n\t\t\t\t\t\t\t\t\"next-hop\":[\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"id\":\"1\",\n\t\t\t\t\t\t\t\t\t\"address\":\"2001:0db8:0a0b:12f0:0000:0000:0000:0002\",\n\t\t\t\t\t\t\t\t\t\"outgoing-interface\":\"local0\",\n\t\t\t\t\t\t\t\t\t\"weight\":\"1\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"id\":\"2\",\n\t\t\t\t\t\t\t\t\t\"address\":\"2001:0db8:0a0b:12f0:0000:0000:0000:0003\",\n\t\t\t\t\t\t\t\t\t\"outgoing-interface\":\"local0\",\n\t\t\t\t\t\t\t\t\t\"weight\":\"2\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}\n" + "item": [ + { + "name": "SimpleNextHop", + "description": "", + "item": [ + { + "name": "Add single hop ipv4", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"routing\": {\n\t\t\"control-plane-protocols\": {\n\t\t\t\"control-plane-protocol\": [\n\t\t\t{\n\t\t\t\t\"type\": \"static\",\n\t\t\t\t\"name\": \"test-routing-protocol-1\",\n\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\"vpp-protocol-attributes\": {\n \t\"primary-vrf\": \"1\"\n\t },\n\t \t\t\"static-routes\":{\n\t \t\t\t\"ipv4\":{\n\t \t\t\t\t\"route\":[\n\t\t\t {\n\t\t\t \t\"description\":\"Test static route single hop ipv4\",\n\t\t\t \"destination-prefix\":\"192.168.2.3/32\",\n\t\t\t \"next-hop\": {\n\t\t\t \t\"next-hop-address\" : \"192.168.2.8\",\n \t\t\t\t\t\"outgoing-interface\": \"local0\"\n\t\t\t },\n\t\t\t \"vpp-ipv4-route\":{\n\t\t\t \t\"classify-table\":\"1\"\n\t\t\t \t}\n\t\t\t }\n\t\t\t ]\n\t\t\t }\n\t \t\t}\n\t\t\t}\t\t\t\n\t\t\t]\n\t\t}\n\t}\n}" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/" + }, + "response": [] + }, + { + "name": "get single hop ipv4", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.2.3%2F32" + }, + "response": [] + }, + { + "name": "get single hop ipv4 Operational", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/operational/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.2.3%2F32" + }, + "response": [] + }, + { + "name": "delete single hop ipv4", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.2.3%2F32" + }, + "response": [] + } + ], + "_postman_isSubFolder": true + }, + { + "name": "MultiNextHop", + "description": "", + "item": [ + { + "name": "Add multi hop ipv4", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"routing\": {\n\t\t\"control-plane-protocols\": {\n\t\t\t\"control-plane-protocol\": [\n\t\t\t{\n\t\t\t\t\"type\": \"static\",\n\t\t\t\t\"name\": \"test-routing-protocol-1\",\n\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\"vpp-protocol-attributes\": {\n \t\"primary-vrf\": \"1\"\n\t },\n\t \t\t\"static-routes\": {\n\t\t\t\t \"ipv4\": {\n\t\t\t\t \"route\": [\n\t\t\t\t {\n\t\t\t\t \"destination-prefix\": \"192.168.2.1/24\",\n\t\t\t\t \"vpp-v4ur:vpp-ipv4-route\": {\n\t\t\t\t \"classify-table\": \"1\"\n\t\t\t\t },\n\t\t\t\t \"next-hop\":{\n\t\t\t\t \t\"next-hop-list\": {\n\t\t\t\t \t\t\"next-hop\": [\n\t\t\t\t \t\t{\n\t\t\t\t \t\t\t\"index\": \"1\",\n\t\t\t\t \t\t\t\"next-hop-address\": \"192.168.2.1\",\n\t\t\t\t \t\t\t\"outgoing-interface\": \"local0\",\n\t\t\t\t \t\t\t\"weight\": \"2\"\n\t\t\t\t \t\t},\n\t\t\t\t \t\t{\n\t\t\t\t\t\t \"index\": \"2\",\n\t\t\t\t\t\t \"next-hop-address\": \"192.168.2.2\",\n\t\t\t\t\t\t \"outgoing-interface\": \"local0\",\n\t\t\t\t\t\t \t\"weight\": \"3\"\n\t\t\t\t \t\t}\n\t\t\t\t \t\t]\n\t\t\t\t \t\t}\n\t\t\t\t \t\t}\n\t\t\t\t \t}\n\t\t\t\t \t]\n\t\t\t\t }\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\t]\n\t\t}\n\t}\n}" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/" + }, + "response": [] + }, + { + "name": "get multi hop ipv4", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.2.1%2F24" + }, + "response": [] + }, + { + "name": "get multi hop ipv4 Operational", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/operational/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.2.1%2F24" + }, + "response": [] + }, + { + "name": "delete multi hop ipv4", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.2.1%2F24" + }, + "response": [] + } + ], + "_postman_isSubFolder": true + }, + { + "name": "SpecialHop", + "description": "", + "item": [ + { + "name": "Add special hop ipv4", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"routing\": {\n\t\t\"control-plane-protocols\": {\n\t\t\t\"control-plane-protocol\": [\n\t\t\t{\n\t\t\t\t\"type\": \"static\",\n\t\t\t\t\"name\": \"test-routing-protocol-1\",\n\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\"vpp-protocol-attributes\": {\n \t\"primary-vrf\": \"1\"\n\t },\n\t \t\t\"static-routes\": {\n\t\t\t\t\"ipv4\": {\n\t\t\t\t\t\"route\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"destination-prefix\": \"192.168.3.1/24\",\n\t\t\t\t\t\t\t\"next-hop\": {\n\t\t\t\t\t\t\t\t\"special-next-hop-enum\": \"blackhole\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\t]\n\t\t}\n\t}\n}" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/" + }, + "response": [] + }, + { + "name": "get special hop ipv4", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.3.1%2F24" + }, + "response": [] + }, + { + "name": "get special hop ipv4 Operational", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/operational/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.3.1%2F24" + }, + "response": [] + }, + { + "name": "delete special hop ipv4", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.3.1%2F24" + }, + "response": [] + } + ], + "_postman_isSubFolder": true + }, + { + "name": "TableHop", + "description": "", + "item": [ + { + "name": "Add tablehop ipv4", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"routing\": {\n\t\t\"control-plane-protocols\": {\n\t\t\t\"control-plane-protocol\": [\n\t\t\t{\n\t\t\t\t\"type\": \"static\",\n\t\t\t\t\"name\": \"test-routing-protocol-1\",\n\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\"vpp-protocol-attributes\": {\n \t\"primary-vrf\": \"1\"\n\t },\n\t \t\t\"static-routes\": {\n\t\t\t\t\"ipv4\": {\n\t\t\t\t\t\"route\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"destination-prefix\": \"192.168.4.1/24\",\n\t\t\t\t\t\t\t\"next-hop\": {\n \"secondary-vrf\": 0\n }\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\t]\n\t\t}\n\t}\n}" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/" + }, + "response": [] + }, + { + "name": "get tablehop ipv4", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.4.1%2F24" + }, + "response": [] + }, + { + "name": "get tablehop ipv4 Operational", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/operational/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.4.1%2F24" + }, + "response": [] + }, + { + "name": "delete tablehop ipv4", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv4/route/192.168.4.1%2F24" + }, + "response": [] + } + ], + "_postman_isSubFolder": true + } + ] }, { - "id": "6244bd7f-dedd-bd6d-45c3-00b0fd10bb21", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/routing-protocols/routing-protocol/test-routing-protocol-6", - "preRequestScript": null, - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1480502701577, - "name": "Add special hop ipv6", + "name": "IPv6", "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\n\t\"routing-protocol\":[\n\t\t{\n\t\t\t\"name\":\"test-routing-protocol-6\",\n\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\"enabled\":\"true\",\n\t\t\t\"type\":\"static\",\n\t\t\t\"vpp-protocol-attributes\": {\n\t \"primary-vrf\": \"6\"\n },\n\t\t\t\"static-routes\":{\n\t\t\t\t\"ipv6\":{\n\t\t\t\t\t\"route\":{\n\t\t\t\t\t\t\"id\":3,\n\t\t\t\t\t\t\"description\":\"Test static route multi hop ipv6\",\n\t\t\t\t\t\t\"destination-prefix\":\"2001:0db8:0a0b:12f0:0000:0000:0000:0001/64\",\n\t\t\t\t\t\t\"special-next-hop\":\"receive\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}\n\t\n" + "item": [ + { + "name": "SimpleNextHop", + "description": "", + "item": [ + { + "name": "Add single hop ipv6", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"routing\": {\n\t\t\"control-plane-protocols\": {\n\t\t\t\"control-plane-protocol\": [\n\t\t\t{\n\t\t\t\t\"type\": \"static\",\n\t\t\t\t\"name\": \"test-routing-protocol-1\",\n\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\"vpp-protocol-attributes\": {\n \t\"primary-vrf\": \"1\"\n\t },\n\t \t\t\"static-routes\":{\n\t \t\t\t\"ipv6\":{\n\t \t\t\t\t\"route\":[\n\t\t\t {\n\t\t\t \t\"description\":\"Test static route single hop ipv6\",\n\t\t\t \"destination-prefix\":\"2001:0db8:0a0b:12f0:0000:0000:0000:0001/64\",\n\t\t\t \"next-hop\": {\n\t\t\t \t\"next-hop-address\" : \"2001:0db8:0a0b:12f0:0000:0000:0000:0002\",\n \t\t\t\t\t\"outgoing-interface\": \"local0\"\n\t\t\t },\n\t\t\t \"vpp-ipv6-route\":{\n\t\t\t \t\"classify-table\":\"1\"\n\t\t\t \t}\n\t\t\t }\n\t\t\t ]\n\t\t\t }\n\t \t\t}\n\t\t\t}\t\t\t\n\t\t\t]\n\t\t}\n\t}\n}" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/" + }, + "response": [] + }, + { + "name": "get single hop ipv6", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + }, + { + "name": "get single hop ipv6 Operational", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/operational/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + }, + { + "name": "delete single hop ipv6", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + } + ], + "_postman_isSubFolder": true + }, + { + "name": "MultiNextHop", + "description": "", + "item": [ + { + "name": "Add multi hop ipv6", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"routing\": {\n\t\t\"control-plane-protocols\": {\n\t\t\t\"control-plane-protocol\": [\n\t\t\t{\n\t\t\t\t\"type\": \"static\",\n\t\t\t\t\"name\": \"test-routing-protocol-1\",\n\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\"vpp-protocol-attributes\": {\n \t\"primary-vrf\": \"1\"\n\t },\n\t \t\t\"static-routes\": {\n\t\t\t\t \"ipv6\": {\n\t\t\t\t \"route\": [\n\t\t\t\t {\n\t\t\t\t \"destination-prefix\": \"2001:0db8:0a0b:12f0:0000:0000:0000:0001/64\",\n\t\t\t\t \"vpp-ipv6-unicast-routing:vpp-ipv6-route\": {\n\t\t\t\t \"classify-table\": \"classify-table-1\"\n\t\t\t\t },\n\t\t\t\t \"next-hop\":{\n\t\t\t\t \t\"next-hop-list\": {\n\t\t\t\t \t\t\"next-hop\": [\n\t\t\t\t \t\t{\n\t\t\t\t \t\t\t\"index\": \"1\",\n\t\t\t\t \t\t\t\"next-hop-address\": \"2001:0db8:0a0b:12f0:0000:0000:0000:0002\",\n\t\t\t\t \t\t\t\"outgoing-interface\": \"local0\",\n\t\t\t\t \t\t\t\"weight\": \"2\"\n\t\t\t\t \t\t},\n\t\t\t\t \t\t{\n\t\t\t\t\t\t \"index\": \"2\",\n\t\t\t\t\t\t \"next-hop-address\": \"2001:0db8:0a0b:12f0:0000:0000:0000:0003\",\n\t\t\t\t\t\t \"outgoing-interface\": \"local0\",\n\t\t\t\t\t\t \t\"weight\": \"3\"\n\t\t\t\t \t\t}\n\t\t\t\t \t\t]\n\t\t\t\t \t\t}\n\t\t\t\t \t\t}\n\t\t\t\t \t}\n\t\t\t\t \t]\n\t\t\t\t }\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\t]\n\t\t}\n\t}\n}" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/" + }, + "response": [] + }, + { + "name": "get multi hop ipv6", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + }, + { + "name": "get multi hop ipv6 Operational", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/operational/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + }, + { + "name": "delete multi hop ipv6", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + } + ], + "_postman_isSubFolder": true + }, + { + "name": "SpecialHop", + "description": "", + "item": [ + { + "name": "Add special hop ipv6", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"routing\": {\n\t\t\"control-plane-protocols\": {\n\t\t\t\"control-plane-protocol\": [\n\t\t\t{\n\t\t\t\t\"type\": \"static\",\n\t\t\t\t\"name\": \"test-routing-protocol-1\",\n\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\"vpp-protocol-attributes\": {\n \t\"primary-vrf\": \"1\"\n\t },\n\t \t\t\"static-routes\": {\n\t\t\t\t\"ipv6\": {\n\t\t\t\t\t\"route\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"destination-prefix\": \"2001:0db8:0a0b:12f0:0000:0000:0000:0001/64\",\n\t\t\t\t\t\t\t\"next-hop\": {\n\t\t\t\t\t\t\t\t\"special-next-hop-enum\": \"receive\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\t]\n\t\t}\n\t}\n}" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/" + }, + "response": [] + }, + { + "name": "get special hop ipv6", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + }, + { + "name": "get special hop ipv6 Operational", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/operational/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + }, + { + "name": "delete special hop ipv6", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + } + ], + "_postman_isSubFolder": true + }, + { + "name": "TableHop", + "description": "", + "item": [ + { + "name": "Add tablehop ipv6", + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"routing\": {\n\t\t\"control-plane-protocols\": {\n\t\t\t\"control-plane-protocol\": [\n\t\t\t{\n\t\t\t\t\"type\": \"static\",\n\t\t\t\t\"name\": \"test-routing-protocol-1\",\n\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\"vpp-protocol-attributes\": {\n \t\"primary-vrf\": \"1\"\n\t },\n\t \t\t\"static-routes\": {\n\t\t\t\t\"ipv6\": {\n\t\t\t\t\t\"route\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"destination-prefix\": \"2001:0db8:0a0b:12f0:0000:0000:0000:0001/64\",\n\t\t\t\t\t\t\t\"next-hop\": {\n \"secondary-vrf\": 0\n }\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\t]\n\t\t}\n\t}\n}" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/" + }, + "response": [] + }, + { + "name": "get tablehop ipv6", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + }, + { + "name": "get tablehop ipv6 Operational", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + }, + { + "name": "delete tablehop ipv6", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/hc2vpp-ietf-routing:control-plane-protocols/hc2vpp-ietf-routing:control-plane-protocol/hc2vpp-ietf-routing:static/test-routing-protocol-1/static-routes/ipv6/route/2001:0db8:0a0b:12f0:0000:0000:0000:0001%2F64" + }, + "response": [] + } + ], + "_postman_isSubFolder": true + } + ] }, { - "id": "86b915a1-f85c-939a-0814-fd98b1154162", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/routing-protocols/routing-protocol/test-routing-protocol-4", - "preRequestScript": null, - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1480502678772, - "name": "Add single hop ipv6", - "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\n\t\"routing-protocol\":[\n\t\t{\n\t\t\t\"name\":\"test-routing-protocol-4\",\n\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\"enabled\":\"true\",\n\t\t\t\"type\":\"static\",\n\t\t\t\"vpp-protocol-attributes\": {\n\t \"primary-vrf\": \"4\"\n },\n\t\t\t\"static-routes\":{\n\t\t\t\t\"ipv6\":{\n\t\t\t\t\t\"route\":[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"id\":1,\n\t\t\t\t\t\t\t\"description\":\"Test static route single hop ipv6\",\n\t\t\t\t\t\t\t\"destination-prefix\":\"2001:0db8:0a0b:12f0:0000:0000:0000:0001/64\",\n\t\t\t\t\t\t\t\"next-hop\":\"2001:0db8:0a0b:12f0:0000:0000:0000:0002\",\n\t\t\t\t\t\t\t\"outgoing-interface\":\"local0\",\n\t\t\t\t\t\t\t\"vpp-ipv6-route\":{\n\t\t\t\t\t\t\t\t\"secondary-vrf\":\"2\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t]\n}" - }, - { - "id": "c50cc4a4-a760-f91a-fe66-dd8a66d6085b", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/operational/hc2vpp-ietf-routing:routing-state", - "preRequestScript": null, - "pathVariables": {}, - "method": "GET", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1479200930229, - "name": "Get Routes Operational", - "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\n\t\"routing-instance\":\n\t{\n\t\t\"name\":\"routing-1\",\n\t\t\"enabled\":\"true\",\n\t\t\"router-id\":\"192.168.2.1\",\n\t\t\"description\":\"Test routing instance\",\n\t\t\"routing-protocols\":{\n\t\t\t\"routing-protocol\":[\n\t\t\t\t{\n\t\t\t\t\t\"name\":\"test-routing-protocol\",\n\t\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\t\"enabled\":\"true\",\n\t\t\t\t\t\"type\":\"static\",\n\t\t\t\t\t\"static-routes\":{\n\t\t\t\t\t\t\"ipv4\":{\n\t\t\t\t\t\t\t\"route\":[\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"id\":1,\n\t\t\t\t\t\t\t\t\t\"description\":\"Test static route\",\n\t\t\t\t\t\t\t\t\t\"destination-prefix\":\"192.168.2.3/32\",\n\t\t\t\t\t\t\t\t\t\"next-hop\":\"192.168.2.8\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\t\n\t\t\t]\n\t\t}\n\t}\t\n}" - }, - { - "id": "c5701b6a-a684-0a4f-9991-6f1a866baddd", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/operational/naming-context:contexts", - "preRequestScript": "", - "pathVariables": {}, - "method": "GET", - "data": [], - "dataMode": "raw", - "tests": "", - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1478601413071, "name": "Naming Context Read ", - "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\r\n \r\n \"interface\": [\r\n {\r\n \"name\": \"testInterface\",\r\n \"description\": \"for testing purposes\",\r\n \"type\": \"iana-if-type:ethernetCsmacd\",\r\n \"enabled\": \"true\",\r\n \"link-up-down-trap-enable\": \"enabled\",\r\n \"ietf-ip:ipv4\": {\r\n \"enabled\": \"true\",\r\n \"mtu\": \"1500\",\r\n \"address\": [\r\n {\r\n \"ip\": \"1.2.3.0\",\r\n \"netmask\": \"255.255.255.0\"\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n \r\n}" - }, - { - "id": "de73785a-6784-b280-a9bc-6d6e48199f09", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/operational/hc2vpp-ietf-routing:routing-state/routing-instance/vpp-routing-instance/routing-protocols/routing-protocol/vpp-routing-protocol_2", - "preRequestScript": null, - "pathVariables": {}, - "method": "GET", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1479210482272, - "name": "Get Specific route Operational", - "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\n\t\"routing-instance\":\n\t{\n\t\t\"name\":\"routing-1\",\n\t\t\"enabled\":\"true\",\n\t\t\"router-id\":\"192.168.2.1\",\n\t\t\"description\":\"Test routing instance\",\n\t\t\"routing-protocols\":{\n\t\t\t\"routing-protocol\":[\n\t\t\t\t{\n\t\t\t\t\t\"name\":\"test-routing-protocol\",\n\t\t\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\t\t\"enabled\":\"true\",\n\t\t\t\t\t\"type\":\"static\",\n\t\t\t\t\t\"static-routes\":{\n\t\t\t\t\t\t\"ipv4\":{\n\t\t\t\t\t\t\t\"route\":[\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"id\":1,\n\t\t\t\t\t\t\t\t\t\"description\":\"Test static route\",\n\t\t\t\t\t\t\t\t\t\"destination-prefix\":\"192.168.2.3/32\",\n\t\t\t\t\t\t\t\t\t\"next-hop\":\"192.168.2.8\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\t\n\t\t\t]\n\t\t}\n\t}\t\n}" + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \r\n \"interface\": [\r\n {\r\n \"name\": \"testInterface\",\r\n \"description\": \"for testing purposes\",\r\n \"type\": \"iana-if-type:ethernetCsmacd\",\r\n \"enabled\": \"true\",\r\n \"link-up-down-trap-enable\": \"enabled\",\r\n \"ietf-ip:ipv4\": {\r\n \"enabled\": \"true\",\r\n \"mtu\": \"1500\",\r\n \"address\": [\r\n {\r\n \"ip\": \"1.2.3.0\",\r\n \"netmask\": \"255.255.255.0\"\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n \r\n}" + }, + "url": "http://localhost:8183/restconf/operational/naming-context:contexts" + }, + "response": [] }, { - "id": "e3510e60-17e7-887b-6a55-5e0f651512b0", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/routing-protocols/routing-protocol/test-routing-protocol-1", - "preRequestScript": null, - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1480502842270, - "name": "Add single hop ipv4", - "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\n\t\"routing-protocol\":[\n\t\t{\n\t\t\t\"name\":\"test-routing-protocol-1\",\n\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\"enabled\":\"true\",\n\t\t\t\"type\":\"static\",\n\t\t\t\"vpp-protocol-attributes\": {\n\t \"primary-vrf\": \"1\"\n },\n\t\t\t\"static-routes\":{\n\t\t\t\t\"ipv4\":{\n\t\t\t\t\t\"route\":[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"id\":1,\n\t\t\t\t\t\t\t\"description\":\"Test static route single hop ipv4\",\n\t\t\t\t\t\t\t\"destination-prefix\":\"192.168.2.3/32\",\n\t\t\t\t\t\t\t\"next-hop\":\"192.168.2.8\",\n\t\t\t\t\t\t\t\"outgoing-interface\":\"local0\",\n\t\t\t\t\t\t\t\"vpp-ipv4-route\":{\n\t\t\t\t\t\t\t\t\"secondary-vrf\":\"2\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t]\n}" + "name": "Multi Naming Context Read", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \r\n \"interface\": [\r\n {\r\n \"name\": \"testInterface\",\r\n \"description\": \"for testing purposes\",\r\n \"type\": \"iana-if-type:ethernetCsmacd\",\r\n \"enabled\": \"true\",\r\n \"link-up-down-trap-enable\": \"enabled\",\r\n \"ietf-ip:ipv4\": {\r\n \"enabled\": \"true\",\r\n \"mtu\": \"1500\",\r\n \"address\": [\r\n {\r\n \"ip\": \"1.2.3.0\",\r\n \"netmask\": \"255.255.255.0\"\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n \r\n}" + }, + "url": "http://localhost:8183/restconf/operational/naming-context:contexts\\multi-naming-context:multi-naming-contexts" + }, + "response": [] }, { - "id": "e8216de3-757d-ce34-87e4-8e25ee6b1f44", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/operational/naming-context:contexts\\multi-naming-context:multi-naming-contexts", - "preRequestScript": "", - "pathVariables": {}, - "method": "GET", - "data": [], - "dataMode": "raw", - "tests": "", - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1478778211905, - "name": "Multi Naming Context Read", - "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\r\n \r\n \"interface\": [\r\n {\r\n \"name\": \"testInterface\",\r\n \"description\": \"for testing purposes\",\r\n \"type\": \"iana-if-type:ethernetCsmacd\",\r\n \"enabled\": \"true\",\r\n \"link-up-down-trap-enable\": \"enabled\",\r\n \"ietf-ip:ipv4\": {\r\n \"enabled\": \"true\",\r\n \"mtu\": \"1500\",\r\n \"address\": [\r\n {\r\n \"ip\": \"1.2.3.0\",\r\n \"netmask\": \"255.255.255.0\"\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n \r\n}" + "name": "Get Routes", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"routing-instance\":\n {\n \"name\":\"routing-1\",\n \"enabled\":\"true\",\n \"router-id\":\"192.168.2.1\",\n \"description\":\"Test routing instance\",\n \"routing-protocols\":{\n \"routing-protocol\":[\n {\n \"name\":\"test-routing-protocol\",\n \"description\":\"Test routing protocol\",\n \"enabled\":\"true\",\n \"type\":\"static\",\n \"static-routes\":{\n \"ipv4\":{\n \"route\":[\n {\n \"id\":1,\n \"description\":\"Test static route\",\n \"destination-prefix\":\"192.168.2.3/32\",\n \"next-hop\":\"192.168.2.8\"\n }\n ]\n }\n }\n } \n ]\n }\n } \n}" + }, + "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing" + }, + "response": [] }, { - "id": "ea4e8b3d-2333-6c17-1da2-32fd0b88da96", - "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://localhost:8183/restconf/config/hc2vpp-ietf-routing:routing/routing-instance/vpp-routing-instance/routing-protocols/routing-protocol/test-routing-protocol-3", - "preRequestScript": null, - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": null, - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1480502667293, - "name": "Add special hop ipv4", - "description": "", - "collectionId": "91b6ff58-8e6f-06aa-8067-caecb9f95c88", - "responses": [], - "rawModeData": "{\n\t\"routing-protocol\":[\n\t\t{\n\t\t\t\"name\":\"test-routing-protocol-3\",\n\t\t\t\"description\":\"Test routing protocol\",\n\t\t\t\"enabled\":\"true\",\n\t\t\t\"type\":\"static\",\n\t\t\t\"vpp-protocol-attributes\": {\n\t \"primary-vrf\": \"3\"\n\t },\n\t\t\t\"static-routes\":{\n\t\t\t\t\"ipv4\":{\n\t\t\t\t\t\"route\":{\n\t\t\t\t\t\t\"id\":3,\n\t\t\t\t\t\t\"description\":\"Test static route multi hop ipv4\",\n\t\t\t\t\t\t\"destination-prefix\":\"192.168.2.5/32\",\n\t\t\t\t\t\t\"special-next-hop\":\"receive\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}\n\t\n" + "name": "Get Routes Operational", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic YWRtaW46YWRtaW4=" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"routing-instance\":\n {\n \"name\":\"routing-1\",\n \"enabled\":\"true\",\n \"router-id\":\"192.168.2.1\",\n \"description\":\"Test routing instance\",\n \"routing-protocols\":{\n \"routing-protocol\":[\n {\n \"name\":\"test-routing-protocol\",\n \"description\":\"Test routing protocol\",\n \"enabled\":\"true\",\n \"type\":\"static\",\n \"static-routes\":{\n \"ipv4\":{\n \"route\":[\n {\n \"id\":1,\n \"description\":\"Test static route\",\n \"destination-prefix\":\"192.168.2.3/32\",\n \"next-hop\":\"192.168.2.8\"\n }\n ]\n }\n }\n } \n ]\n }\n } \n}" + }, + "url": "http://localhost:8183/restconf/operational/hc2vpp-ietf-routing:routing" + }, + "response": [] } ] } \ No newline at end of file diff --git a/vpp-integration/api-docs/scripts/src/main/resources/routing.json b/vpp-integration/api-docs/scripts/src/main/resources/routing.json index 95f85414f..5b7fe6de7 100644 --- a/vpp-integration/api-docs/scripts/src/main/resources/routing.json +++ b/vpp-integration/api-docs/scripts/src/main/resources/routing.json @@ -1,4 +1,3 @@ { - "default-routing-instance-name": "vpp-routing-instance", "learned-route-name-prefix": "learned-route" -} \ No newline at end of file +} -- cgit 1.2.3-korg