netconf.git
2 weeks agoExpand NettyImpl with datagram support 06/114006/5
Robert Varga [Tue, 15 Oct 2024 15:46:45 +0000 (17:46 +0200)]
Expand NettyImpl with datagram support

Add basics needed to support datagram channels. This will be useful for
transport-udp.

Change-Id: I290f7677cf581fc66ccffbaf50dfc942388f1e12
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDisconnect AbstractNettyImpl from ietf-tcp-common 07/114007/4
Robert Varga [Tue, 15 Oct 2024 16:10:27 +0000 (18:10 +0200)]
Disconnect AbstractNettyImpl from ietf-tcp-common

The Netty implementation should not have direct bindings to a concrete
model, so it can be reused between transport-{tcp,udp}.

Change-Id: I447163b7db2d2c1bfccae9042c661e3c2d999bfb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix NettyTransportSupport documentation 09/114009/1
Robert Varga [Tue, 15 Oct 2024 17:53:18 +0000 (19:53 +0200)]
Fix NettyTransportSupport documentation

We have a copy&paste error in javadoc links, fix that up.

Change-Id: Ib0171370c7806d5012b7788b294e7bb38fec06e4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEnd-to-end tests for Netty RESTCONF server 96/112996/64
Ivan Hrasko [Wed, 4 Sep 2024 11:30:25 +0000 (14:30 +0300)]
End-to-end tests for Netty RESTCONF server

Integration tests provided for Netty based RESTCONF server
implementation. Instance of Netty endpoint with basic
controller models is created then HTTP requests are performed
using Netty based client from transport-http.

Tests covering requests to /data (incl actions and yang-patch),
/operations, /yang-library-version, /modules URIs plus
/.well-known/host-meta{.json} URIs.

Additional scenarios:
- topology node mount using device simulator
- data change notifications event stream
- device notification event stream

JIRA: NETCONF-1367
Change-Id: Ibb9dc960cc03b1a7215cb8ff39e2fd2bd136db0e
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Signed-off-by: Matej Sramcik <matej.sramcik@pantheon.tech>
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
2 weeks agoClean up ClientFactoryManager configuration 98/113998/2
Robert Varga [Tue, 15 Oct 2024 13:53:30 +0000 (15:53 +0200)]
Clean up ClientFactoryManager configuration

We have split configuration processing -- the key is acquired only after
the connection is established. Refactor this by acquiring the bits
needed and then perform minimal changes to ClientFactoryManager.

This also adds a FIXME for a follow up, which would not require access
to SSH implementation internals.

JIRA: NETCONF-1190
Change-Id: I223597f3b2cfc7f5e898e830874d3e142eb10acc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoConvert transport-ssh to a JPMS module 78/113978/6
Robert Varga [Mon, 14 Oct 2024 11:59:22 +0000 (13:59 +0200)]
Convert transport-ssh to a JPMS module

Now that we are not hosting models, we can become a full JPMS module. As
a temporary side-effect, also specify Automatic-Module-Name in
shaded-sshd.

JIRA: NETCONF-1190
Change-Id: Ia19cec291d368dcfe75a97716003ba633685e10b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd encoding to AbstractPendingRequest 34/113934/11
Yaroslav Lastivka [Thu, 10 Oct 2024 10:19:10 +0000 (13:19 +0300)]
Add encoding to AbstractPendingRequest

Fix picking encoding inside AbstractPendingRequest#onFailure
which causes NPE during the initialization of FormattableDataResponse.

JIRA: NETCONF-1379
Change-Id: I336a28b20f08402f79636dc8a97c4e15d1282d01
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEnsure backoffMillis is not less than expected 51/113951/4
Peter Suna [Wed, 9 Oct 2024 11:11:36 +0000 (13:11 +0200)]
Ensure backoffMillis is not less than expected

Keeping the last backoff value after randomization can
reduce the SleepingTask timeout to a much smaller value
than expected.

Fix this by keeping the backoff value before randomization.

JIRA: NETCONF-1408
Change-Id: Ie926c92f9e203515c9623d9c794e441a447962f7
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
2 weeks agoAdopt draft-ietf-netconf-udp-client-server-04 90/113990/3
Robert Varga [Tue, 15 Oct 2024 10:53:32 +0000 (12:53 +0200)]
Adopt draft-ietf-netconf-udp-client-server-04

Import ietf-udp-{client,server}.yang as found in the latest version of
draft-ietf-netconf-udp-client-server -- in transport-udp.

Change-Id: Id483a3f195346ebea51530be35cd6cb0d4c321e9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdopt draft-ietf-netconf-netconf-client-server-37 89/113989/2
Robert Varga [Tue, 15 Oct 2024 10:44:16 +0000 (12:44 +0200)]
Adopt draft-ietf-netconf-netconf-client-server-37

Upgrade models to match current draft, at revision 2024-08-14.

Change-Id: Iee29808e943abf4945d7d11876f9ce57af5e420d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoFix odl-netconf-transport dependencies 88/113988/1
Robert Varga [Tue, 15 Oct 2024 09:28:02 +0000 (11:28 +0200)]
Fix odl-netconf-transport dependencies

Make sure we use a range for odl-mdsal-model-rfc7317-iana-crypt-hash.

Change-Id: I555ea90c0c840ee3ee107687d4e32336028571ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 325167b5cb205456cbc6a5fe8fd84606c67d1c1c)

3 weeks agoConvert transport-tls to a JPMS module 86/113986/1
Robert Varga [Tue, 15 Oct 2024 10:29:33 +0000 (12:29 +0200)]
Convert transport-tls to a JPMS module

Now that we do not have generated code here, we can switch to being a
JPMS module, properly encapsulating our internals.

Change-Id: Ib8c06203408f53b40db996b868329ae928dd1745
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoSwitch to using RFC9645 models 73/113973/6
Robert Varga [Sat, 12 Oct 2024 21:00:29 +0000 (23:00 +0200)]
Switch to using RFC9645 models

ietf-tls-{client,common,server}.yang have been published in RFC9645 and
are available from MD-SAL.

Change-Id: If36b3c6070223fc81c34354bbcc6c4ea96289be2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoAllow status code 201 81/113981/1
Sangwook Ha [Mon, 14 Oct 2024 17:45:31 +0000 (10:45 -0700)]
Allow status code 201

The POST request returns 201 when resource is created successfully,
so it should not generate WARN log when the test tool sees the response
code. Include it in the list of accepted status codes.

JIRA: NETCONF-1410
Change-Id: I6b1d5e099bba285ecf6f1653ef9ce188eb12bd8c
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
3 weeks agoRefactor SessionListener integration 79/113979/2
Robert Varga [Mon, 14 Oct 2024 12:12:48 +0000 (14:12 +0200)]
Refactor SessionListener integration

Disconnect SSHTransportStack from SessionListener, so the implementation
detail is hidden from users. An additional side-effect is that we no
longer need to suppress SpotBugs.

JIRA: NETCONF-1190
Change-Id: I79c28aba49064289dfa7ce903522b1da60482004
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoConvert transport-tcp to a JPMS module 38/112838/5
Robert Varga [Mon, 14 Oct 2024 10:53:48 +0000 (12:53 +0200)]
Convert transport-tcp to a JPMS module

We have moved models out, convert now to a JPMS module to improve Java
integration.

Change-Id: I3eb8603af7a66f1f102d9a126bbdad492ee334cc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoSwitch to using RFC9644 models 70/113970/4
Robert Varga [Sat, 12 Oct 2024 19:50:55 +0000 (21:50 +0200)]
Switch to using RFC9644 models

ietf-ssh-{client,common,server}.yang have been published in RFC9644 and
are available from MD-SAL.

This patch switches to using them instead of the old draft, adapting to
the new way how algorithms are modeled.

Change-Id: Iaac864c7ec315794c92f6bd8313a580a9d4b75ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoSwitch to using RFC9643 models 69/113969/3
Robert Varga [Sat, 12 Oct 2024 18:36:55 +0000 (20:36 +0200)]
Switch to using RFC9643 models

ietf-tcp-{client,common,server}.yang have been published in RFC9643 and
are available from MD-SAL.

This patch switches to using them instead of the old draft, but only
supports single address binding for now.

It also requires updating the client/server models to match the
multi-listen capability -- which we pick up in the exact shape as the
latests drafts.

Change-Id: Id2ee382b6d988679a65a2812b51af8653e22d6c1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoUse RFC9642 ietf-keystore.yang 68/113968/2
Robert Varga [Sat, 12 Oct 2024 18:32:11 +0000 (20:32 +0200)]
Use RFC9642 ietf-keystore.yang

This model has been finalized and published and is available from
MD-SAL. Pick it up from there, leaving keystore-api a vacuous artifact
for now.

Change-Id: Ia99d3d1947fb343586d32f8ae6e420af5ffd6588
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoUse RFC9641 ietf-truststore.yang 67/113967/2
Robert Varga [Sat, 12 Oct 2024 18:26:28 +0000 (20:26 +0200)]
Use RFC9641 ietf-truststore.yang

This model has been finalized and published and is available from
MD-SAL. Pick it up from there, leaving truststore-api a vacuous artifact
for now.

Change-Id: I105a25b91ed2f06acec60295f1af716f7e69285d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoUse RFC9640 ietf-crypto-types 66/113966/2
Robert Varga [Sat, 12 Oct 2024 18:08:27 +0000 (20:08 +0200)]
Use RFC9640 ietf-crypto-types

MD-SAL is providing ietf-crypto-types.yang, hence we do not have to
package it ourselves anymore.

Change-Id: I066a1055f78882ba8c5ab26639f9654da0d4f95a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoBump upstreams 65/113965/2
Robert Varga [Sat, 12 Oct 2024 16:28:40 +0000 (18:28 +0200)]
Bump upstreams

Adopt:
- odlparent-14.0.4
- infrautils-7.0.4
- yangtools-14.0.5
- mdsal-14.0.3
- controller-10.0.3
- aaa-0.20.2

Change-Id: Ide732539861eda8d123f66a2c5849f326f4ed2f6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoFixup checkstyle 64/113964/1
Robert Varga [Sat, 12 Oct 2024 17:25:01 +0000 (19:25 +0200)]
Fixup checkstyle

Upgraded checstyle is catching a lot of javadoc violations, this patch
fixes them up.

Change-Id: Ib156cb891e748b957cf0dd9415d043c35c62d01c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoAdd RFC6415 constructs 33/113933/6
Robert Varga [Thu, 10 Oct 2024 08:46:39 +0000 (10:46 +0200)]
Add RFC6415 constructs

The XRD and related contracts should be modeled, so that we can actually
look them up.

This creates LinkRelation and WellKnownURI constant registries and
models the XRD, at least the very bare bones we require.

We then proceed to define responses and use them in WellKnownResources.

JIRA: NETCONF-1379
Change-Id: Id24fe3dc9d1798440277286d182506feabafdc55
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoFix JAX-RS JRD output 38/113938/2
Robert Varga [Thu, 10 Oct 2024 13:53:23 +0000 (15:53 +0200)]
Fix JAX-RS JRD output

'links' is an array, not a singleton -- correct that.

Change-Id: I10ef1929d1ec13a5a111e7063baeca62141892e8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoRemove temp directory usage in plaintext-localfile 28/113428/7
Peter Suna [Wed, 4 Sep 2024 13:51:15 +0000 (15:51 +0200)]
Remove temp directory usage in plaintext-localfile

The PlaintextLocalFileStorageTest use the /tmp folder to store
new data-file and then replace original data-file in custom location.

This can cause error when move operation is performed accross
data stores. Fix this issue by storing new data-file in same
folder as original data-file.

Also removed the usage of /tmp folder in the tests.

JIRA: NETCONF-1396
Change-Id: I3124253567d9d47e59c61aa49f193980cff15d69
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
3 weeks agoIntroduce transport.http.ReadyResponse 35/113935/2
Robert Varga [Thu, 10 Oct 2024 10:29:01 +0000 (12:29 +0200)]
Introduce transport.http.ReadyResponse

ReadyResponse is a Response which can seamlessly translate to
HttpResponse, without throwing a checked exception.

Also promote EmptyRequestResponse to transport.http.

JIRA: NETCONF-1379
Change-Id: I8ce712a15dd692dcdd03cf00c9f92ed0be80a0d5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoModernize netconf-server-mdsal 14/113914/9
Robert Varga [Wed, 9 Oct 2024 06:20:04 +0000 (08:20 +0200)]
Modernize netconf-server-mdsal

Eliminate most of deprecation warnings by migrating to
DataObjectIdentifier.

Change-Id: I6fb2a22be4dc7c31d8f04907fa5da79fef71802a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoUse switch expression to assign type 25/113925/3
Robert Varga [Wed, 9 Oct 2024 12:26:07 +0000 (14:26 +0200)]
Use switch expression to assign type

Address the TODO we have left here.

Change-Id: I83191cd97b8fd2c6325325866f5f61b1483e2156
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoReduce argument passing in PathsEntity 23/113923/2
Robert Varga [Wed, 9 Oct 2024 12:01:35 +0000 (14:01 +0200)]
Reduce argument passing in PathsEntity

We are passing down arguments from fields. Stop doing that and reference
the fields instead.

Change-Id: I6e3d4143707426b81a4219e11e695a742c9d497d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoAdd OpenApiServiceImpl.unboxOrZero() 22/113922/6
Robert Varga [Wed, 9 Oct 2024 11:08:33 +0000 (13:08 +0200)]
Add OpenApiServiceImpl.unboxOrZero()

Using Objects.requireNonNullElse() operates on objects, hence we are
bouncing between Integer and int.

Add unboxOrZero(), which does what it says on the tin: unboxes non-null
and returns 0 for nulls.

Change-Id: Ic69b4284dc0ddcabf69e46d7e458970e5b771dc9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoRefactor PreparedRequest/Response class hierarchy 29/113929/2
Robert Varga [Wed, 9 Oct 2024 19:35:26 +0000 (21:35 +0200)]
Refactor PreparedRequest/Response class hierarchy

PreparedRequest, along with its sibling API components should really
live in transport-http.

This patch pulls it down, clreaning up the class hierchy.

JIRA: NETCONF-1379
Change-Id: Idada210d5236675037424650a52546bf6155c6a3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoFix SSH client re-authentication 42/113842/5
Robert Varga [Sat, 5 Oct 2024 06:25:26 +0000 (08:25 +0200)]
Fix SSH client re-authentication

The onKeyEstablished() callback is invoked whenever a key is
established, i.e. also after rekeying.

This leads to us attempting to trigger authentication again, which is
stopped cold by an ISE.

Fix this by bringing back the check we used to have in
NetconfCallHomeServer.

JIRA: NETCONF-1405
Change-Id: I2a15c319473f3a7a1082f5f58a9a30e9fbec8d73
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoModernize MonitoringToMdsalWriter 17/113917/2
Robert Varga [Wed, 9 Oct 2024 07:19:03 +0000 (09:19 +0200)]
Modernize MonitoringToMdsalWriter

Switch to using DataObjectIdentifier.

Change-Id: Ib4ebe27d2bd90fd056eac627f72c153e50f35c94
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoEliminate OpenApi streams 20/113920/2
Robert Varga [Wed, 9 Oct 2024 09:00:46 +0000 (11:00 +0200)]
Eliminate OpenApi streams

There is no need to perform complicated buffering, as we have an
OpenApiEntityWriter.

We perform the following refactors:
- OpenApiInputStream is now DocumentEntity
- ComponentsStream is (for) now ComponentsEntity
- SchemasStream is now SchemasEntity

We also instantiate primary entities eagerly, as now they are costing us
nigh nothing and their presence makes it clearer as to what state is
encapsulated where.

JIRA: NETCONF-1370
Change-Id: I235ef442fddae47591348c2e73419972d3265c03
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoFix invalid use of @NonNull 19/113919/1
Robert Varga [Wed, 9 Oct 2024 08:50:01 +0000 (10:50 +0200)]
Fix invalid use of @NonNull

Primitive types are not references, hence they can never be null.

Change-Id: Ia68c25593c3a4383970d59f5588f5ce6ba9cf2bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoMigrate to BindingDataCodecFactory 15/113915/2
Robert Varga [Wed, 9 Oct 2024 06:25:04 +0000 (08:25 +0200)]
Migrate to BindingDataCodecFactory

BindingDOMCodecFactory is deprecated, use its replacement.

Change-Id: I224714448be903660b635426f6b675007d6bbf34
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoModernize yanglib-mdsal-writer 08/113908/1
Robert Varga [Wed, 9 Oct 2024 03:45:35 +0000 (05:45 +0200)]
Modernize yanglib-mdsal-writer

Use DataObjectIdentifier instance of InstanceIdentifier.

Change-Id: I9b4ce5f765d2a28ee0cad45cdd2e38f3a5e6ff65
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoAdd ChunkOutputStream 84/113084/17
Robert Varga [Sat, 10 Aug 2024 01:11:25 +0000 (03:11 +0200)]
Add ChunkOutputStream

Address the TODO left by the previous patch: ChunkOutputStream knows
the output and chunkSize, plus it gets a buffer.

write() methods now append to the buffer and frame it to output as
needed.

While we are here, also improve toString() implementations and add more
documentation.

Change-Id: I5cf0b91ab593bd9ab9151051bf828c9877f1386e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoMove EndpointInvariants 44/113844/9
Robert Varga [Sat, 5 Oct 2024 12:24:26 +0000 (14:24 +0200)]
Move EndpointInvariants

EndpointInvariants is a simple DTO, we can just move it to
impl package without exposing anything to the outside world.

JIRA: NETCONF-1379
Change-Id: I282a908b771132bcb71b5098c87f23b3f3b62fa4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoMove SegmentPeeler 45/113845/10
Robert Varga [Mon, 7 Oct 2024 07:51:56 +0000 (09:51 +0200)]
Move SegmentPeeler

SegmentPeeler is a utility useful to all users to transport-http, move
it there.

JIRA: NETCONF-1379
Change-Id: I281d48c548cee2752c58f13ec58320a6fddb8b8e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoFinish RestconfSession/PendingRequest integration 43/113843/8
Robert Varga [Sat, 5 Oct 2024 12:16:16 +0000 (14:16 +0200)]
Finish RestconfSession/PendingRequest integration

We have all the bits and pieces concentrated in RestconfSession, now
implement request tracking as outlined in the FIXMEs, completing the
dispatch integration.

JIRA: NETCONF-1379
Change-Id: Icc5216b5496abda90cd2f1368f99134a07b09306
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoSplit out HTTPServerSession 39/113839/7
Robert Varga [Fri, 4 Oct 2024 20:53:31 +0000 (22:53 +0200)]
Split out HTTPServerSession

RestconfSession has a top-half, which is RESTCONF-specific, and a
bottom-half, which is closely related to HTTPServer's channel setup.

This splits out HTTPServerSession, so that it can be moved to
transport-http and reused by other components if/when the need arises.

JIRA: NETCONF-1379
Change-Id: Iab96baab4b9469a6a5eaf2d3234cfdbb813a59a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoEliminate Http2Utils 40/113840/6
Robert Varga [Fri, 4 Oct 2024 23:03:21 +0000 (01:03 +0200)]
Eliminate Http2Utils

This class is a case of false sharing:

1. most of the callers of copyStreamId() are server-side, so they
   can squat in ServerSseHandler.

2. connectionHandler() is differentiated by a boolean -- which selects
   the framer and deals with the setup of listeners.

Eliminate the entire class at the cost of duplicating ~15 lines of code.
While that may sound horrible, it is actually what we want to do,
because now we can evolve the setup on client side and server side of
things separately.

JIRA: NETCONF-1379
Change-Id: I3a5f4288f4b0d65fa53cc039e37b2dde70f46e87
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoEliminate RestconfRequest 38/113838/6
Robert Varga [Fri, 4 Oct 2024 19:12:51 +0000 (21:12 +0200)]
Eliminate RestconfRequest

The sole remaining user of this class is RestconfSession, which uses
it just as an indirection.

Fold RestconfRequest.execute() into RestconfSession.executeRequest(), so
that we get all the things in one place.

JIRA: NETCONF-1379
Change-Id: I085d5c1e020d31ab1deb38c5496f1ace0bcd8ce7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoRefactor AbstractRequestProcessorTest wiring 37/113837/6
Robert Varga [Fri, 4 Oct 2024 18:36:31 +0000 (20:36 +0200)]
Refactor AbstractRequestProcessorTest wiring

This patch finishes the 'RequestDispatcher' refactoring saga by wiring
AbstractRequestProcessorTest to RestconfSession so that all requests
we send end up going through all of our validation.

This flushes out the fact we do not add a Host: header, which this patch
adds to all testing messages.

JIRA: NETCONF-1379
Change-Id: I907d689e1524b501070d2ef96a00df77ad37aa25
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoImprove PendingRequest.execute()'s body handling 36/113836/8
Robert Varga [Fri, 4 Oct 2024 18:11:17 +0000 (20:11 +0200)]
Improve PendingRequest.execute()'s body handling

Empty body is not really valid in terms of RESTCONF -- in fact we have
some code to detect empty inputs in restconf-server-api.

Update PendingRequest's contract to allow for null bodies and deal with
that in PendingRequest{With,Without}Body.

With that expressiveness in place, rework RestconfSession's content
reference handling, so that we release the body as soon as the execution
is done.

JIRA: NETCONF-1379
Change-Id: Idb3b92450cabe6fd27661e70863fa8b64e3bc93a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoAdd PendingRequestWithoutBody 35/113835/7
Robert Varga [Fri, 4 Oct 2024 17:36:41 +0000 (19:36 +0200)]
Add PendingRequestWithoutBody

We are getting our body handed as an InputStream and it is critical we
close it.

PendingRequestWithBody already deals with that, now we introduce
PendingRequestWithoutBody, which closes the stream prior to continuing
execution.

In order to prevent accidental mistakes, make AbstractPendingRequest a
sealed class allowing only these two subclasses, so that everybody else
has to pick on which side they are.

JIRA: NETCONF-1379
Change-Id: Ic06c133bb401f8ff8eeb5b1e2df55f074148a546
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoEliminate APIResource.firstSegment() 34/113834/7
Robert Varga [Fri, 4 Oct 2024 17:24:56 +0000 (19:24 +0200)]
Eliminate APIResource.firstSegment()

APIResource should not care how it is reached from EndpointRoot, move
that knownledge out.

JIRA: NETCONF-1379
Change-Id: I79704a1be259265048a0205db397819252dc28e1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoSplit out EndpointRoot 33/113833/7
Robert Varga [Fri, 4 Oct 2024 16:01:21 +0000 (18:01 +0200)]
Split out EndpointRoot

RestconfSession includes more functionality than it should, mostly
because there was no other place to stick it while we had
RestconfRequestDispatcher.

This patch introduces EndpointRoot, which acts as the semantic root
resource of a particular Endpoint, taking care of dispatching between
registered resources.

JIRA: NETCONF-1379
Change-Id: Id59841b92f5a568024463a7355d6bfdf2969a7c9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoFixup OpenApiBodyWriter usage 73/113873/2
Robert Varga [Mon, 7 Oct 2024 16:14:50 +0000 (18:14 +0200)]
Fixup OpenApiBodyWriter usage

OpenApiBodyWriter is a JAX-RS integration capable of streaming an entity
into an OutputStream, but we are misusing it to buffer entities in our
InputStreams.

Introduce OpenApiBodyBuffer to perform exactly the operation we need,
migrating complicated callers.

MetadataStream is straight-up replaced with pushing the MetadataEntity
into Response -- whence it is picked up by OpenApiBodyWriter.

JIRA: NETCONF-1370
Change-Id: Ic6f7b779b7afe28b90739351b48aff2aceedf0e0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoClean up restconf-openapi dependencies 72/113872/1
Robert Varga [Mon, 7 Oct 2024 15:18:14 +0000 (17:18 +0200)]
Clean up restconf-openapi dependencies

We are using jackson-databind only for tests, hence we can work with
just jackson-core.

Update our wiring and clean up dependencies, switch enforcement on, so
we do not regress.

JIRA: NETCONF-1370
Change-Id: Ia553b53e6d580a072eea67813062f8b27729e343
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoBump SSHD to 2.14.0 80/113780/3
Robert Varga [Tue, 1 Oct 2024 09:04:17 +0000 (11:04 +0200)]
Bump SSHD to 2.14.0

https://github.com/apache/mina-sshd/blob/master/docs/changes/2.14.0.md

Change-Id: I14fa8f3641550852705811a93521128768e15246
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoPropagate TransportSession to NettyServerRequest 23/113823/7
Robert Varga [Fri, 4 Oct 2024 14:10:02 +0000 (16:10 +0200)]
Propagate TransportSession to NettyServerRequest

Subscriptions will need to be attaching resources to RestconfSession,
this patch ensures we expose it from ServerRequest.

JIRA: NETCONF-714
Change-Id: I7948ea3f76351de7b69ae0b99a15b20c79cfdc6f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoRename RestconfRequestDispatcher to APIResource 31/113831/7
Robert Varga [Fri, 4 Oct 2024 12:49:46 +0000 (14:49 +0200)]
Rename RestconfRequestDispatcher to APIResource

At this point there is only a teensy-tiny bit of the old 'dispatch()'
logic living in RestconfRequestDispatcher and it now really acts as a
the root of RESTCONF -- i.e. what RFC8040 calls 'API Resource'. Rename
it to match its function.

JIRA: NETCONF-1379
Change-Id: I18437f5346ff6c1c179a477514001a2c4bb692fa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoMove RestconfRequestDispatcher processing 30/113830/7
Robert Varga [Fri, 4 Oct 2024 12:32:05 +0000 (14:32 +0200)]
Move RestconfRequestDispatcher processing

The entire RestconfRequestDispatcher.dispatch() thing is going to be
refactored. Move it to RestconfRequest, as it is completely independent
from RestconfRequestDispatcher.

JIRA: NETCONF-1379
Change-Id: I6a7ea7768fa467002beecc38d806898f46cca55c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoClean up RestconfRequestDispatcher a bit 29/113829/7
Robert Varga [Fri, 4 Oct 2024 12:19:40 +0000 (14:19 +0200)]
Clean up RestconfRequestDispatcher a bit

This class is becoming a normal resource, hence it should not be logging
things on behalf of the entire component.

Move the logging bits to RestconfTransportChannelListener and move the
prepare() method just below the constructor, so that it is clear what is
going away at some point.

JIRA: NETCONF-1379
Change-Id: Ia5b9f168c164ac30341ae3cdc43eb2a34b696b84
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoTrim leaf resource method names 28/113828/7
Robert Varga [Fri, 4 Oct 2024 12:08:21 +0000 (14:08 +0200)]
Trim leaf resource method names

Now that each resource has its own class, we can shorten private method
names.

JIRA: NETCONF-1379
Change-Id: If2c257a3ac0fbda401ab24b12dc71539b89c03a9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoRestconfRequestDispatcher is an AbstractResource 27/113827/6
Robert Varga [Fri, 4 Oct 2024 11:54:16 +0000 (13:54 +0200)]
RestconfRequestDispatcher is an AbstractResource

We now have a clear definition of what a resource is -- but the
prepare() method has some tension between RestconfRequestDispatcher's
and AbstractResource's (and its subclasses') needs.

Resolve this tension by introducing AbstractLeafResource, which is what
DataResource et al. really are.

This allows us to redefine AbstractResource.prepare() to match exactly
what RestconfRequestDispatcher's idea, with AbstractLeafResource
providing the common glue during invocation.

JIRA: NETCONF-1379
Change-Id: I6e060eac0513c6188627a0543bd87708edbdbf6e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoSplit out RESTCONF request preparation 26/113826/6
Robert Varga [Fri, 4 Oct 2024 11:34:02 +0000 (13:34 +0200)]
Split out RESTCONF request preparation

RestconfRequestDispatcher's organization is now such that there are two
three distinct parts to it:

1. the 'RESTCONF API root resource' part, dealing request
2. the preparation of subresources
3. the Netty pipeline part, dealing with interface to RestconfSession

In this patch we introduce AbstractResource to split out utilities and
constants shared for the first two parts. It additionally defines the
prepare() function, which we use from the last part.

We split out {Data,Modules,Operations,YLV}Resource, so that each hosts
only methods specific to them.

JIRA: NETCONF-1379
Change-Id: I0b42a3920146a30f22ce8bfdb3b5fd97693bfcdf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoRefactor RESTCONF request dispatch 93/113793/26
Robert Varga [Tue, 1 Oct 2024 17:05:57 +0000 (19:05 +0200)]
Refactor RESTCONF request dispatch

The act of servicing an HTTP request has four distinct phases:
- request validation and binding, synchronous
- request execution, asynchronous
- result interpretation, synchronous
- result streaming, asynchronous

We have first two cobbled together in RestconfRequestDispatcher, while
the last two are handled synchronously in ResponseUtils and the various
RestconfRequest subclasses.

This patch tackles the problem in RestconfRequestDispatcher, separating
the two phases.

We introduce a prepare() method, whose sole raison d'etre is to
synchronously process the contents of HttpRequest, i.e. method, URI and
headers, so as to arrive at a specific request (and its parameters) that
we want to be executing.

The result is communicated via PreparedRequest, which is a sealed
interface with two specializations:

1. CompletedRequest, holding an immediate result -- typically an error
   response, or a response that is statically known (such as the answer
   to 'OPTIONS /restconf/operations HTTP/1.1')
2. PendingRequest, represents has a number of specializations for the
   various requests we can execute asynchronously

The former is handled by immediate conversion to a FullHttpResponse,
which is then sent to the client. The latter is then fed any request
body, if present and executed, with the results processed in the usual
way.

We also eliminate two implementation hotspots:

1. RequestParameters, which has comindled the various request-related
   concerns in a structure-like blob. We now track the various
   parameters in the various AbstractPendingRequest subclasses, keeping
   them colocated with their users.

2. ResponseUtils along with the message builder -- which are now
   replaces through the Response interface, which offers decoupling of
   response shapes from how they map to HTTP constructs -- which is
   really a pipeline-side concern.

The result is that we have separated out the concerns, so that each
processing stage has a natural view of what it needs to handle --
resulting in much more modular codebase, where individual concerns can
be further evolved without touching others.

Most significantly, the process of turning RestconfServer responses
into ByteBufs is driven completely from PendingRequestListener -- i.e.
fully at the discretion of the Netty pipeline side of the house.

JIRA: NETCONF-1379
Change-Id: I58b89a389faac4a305881f425b5ec6cfac0d77f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoUse exhaustive switch in sessionEvent() 41/113841/3
Robert Varga [Sat, 5 Oct 2024 05:50:10 +0000 (07:50 +0200)]
Use exhaustive switch in sessionEvent()

We really want full coverage of possible events, use a Java 21 trick
to get that.

Change-Id: I6f7005700406ad713ea302f0ef511c74a0ba1700
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoUse HttpRequest in PrincipalService 22/113822/1
Robert Varga [Thu, 3 Oct 2024 21:00:33 +0000 (23:00 +0200)]
Use HttpRequest in PrincipalService

PrincipalService requires access to headers, nothing else. Make sure it
does not carry the baggage of FullHttpRequest.

JIRA: NETCONF-1379
Change-Id: Icae70e153118dc661fc7a50352a6503337ac7ba2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoSeparate out ugly assert 21/113821/1
Robert Varga [Thu, 3 Oct 2024 19:55:41 +0000 (21:55 +0200)]
Separate out ugly assert

We have a rather funky test here, which happened to work because we had
no guards against thrown exceptions.

Those guards are coming back, hence this late-access to InputStream will
not work.

Refactor the test harness into its own class and mark it for
replacement.

JIRA: NETCONF-1379
Change-Id: I6f233fb4dc3a223b375d0e611e12dc5d8ccd0996
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoAdd restconf.server.ImplementedMethod 19/113819/4
Robert Varga [Thu, 3 Oct 2024 12:45:51 +0000 (14:45 +0200)]
Add restconf.server.ImplementedMethod

We are making a check whether a particular method is implemented via a
Set.contains(). This involves a hash-based lookup and gives us a
boolean.

We can do better: define an ImplementedMethod enum, and use Map.get()
for the same check. This has the same lookup cost, but gives us a
singleton check, which we can use for more efficient dispatch.

JIRA: NETCONF-1379
Change-Id: Ic58a0d2d5cdf836b8acd40f5be5c6f1c40ecced7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoExpose AbstractServerRequest.prettyPrint() 14/113814/1
Robert Varga [Wed, 2 Oct 2024 23:05:03 +0000 (01:05 +0200)]
Expose AbstractServerRequest.prettyPrint()

Having this method limited to subclasses is quite limiting -- it means
that classes in the same package as a subclass cannot reference it.

Rather than requiring subclasses to provide a different method that
bridges to prettyPrint(), make the method public, which does no harm.

JIRA: NETCONF-1379
Change-Id: Ib3f307d650756e405aef2a850a2af8dd579fac1e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoOpenAPI: Actions displayed under /rests/operations 21/113721/3
Oleksandr Zharov [Thu, 26 Sep 2024 16:03:46 +0000 (18:03 +0200)]
OpenAPI: Actions displayed under /rests/operations

Fixed base path for action to be /rests/data instead of
/rests/operations.

JIRA: NETCONF-1395
Change-Id: Iae1043447252d3ff97b0f067a99b5b0a94fdc06d
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
4 weeks agoEliminate extractAcceptTypes() 91/113791/7
Robert Varga [Tue, 1 Oct 2024 19:42:28 +0000 (21:42 +0200)]
Eliminate extractAcceptTypes()

This method is a simple internal intermediary, which actually hides
things from its caller. Inline it and drop a FIXME pointing out the
naivety of responseTypeFromAccept().

JIRA: NETCONF-1379
Change-Id: If22a569be1e740c64673f3675d6095126c197dba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoExpand usability of MessageEncoding 90/113790/5
Robert Varga [Tue, 1 Oct 2024 19:21:38 +0000 (21:21 +0200)]
Expand usability of MessageEncoding

Now that MessageEncoding is a well-defined, expand its usefulness by
including:
- direct RestconfStream.Encoding constant reference
- the set of producer-compatible media types

JIRA: NETCONF-1379
Change-Id: I586773cd08449224aba5568d90cecdcede9513fc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoSplit out NettyEndpointConfiguration.Encoding 89/113789/4
Robert Varga [Tue, 1 Oct 2024 18:45:49 +0000 (20:45 +0200)]
Split out NettyEndpointConfiguration.Encoding

This encoding enumeration is backed by a well-known specification,
namely RFC8040 section 5.2 "Message Encoding".

Promote this class to a top-level construct, adding the appropriate
documentation to ensure where this is coming from.

Update propagation within o.o.restconf.server, so that we do not
lose type safety to AsciiString.

Furthermore split out the from(String) method to restconf-nb, as its
contract is undocumented and is really only appropriate in parsing
the configuration file there.

JIRA: NETCONF-1379
Change-Id: I60499d255d94463e498d6aa1511715469d1b8ead
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoSplit out bootstrap factory 84/113784/5
Robert Varga [Tue, 1 Oct 2024 08:42:42 +0000 (10:42 +0200)]
Split out bootstrap factory

NettyEndpoint currently allocates its own BootstrapFactory and it fails
to clean it up.

Furthermore the configuration prevents users from sharing threads
between multiple subsystems as well as using split groups fro accepting
connections (boss) and servicing connections (worker).

Fix the leak and plug the capability gap by more closely following the
netconf-nb model -- and have the BootstrapFactory managed separately
outside of NettyEndpointConfiguration.

JIRA: NETCONF-1379
Change-Id: I2cd0e93fc29f1413b3b4438ce74a3327f72f3f1a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoRetain Encoding in endpoint configuration 79/113779/6
Robert Varga [Tue, 1 Oct 2024 08:38:44 +0000 (10:38 +0200)]
Retain Encoding in endpoint configuration

Do not peel Encoding, just forward requests for default encoding to it.

JIRA: NETCONF-1379
Change-Id: I8df2f190b030f505023ac6a5e28aeca54eb74343
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoAdd response body example for ROOT operations GET 21/113121/5
Yaroslav Lastivka [Fri, 16 Aug 2024 10:02:00 +0000 (13:02 +0300)]
Add response body example for ROOT operations GET

Hardcoded top-level container "ietf-restconf:operations" for
the OpenAPI-generated example.
Implemented fixed structure to ensure proper schema generation
for both JSON and XML.
Updated unit tests (UT) accordingly to reflect
the new changes.

JIRA: NETCONF-1343
Change-Id: I4aa9f4d782eee929cd49b445913683c3cd1ea33b
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
4 weeks agoUpdate Netty RESTCONF API root path configuration 51/113751/12
Robert Varga [Fri, 27 Sep 2024 18:44:48 +0000 (20:44 +0200)]
Update Netty RESTCONF API root path configuration

The 'restconf' configuration property defaults to "rests" for historical
reasons and controls the {+restconf} expansion on the JAX-RS endpoint.

In the Netty endpoint we want to retain the ability to control the path,
but want to start with the default of "restconf", to make the
out-of-the-box experience match RFC8040.

This patch introduces a separate "api-root-path" property, with a
well-documented syntax and semantics.

We propagate this property via NettyEndpointConfiguration in a decoded
form, so there is no confusion as to what the actual semantics are --
which is always a problem with naked Strings.

JIRA: NETCONF-1379
Change-Id: I14ae912082c9407cac796971686e75f0c23cf04f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoAdd response body example for ROOT data GET 73/113173/10
Oleksandr Zharov [Wed, 21 Aug 2024 19:43:09 +0000 (21:43 +0200)]
Add response body example for ROOT data GET

Added refs to root data GET requests to fill the response
for this path. Controller and devices have different
models wired up to them depending on what you can
actually see after executing GET request to them.

All UT test resources have been adapted for this change.

JIRA: NETCONF-1342
Change-Id: I38ec5df3183809e062fed1af09ba43cf59e1a034
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
5 weeks agoAdd parameters for ROOT data GET 14/112414/6
Yaroslav Lastivka [Tue, 2 Jul 2024 07:42:25 +0000 (10:42 +0300)]
Add parameters for ROOT data GET

Added parameters for GET ROOT path object,
provides possibility to select config or nonconfig data.
Added possibility to set 'Accept' parameter inside header,
included empty content container for proper OpenAPI parsing.

JIRA: NETCONF-1338
Change-Id: I6584e58d1d8857b6abe202b63e14c03d6fd584d9
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
5 weeks agoFix request path interpretation 22/113722/11
Robert Varga [Thu, 26 Sep 2024 16:16:53 +0000 (18:16 +0200)]
Fix request path interpretation

We are decoding the request path before processing it, which leads to
our inability to properly target values.

This patch introduces SegmentPeeler, which aids our traversal of the
path -- thus we can examine decoded segments while we still retain the
ability to pick up the remainder of the path in encoded form.

JIRA: NETCONF-1399
Change-Id: Ib7f7b08db8a97da7e9f60528f9834c50e6ce1ee4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoOpenApi: Avoid leaf names duplication 25/113425/3
Oleksandr Zharov [Wed, 4 Sep 2024 12:45:53 +0000 (14:45 +0200)]
OpenApi: Avoid leaf names duplication

Slightly modified schema generation logic to add the name
of the module before augmentation nodes to avoid
duplication error for augmentations with the same name as
the augmented node. This should help to distinguish
between augmented and not augmented nodes.

JIRA: NETCONF-1361
Change-Id: Iddae59522949a147ef3a6877bef30cfba1d24b20
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
5 weeks agoRemove NettyEndpointConfiguration.baseUri() 58/113658/5
Robert Varga [Thu, 26 Sep 2024 20:52:49 +0000 (22:52 +0200)]
Remove NettyEndpointConfiguration.baseUri()

The idea that the user needs to configure a hostname for Netty endpoint
is quite wrong: we get an absolute URI with each request and hence can
trivially derive restconfURI that the caller can use to reach us.

Remove the host-configuration knob and streamline
NettyEndpointConfiguration by propagating only the restconf() prefix.

JIRA: NETCONF-1379
Change-Id: Ia4857e74e109e04339865fec31f4261343ab953d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoAdd String-based StorageEntry constructor 48/113748/2
Robert Varga [Fri, 27 Sep 2024 15:02:18 +0000 (17:02 +0200)]
Add String-based StorageEntry constructor

We have two places instantiating StorageEntry from strings:
- TestUtils.storageEntry()
- PlaintextLocalFileStorage.readData()

Expose the appropriate constructor and eliminate and let tests use that.

Change-Id: I4f0225ded5cc925c6197a3b12e36f84f36284856
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoDo not allow StorageEntry to be subverted 47/113747/1
Robert Varga [Fri, 27 Sep 2024 14:53:08 +0000 (16:53 +0200)]
Do not allow StorageEntry to be subverted

Perform a defensive clone on {insert,put}Entry(), so that these cannot
be modified later.

Change-Id: Id41b1a157e3ec1ca30f26b0e37c20d59d7fb983e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoStorageEntry should not be a Map.Entry 44/113744/4
Robert Varga [Fri, 27 Sep 2024 11:02:10 +0000 (13:02 +0200)]
StorageEntry should not be a Map.Entry

StorageEntry is internal storage and as such it does not follow the
Map.Entry contract -- most notably it has a different hashCode().

Stop claiming we are implementing Map.Entry and instead use Map.entry()
to construct the one to give out to users.

Change-Id: I6ef9900f32d65d129edbbc7aa84e89177ca853e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoUse a iterator mapping 43/113743/2
Robert Varga [Fri, 27 Sep 2024 10:43:01 +0000 (12:43 +0200)]
Use a iterator mapping

Each of our entries snapshot is immutable, hence we can use iterator
transforms instead of linearizing to array.

Change-Id: Ic41fbfc35a39db704c78de1ccea5381dfd3ecb8b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoCleanup plaintext-localfile dependencies 42/113742/2
Robert Varga [Fri, 27 Sep 2024 10:30:08 +0000 (12:30 +0200)]
Cleanup plaintext-localfile dependencies

We have superfluous dependencies specified and have them misordered. Fix
both up.

Change-Id: I3101f9f581c3eefeb1e92b4b5673028e3936c980
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoRemove superfluous nullness annotations 41/113741/2
Robert Varga [Fri, 27 Sep 2024 09:52:12 +0000 (11:52 +0200)]
Remove superfluous nullness annotations

Annotations are specified in interface contract, there is no point in
repeating them.

Change-Id: I0c346d62b7c1bde2b5978f7c80b707d601c5fe8a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoDo not use Optional during lookup 40/113740/2
Robert Varga [Fri, 27 Sep 2024 09:48:27 +0000 (11:48 +0200)]
Do not use Optional during lookup

We are using Optional only to remap it internally. Rename findByKey() to
lookupEntry() and return a nullable instead.

While we are here, also make sure we reject null keys consistently.

Change-Id: I404247e93e34f3e05405e6e0517d942f6b8a5489
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoSpecialize TransportChannelListeners 19/113719/6
Robert Varga [Thu, 26 Sep 2024 14:27:53 +0000 (16:27 +0200)]
Specialize TransportChannelListeners

Take advantage of the ability to cap which TransportChannels a
particular listeners supports. This allows us to eliminate a cast in
RestconfTransportChannelListener.

JIRA: NETCONF-1400
Change-Id: I1f7000b724eb9f94bc28f9cec51f098165d5f722
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoFix private TransportChanneListener references 20/113720/5
Robert Varga [Thu, 26 Sep 2024 14:18:23 +0000 (16:18 +0200)]
Fix private TransportChanneListener references

Our switch making TransportChanneListener a parameterized interface is
causing quite a few warnings.

This patch addresses warnings private to transport implementations,
without an ABI impact.

JIRA: NETCONF-1400
Change-Id: I5d3aa813f9ef4c859b72e774376031facf614ee5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoParameterize TransportChannelListener 17/113717/6
Robert Varga [Thu, 26 Sep 2024 12:01:01 +0000 (14:01 +0200)]
Parameterize TransportChannelListener

TransportChannel types are exposed to users and some of them provide
useful information. Allow the TransportChannel type to be specified
for TransportChannelListener.

JIRA: NETCONF-1400
Change-Id: Ia5d589ff2496153ee6909350217bb31a4152b4ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoPropagate Target URI to dispatcher 16/113716/2
Robert Varga [Thu, 26 Sep 2024 11:30:52 +0000 (13:30 +0200)]
Propagate Target URI to dispatcher

We need the Target URI in RestconfRequestDispatcher, so that we can
propagate the correct {+restconf} base, as seen by the client, to the
RestconfServer.

JIRA: NETCONF-1379
Change-Id: Iac3fb12bc708f72496f576260c7de7a0fb09c5c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoRework resource lookup 08/113708/5
Robert Varga [Wed, 25 Sep 2024 10:36:44 +0000 (12:36 +0200)]
Rework resource lookup

RestconfRequestDispatcher is using indirection via PathParameters to
interpret the requested path.

There are multiple problems here:
- the logic is quite undocumented
- there is an overload of PathArguments.EMPTY to report at least two
  distinct paths
- we are reporting 409 where we should be reporting 404, as noted in
  RFC8040 section 4.3
- the splitting works on decoded path, whereas the ApiPath.parse()
  should always we presented with an encoded path

This patch deals with the first three problems, documenting how we are
peeling the path and what gaps there are relative to the specification.

The last problem is marked with a FIXME and will be addressed in a
follow-up patch.

JIRA: NETCONF-1379
Change-Id: I408626a5e328bb938f727d9a549ca8297c9df3a9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoCorrect well-known error status code 07/113707/3
Robert Varga [Wed, 25 Sep 2024 22:59:54 +0000 (00:59 +0200)]
Correct well-known error status code

We are now reporting unimplemented method from RestconfSession, hence
WellKnownResources can report a proper 405 Method Not Allowed by
default.

JIRA: NETCONF-1379
Change-Id: I62c4323e8bc4f4fe0c0f082bffec18dffab55f01
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoReconstruct Target URI, part two 83/113683/9
Robert Varga [Wed, 25 Sep 2024 16:39:57 +0000 (18:39 +0200)]
Reconstruct Target URI, part two

Reconstructing Target URI from its usual origin-form is a tad more
involved:

1. we need access to the URI scheme being used, which we now have
   conveniently available from HTTPTransportChannel
2. we need to ensure we have a Host header, that it contains only one
   value and that it is a valid authority

We employ java.net.URI for most of the parsing, combining and error
reporting functions. It also allows us to determine in the uri is in
absolute-form, in which case we can pick it up as is.

We use this URI to initialize QueryStringDecoder, so that its uri()
method reports the complete thing.

JIRA: NETCONF-1379
Change-Id: I6641a613f2fd4c63332ae29b0a876ca32a325a03
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoReconstruct Target URI, part one 80/113680/7
Robert Varga [Wed, 25 Sep 2024 12:31:06 +0000 (14:31 +0200)]
Reconstruct Target URI, part one

In order to correctly serve our requests, we need to properly
reconstruct target URI, as per HTTP/1.1 spec.

This patch deals with the simplest case, asterisk-form: it is only
allowed for OPTIONS request and reports all methods implemented by
the server. All other methods fails with either status 400.

That necessitates knowledge as to what methods are requested, hence
we have a statically-populated Set.

JIRA: NETCONF-1379
Change-Id: Id37044799460759d1066ad7a17524ee0c0284060
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoExpose HttpScheme from HTTPTransportChannel 05/113705/4
Robert Varga [Wed, 25 Sep 2024 18:48:46 +0000 (20:48 +0200)]
Expose HttpScheme from HTTPTransportChannel

Downstream users may need to inquire as to whether the channel is secure
or not -- for example to follow RFC9110 Target URI construction.

Expose HttpScheme from HTTPTransportChannel, so that this information is
readility available.

JIRA: NETCONF-1379
Change-Id: Iba7f847246ab9c88a9804caba803f22ab704f406
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoSpecialize HTTPClient 84/113684/4
Robert Varga [Wed, 25 Sep 2024 19:13:36 +0000 (21:13 +0200)]
Specialize HTTPClient

We know statically whether a particular client is TLS-enabled, so use
two subclasses, each specialized for the task.

JIRA: NETCONF-1379
Change-Id: Ib46a3c779dd2f3bdf060561a754180f099fdc997
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoMove ResponseUtils.optionsResponse() 73/113673/3
Robert Varga [Tue, 24 Sep 2024 22:56:46 +0000 (00:56 +0200)]
Move ResponseUtils.optionsResponse()

This method is only called from RestconfRequestDispatcher. Move it there
and simplify it by bypassing ResponseBuilder's complexities.

JIRA: NETCONF-1379
Change-Id: Ie7647fcc2eab6b8c1c9112da55283efb1b5819ae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoClean up NettyServerRequest subclasses 72/113672/4
Robert Varga [Tue, 24 Sep 2024 22:42:19 +0000 (00:42 +0200)]
Clean up NettyServerRequest subclasses

Almost all anonymous NettyServerRequest subclasses are inefficient in
that they retain RequestParameters twice:
- once in NettyServerRequest
- once via reference to 'params' method argument

Make sure we reference NettyServerRequest.requestParams instead of
params, reducing memory overhead of each request.

JIRA: NETCONF-1379
Change-Id: I0f7df86dbd8681f2d4e92f7dabefb6f6820709ef
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoAdd FormattableServerRequest 71/113671/3
Robert Varga [Tue, 24 Sep 2024 22:35:36 +0000 (00:35 +0200)]
Add FormattableServerRequest

We have two distinct NettyServerRequest subclasses doing exactly the
same thing. Share a single FormattableServerRequest class between the
two code paths.

JIRA: NETCONF-1379
Change-Id: Id30306ce9073afdd73d790282d3a023dde2c4c07
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoIntroduce RestconfRequest 70/113670/3
Robert Varga [Tue, 24 Sep 2024 22:03:41 +0000 (00:03 +0200)]
Introduce RestconfRequest

The use of FutureCallback is misleading and not very well controlled.
Introduce RestconfRequest, which shows that the onFailure() path is
never taken.

This also provides us with an anchor point for future evolution, as we
must be mindful of asynchronous processing. The requirements are laid
down in a FIXME, which we will address in future improvements.

JIRA: NETCONF-1379
Change-Id: I3e9a25ce6932498654567c12ea431417e27a2c7b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>