netconf.git
7 months agoClean up restconf-common dependencies 88/108688/3
Robert Varga [Thu, 26 Oct 2023 17:09:05 +0000 (19:09 +0200)]
Clean up restconf-common dependencies

We have a few warnings reported here, clean them up.

Change-Id: Ida88e1939b2901b642ea14798a4833954cdc05ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove NetconfServerFactory 49/108649/9
Robert Varga [Tue, 24 Oct 2023 21:22:52 +0000 (23:22 +0200)]
Remove NetconfServerFactory

NetconfServerFactory is not used anywhere, remove it along with its
single implementation class.

Refactor its unit tests to separate (Ssh,Tcp}NetconfServerTests,
properly specialized to what we need. This offers quite a few clean up
opportunities in the testing code, which are also implemented -- notably
reducing the number of warnings generated.

Finally clean up pom.xml as well, as the code updates lower
dependencies,  which need to be reflected back in order to keep
maven-dependency-plugin content.

JIRA: NETCONF-1106
Change-Id: I40445177aa1a8deaa8d5a0bcb41101447fa884be
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoHide SendErrorExceptionUtil 48/108648/4
Robert Varga [Tue, 24 Oct 2023 21:15:56 +0000 (23:15 +0200)]
Hide SendErrorExceptionUtil

This utility class is an implementation detail, hide it from the outside
world, allowing it to be split up in the future.

JIRA: NETCONF-1106
Change-Id: I362b5bc1f80af69ae6dde43ad8c9785c4f9baa25
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoInline NetconfServerSessionNegotiatorFactoryBuilder 47/108647/4
Robert Varga [Tue, 24 Oct 2023 21:13:07 +0000 (23:13 +0200)]
Inline NetconfServerSessionNegotiatorFactoryBuilder

Make the builder static inline class for the entity being built,
cleaning up the namespace a bit. This allows us to inline
transformCapabilities(), as it is only used in the builder.

JIRA: NETCONF-1106
Change-Id: Id22438e6212188f19c85ccb74d9d0d5077c2c84c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoWorkaround invalid password 78/108678/2
Robert Varga [Thu, 26 Oct 2023 10:58:45 +0000 (12:58 +0200)]
Workaround invalid password

Catch IAE which can, for example, be produced when we attempt to decrypt
a bad password.

JIRA: NETCONF-1114
Change-Id: I17154dea25cdec0252514ed803fbfaafd5060a6c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoBump SSHD to 2.11.0 34/108634/4
Robert Varga [Tue, 24 Oct 2023 15:32:26 +0000 (17:32 +0200)]
Bump SSHD to 2.11.0

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

JIRA: NETCONF-1189
Change-Id: I4bd7e028f9340c7169317a10bd2ccf3d75e1058e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoReturn ImmutableSet from transformCapabilities() 46/108646/3
Robert Varga [Tue, 24 Oct 2023 21:03:23 +0000 (23:03 +0200)]
Return ImmutableSet from transformCapabilities()

Ditch use of Collections2 and modernize to return ImmutableSet, which
conveys the semantics.

JIRA: NETCONF-1106
Change-Id: Ic815d7236299a5da5737299b685fa13592fde2d8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMark deprecated login-password as obsolete 12/108612/2
Oleksandr Zharov [Tue, 24 Oct 2023 09:38:47 +0000 (11:38 +0200)]
Mark deprecated login-password as obsolete

Marked deprecated login-password as obsolete before removing it.

JIRA: NETCONF-1187
Change-Id: Ibc0e633621572aef109632b4c0f9a787020ba728
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
7 months agoEliminate use of checkArgument() 45/108645/1
Robert Varga [Tue, 24 Oct 2023 20:45:16 +0000 (22:45 +0200)]
Eliminate use of checkArgument()

This is an explicit check, make sure we isolate it as such.

Change-Id: Id69ae248ae69f62c227b69bacdd36baf13976aa8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDo not use NetconfServerFactory 42/108642/2
Robert Varga [Tue, 24 Oct 2023 18:12:12 +0000 (20:12 +0200)]
Do not use NetconfServerFactory

ConcurrentClientsTest is establishing only TCP sessions, which turns out
to be a very simple operation. Do not use NetconfServerFactory for that,
but rather talk to TCPServer directly.

JIRA: NETCONF-1106
Change-Id: I1ed165276d119de4fa2f07f8cc9db9bd13a9189e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoAdd BootstrapFactory 26/108626/4
Robert Varga [Tue, 24 Oct 2023 13:45:50 +0000 (15:45 +0200)]
Add BootstrapFactory

We have SSHTransportStackFactoryin in transport-ssh, which provides nice
encapsulation of Netty EventLoopGroups and utility
new(Server)Bootstrap() methods.

This patch introduces BootstrapFactory, making this utility available
to all users of transport-tcp -- reducing the need to muck directly with
NettyTransportSupport.

JIRA: NETCONF-590
Change-Id: I1e22dcf16dcd1aa6ef076717562fe84df41937da
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove PublicKeyAuth 09/108609/6
Robert Varga [Mon, 23 Oct 2023 23:41:09 +0000 (01:41 +0200)]
Remove PublicKeyAuth

This class is not used anywhere, remove it. Also make
LoginPasswordHandler final, as there are no subclasses (and it is a
trivial implementation).

JIRA: NETCONF-1108
Change-Id: Ibb9acfd9aa2f6adeab767af46e3c048e1bf84d1b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMerge (Abstract)NetconfSessionNegotiator 08/108608/7
Robert Varga [Mon, 23 Oct 2023 22:37:29 +0000 (00:37 +0200)]
Merge (Abstract)NetconfSessionNegotiator

All NetconfSessionNegotiator are based on
AbstractNetconfSessionNegotiator, hence we can ditch the intermediate
interface to improve clarity.

JIRA: NETCONF-590
Change-Id: I952a2d0f03b8ff3d2dda3e6b382a93e9ba38168c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoOpenApi: Fix parameter types for paths 21/108321/11
lubos-cicut [Tue, 10 Oct 2023 18:37:19 +0000 (20:37 +0200)]
OpenApi: Fix parameter types for paths

Corrected the hard-coded "string" type for path parameters type to the
proper type. Created a test to verify that the Schema type is assigned
with the expected type.

JIRA: NETCONF-1168
Change-Id: I0c1ff3dd04044507840fe2c484145e8c5740776a
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
7 months agoDo not start devices with invalid configuration 08/108508/8
Robert Varga [Wed, 18 Oct 2023 20:30:31 +0000 (22:30 +0200)]
Do not start devices with invalid configuration

We have an unfortunate modeling accident, where netconf-node's 'host'
and 'port' leaves cannot be made mandatory unless an incompatible change
is made.

This means invalid configuration may hit the configuration datastore
(rather than being rejected) and we need to deal with that.

Redefine ensureNode() to issue a deleteNode() on error and restructure
internals to capture required state before we make a decision whether
to start a node. This rids us of a source of NPE when the NetconfNode is
completely missing.

JIRA: NETCONF-1114
Change-Id: I2f0fd8a65d1c508cb439c1994cf6c446d051412d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
7 months agoClean up AuthenticationHandler 07/108607/4
Robert Varga [Mon, 23 Oct 2023 22:22:36 +0000 (00:22 +0200)]
Clean up AuthenticationHandler

We do not have an import conflict anymore, make things a tad more
concise.

Change-Id: I424cf907412bf1e01563bc863d5d56617c4be9d1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMove AbstractNetconfDispatcher 06/108606/4
Robert Varga [Mon, 23 Oct 2023 22:18:30 +0000 (00:18 +0200)]
Move AbstractNetconfDispatcher

We no longer have a NetconfServerDispatcher, hence this abstract
base class is purely a client-side thing.

JIRA: NETCONF-1106
Change-Id: I6c7c5bfaa15ee88339ab1c98535e566a5e4ca440
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoEliminate ServerChannelInitializer 02/108602/8
Robert Varga [Mon, 23 Oct 2023 18:36:21 +0000 (20:36 +0200)]
Eliminate ServerChannelInitializer

We are always wrapping ServerChannelInitializer in a
ServerTransportInitializer. The server-side of NETCONF protocol has been
completely converted to transport-api and we can therefore simplify
things by inlining initialization logic into ServerTransportInitializer.

JIRA: NETCONF-1106
Change-Id: I848eb3d66aff2988ca6a0df840f5904f13916036
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDitch unused netconf-nb dependency 99/108599/9
Robert Varga [Mon, 23 Oct 2023 16:49:40 +0000 (18:49 +0200)]
Ditch unused netconf-nb dependency

We do not need the entire netconf-nb, as we are not using anything from
it. Ditch the dependency.

JIRA: NETCONF-1106
Change-Id: Id9ea79af282f6bd0bca8070eb17e5c063bdbba21
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDo not use NetconfServerFactory in NetconfDeviceSimulator 98/108598/9
Robert Varga [Mon, 23 Oct 2023 16:40:31 +0000 (18:40 +0200)]
Do not use NetconfServerFactory in NetconfDeviceSimulator

NetconfServerFactory provides only a trivial wrapper around
transport-{tcp,ssh}. Bypassing it allows us to share one instance of
ServerTransportInitializer, improving efficiency and reducing
indirections.

JIRA: NETCONF-1106
Change-Id: I653654b3392ca63473c8cd3a1278317c69af8d96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove NetconfSessionNegotiatorFactory 03/108603/7
Robert Varga [Mon, 23 Oct 2023 18:48:30 +0000 (20:48 +0200)]
Remove NetconfSessionNegotiatorFactory

This interface is a useless abstraction, as the server-side completely
ignores one of its arguments. Eliminate it, allowing both sides to do
precisely what suites them.

JIRA: NETCONF-590
Change-Id: I9fc2674a13622f3de7951463c462496b23cb3f4f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUse ConcurrentHashMap in TesttoolNegotiationFactory 04/108604/2
Robert Varga [Mon, 23 Oct 2023 19:26:41 +0000 (21:26 +0200)]
Use ConcurrentHashMap in TesttoolNegotiationFactory

TesttoolNegotiationFactory is used by a shared initializer, hence it
could be called from multiple threads concurrently. Use ConcurrentMap to
populate operation caches.

Change-Id: I44292dcd3635c1e508058caa988a99f94d83bdc7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoCentralize NETCONF over SSH subsystem name 00/108600/4
Robert Varga [Mon, 23 Oct 2023 17:12:24 +0000 (19:12 +0200)]
Centralize NETCONF over SSH subsystem name

We have quite a few places which hard-code the "netconf" string.
Centralize them in TransportConstants along with pointer to where it is
defined.

JIRA: NETCONF-1106
JIRA: NETCONF-1108
Change-Id: Ifc273c084a59f52c37c7d123de7256f682d5a0d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoOpenApi: Fix 'min-elements' for XML Leaf-List 94/108394/7
lubos-cicut [Fri, 13 Oct 2023 12:21:56 +0000 (14:21 +0200)]
OpenApi: Fix 'min-elements' for XML Leaf-List

Manually set examples with the expected number of elements in the
leaf-list, rather than relying on OpenAPI to duplicate them for us.

JIRA: NETCONF-1171
Change-Id: I883c92a396f88c610067861dc1e31bdd8dfcceb3
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
7 months agoRefactor FramingMechanismHandlerFactory 01/108601/4
Robert Varga [Mon, 23 Oct 2023 18:00:01 +0000 (20:00 +0200)]
Refactor FramingMechanismHandlerFactory

Rename FramingMechanismHandlerFactory to FramingMechanismEncoder and
make it act as abstract superclass to encoders. Also rename
createHandler() to simple of().

Furthermore update users to directly pick encoders, as these are always
compile-time constants.

Change-Id: Idc54c4ccbb3e3706a5f283f966826c5a4997e95d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoClean up validateBaseCapabilities() a bit 97/108597/3
Robert Varga [Mon, 23 Oct 2023 16:09:56 +0000 (18:09 +0200)]
Clean up validateBaseCapabilities() a bit

Use builder fluently and use local variable type inference.

JIRA: NETCONF-1106
Change-Id: Ifae0e83171d89a20735c080103c2e0fb80b10820
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoInline getListener() 96/108596/2
Robert Varga [Mon, 23 Oct 2023 16:07:03 +0000 (18:07 +0200)]
Inline getListener()

This should be called newListener(), as that is what it does, but since
it has only a single caller, inline it there.

JIRA: NETCONF-1106
Change-Id: I02166cf3b5ee7278f3b24dd0dfd1edf9295e2e1d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoFix module's root POST request payload 06/108306/6
Oleksandr Zharov [Tue, 10 Oct 2023 10:24:18 +0000 (12:24 +0200)]
Fix module's root POST request payload

Removed “processModule” method from DefinitionGenerator class.
This method is invoked only when a specific single model is requested
directly and generated POST request had an incorrect payload.

Fixed “addRootPostLink” method to correct POST payload containing
the first container/list child.
Adapted affected unit tests.

JIRA: NETCONF-1179
Change-Id: Ic10280770cfceedc2c9c5099cdbdab14cdc28ad6
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
7 months agoSkip POST for nodes without container/list child 75/108275/8
Samuel Schneider [Fri, 6 Oct 2023 15:23:43 +0000 (17:23 +0200)]
Skip POST for nodes without container/list child

Remove generation of post operations for nodes that does
not have at least one container/list child.

Current implementation generates the wrong payload for JSON
and XML POST requests with leafs or leaf-list in the payload.

With this solution, we can avoid the need to check how many
leaves are in the container and what to do if more of them
are mandatory.

JIRA: NETCONF-1164, NETCONF-1165
Change-Id: I6268ab118fd0cb5092d4b959660855035394e436
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
7 months agoClean up RestconfError 78/108578/3
Robert Varga [Fri, 20 Oct 2023 17:42:25 +0000 (19:42 +0200)]
Clean up RestconfError

Update documentation and clean up conversion bits from RpcError.

JIRA: NETCONF-1188
Change-Id: I446dd8e4c14473241838c95b5220aa7ec2253efd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove RestconfDocumentedException.throwIf() 38/108538/6
Robert Varga [Fri, 20 Oct 2023 13:07:46 +0000 (15:07 +0200)]
Remove RestconfDocumentedException.throwIf()

These convenience methods are not overly convenient, as they are used
only in a few places. Replace them with explicit throws in our quest to
simplify RestconfDocumentedException.

JIRA: NETCONF-1188
Change-Id: I6fe188a134887e4e387800e2abecbaf4a10da502
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMove ErrorTags 37/108537/3
Robert Varga [Fri, 20 Oct 2023 12:44:02 +0000 (14:44 +0200)]
Move ErrorTags

ErrorTags is primarily a JAX-RS mapping utility, move it to restconf-nb
to hide it from the outside world.

JIRA: NETCONF-773
Change-Id: I3fc5f4022da40a8fc536a7e9d6ec965344c1223f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove RestconfDocumentedException.decodeAndThrow() 35/108535/3
Robert Varga [Fri, 20 Oct 2023 12:16:05 +0000 (14:16 +0200)]
Remove RestconfDocumentedException.decodeAndThrow()

This method is not used anywhere, remove it as it binds strongly to
ErrorTags, which are a JAX-RS mapping thing (mostly).

JIRA: NETCONF-1188
Change-Id: I08f0faa8858f4835f843b3b5b4f80de1bb10fa3c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMove JAX-RS patch providers 40/107840/5
Robert Varga [Tue, 12 Sep 2023 17:12:43 +0000 (19:12 +0200)]
Move JAX-RS patch providers

The package structure here is ugly -- just use the baseline package.

JIRA: NETCONF-773
Change-Id: Idfef7854ec523f5c3e0035cfe56bce5a8c7c13b8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove RestconfDocumentedException.status 34/108534/1
Robert Varga [Fri, 20 Oct 2023 10:44:40 +0000 (12:44 +0200)]
Remove RestconfDocumentedException.status

The actual status is derived from the errors reported, which now have to
have at least one element. RestconfDocumentedExceptionMapper is taught
to just infer the status.

JIRA: NETCONF-1188
Change-Id: I90b367a8fa1bf995e3d47d8b9f581a29f76eb2f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRestconfDocumentException is a RuntimeException 14/108514/2
Robert Varga [Thu, 19 Oct 2023 09:31:45 +0000 (11:31 +0200)]
RestconfDocumentException is a RuntimeException

Disconnect from WebApplicationException to reduce dependencies on
JAX-RS.

JIRA: NETCONF-1188
Change-Id: I6c7e7cd7c390ad2502e1aa79ed0496b37d68d315
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoPartially revert "Fix incorrect operational state of device configuration" 07/108507/3
Robert Varga [Wed, 18 Oct 2023 17:19:15 +0000 (19:19 +0200)]
Partially revert "Fix incorrect operational state of device configuration"

NetconfNodeHandler must always have a correct configuration. Users must
be prepared with the fallout of supplying incorrect configuration.

This restores previous behaviour and documents existing behaviour,
repurposing tests introduced in the reverted patch.

JIRA: NETCONF-1114
Change-Id: Iccb501321957a41cac115d70c0da9799fe62d1bd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove synchronization locking 08/105808/7
Samuel Schneider [Wed, 18 Oct 2023 12:16:43 +0000 (14:16 +0200)]
Remove synchronization locking

All sal-restconf-docgen API methods were synchronized
due to bug causing thread access to the SchemaContext
be not synchronized properly. The bug should be no longer
present as SchemaContext is declared to be safe for usage
in multi threaded environment.

JIRA: NETCONF-1049
Change-Id: I86818ee3c93f68f4a5f5bbd8d8fb6e8f6a8ee21c
Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
7 months agoUpdate port in NETCONF user guide 15/108515/2
Matej Sramcik [Wed, 18 Oct 2023 12:16:16 +0000 (14:16 +0200)]
Update port in NETCONF user guide

Update NETCONF user guide call-home section with
currently being used listening port 4334.

JIRA: NETCONF-1184
Change-Id: If3390aab4e028fd6e18c377d668692807828024d
Signed-off-by: Matej Sramcik <matej.sramcik@pantheon.tech>
7 months agoReplace whitelist with allowlist 16/108516/2
Matej Sramcik [Thu, 19 Oct 2023 08:08:12 +0000 (10:08 +0200)]
Replace whitelist with allowlist

Replaced all usages of whitelist as its considered non-technical term
with allowlist.

JIRA: NETCONF-1185
Change-Id: Id6f827ae1b1fb4c2c3e52e69ec2c60ab3c19b25d
Signed-off-by: Matej Sramcik <matej.sramcik@pantheon.tech>
7 months agoDeprecate CallHomeMountDispatcher.createClient() 10/108510/2
Robert Varga [Wed, 18 Oct 2023 21:42:46 +0000 (23:42 +0200)]
Deprecate CallHomeMountDispatcher.createClient()

This an override of a deprecated method, mark it as such to highlight
explicit references.

JIRA: NETCONF-1108
Change-Id: I6aeda7f5303186c80fb99f0319c2d8281e39d5a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoClean up NetconfTopologyImpl(Test) 09/108509/5
Robert Varga [Wed, 18 Oct 2023 21:26:31 +0000 (23:26 +0200)]
Clean up NetconfTopologyImpl(Test)

Improve dispatch of changes and eliminate useless mucking with
yang-binding internals.

We also migrate to JUnit and simplify mocking, eliminating a number
of warnings in the process of doing so.

Change-Id: I0357cf2f728e456918b036ff384da9cd226b6291
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRefactor BaseNetconfSchemas 11/108511/2
Robert Varga [Wed, 18 Oct 2023 22:51:48 +0000 (00:51 +0200)]
Refactor BaseNetconfSchemas

Make the interface record-friendly and make the default implementation a
record. Also clean up surrounding test code.

Change-Id: Ib6c1bbc5e3bbcd0d2da6b6f84fc645a75de16a34
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoAdd option to get device context in ExceptionMapper 74/107874/13
Peter Suna [Mon, 11 Sep 2023 13:54:21 +0000 (15:54 +0200)]
Add option to get device context in ExceptionMapper

To correctly emit device error-path, it is required
to have the device context in the mapper provided by
RestconfDocumentedException.

JIRA: NETCONF-1130
Change-Id: I0050391f349485e5909359e2f23df46111d92546
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMigrate SchemalessRpcStructureTransformerTest to xmlunit-core 97/108497/1
Robert Varga [Wed, 18 Oct 2023 10:04:05 +0000 (12:04 +0200)]
Migrate SchemalessRpcStructureTransformerTest to xmlunit-core

This test has simple assertions, reduce our reliability on legacy
components.

Change-Id: I9e22e917b03934609cb63e38e8b6c9f5e5c93654
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMigrate FieldsSchemalessRpcStructureTransformerTest 96/108496/1
Robert Varga [Wed, 18 Oct 2023 09:51:52 +0000 (11:51 +0200)]
Migrate FieldsSchemalessRpcStructureTransformerTest

Migrate tu xmlunit-code and JUnit5.

Change-Id: I2f7ebbf7644e5d8b27a2e3d19588f792031bf535
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMigrate NC881Test to xmlunit-core/JUnit5 95/108495/1
Robert Varga [Wed, 18 Oct 2023 09:28:06 +0000 (11:28 +0200)]
Migrate NC881Test to xmlunit-core/JUnit5

Reduce our dependencies on legacy components a bit.

Change-Id: Idc2f3a788c932c77884c30b5becd4dc56a36e69b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove identity from OpenAPI Schemas 99/107899/13
Samuel Schneider [Tue, 10 Oct 2023 10:45:41 +0000 (12:45 +0200)]
Remove identity from OpenAPI Schemas

Removes creation of schemas for identity. Use string
value instead of reference on this schema.

Adds test for new behavior.

JIRA: NETCONF-1145
Change-Id: Ic1118bdb90649aa123caa642f06cd00e966e808d
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
7 months agoMake LoggingRemoteDevice a singleton 72/108472/1
Robert Varga [Tue, 17 Oct 2023 08:52:48 +0000 (10:52 +0200)]
Make LoggingRemoteDevice a singleton

There is no point in creating multiple instances of this class, just
squash them to a single instance.

Change-Id: Icb501b176577e2c18df565a7d7aeda01e047ca09
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoYangResource should be a record 71/108471/1
Robert Varga [Tue, 17 Oct 2023 08:41:32 +0000 (10:41 +0200)]
YangResource should be a record

This is a trivial data holder, convert it to a record.

Change-Id: If98bc2f8865ea8658aca707d01b6eae3b275331e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoClean up StressClient a bit 70/108470/1
Robert Varga [Mon, 16 Oct 2023 18:06:02 +0000 (20:06 +0200)]
Clean up StressClient a bit

Move @SuppressFBWarnings on top the sole caller and justify the
suppression.

Use local variable type inference throughout.

Change-Id: I84e65aceb89dbcb2c528aab02d978f7df866dc08
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUse SettableFuture instead of Promise 68/108468/3
Robert Varga [Mon, 16 Oct 2023 18:34:33 +0000 (20:34 +0200)]
Use SettableFuture instead of Promise

Perform correct bridging when we have a channel handy -- that allows us
to reuse the channel's thread.

JIRA: NETCONF-1108
Change-Id: Icdc1437f9ed9e0f560773185b2ba1f6124b0845b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUse Files.readString() 63/108463/1
Robert Varga [Mon, 16 Oct 2023 17:34:13 +0000 (19:34 +0200)]
Use Files.readString()

Since Java 11 we have a simple convenience method to read the contents
of a UTF-8-encoded file. Use that instead of going through a CharSource.

Change-Id: I1ddf210a7d5fb0d78296fbc897593e395e75ae63
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUse text blocks in StressClient 62/108462/1
Robert Varga [Mon, 16 Oct 2023 17:28:52 +0000 (19:28 +0200)]
Use text blocks in StressClient

We have inline XML documents here. Make sure they are as crisp as
possible.

Change-Id: I2d56361b5b7ad78ea596b46196436ab486b53c2f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoClean up CryptHashPasswordAuthenticator 61/108461/1
Robert Varga [Mon, 16 Oct 2023 17:12:53 +0000 (19:12 +0200)]
Clean up CryptHashPasswordAuthenticator

Use simple record for CryptHashValidator, inlining its isValid() method
into its sole caller. Also extract validation logic into the
the authenticator construction loop.

Change-Id: I6a26b36786b7d5f1f9c6b12e0e01e3c3304fe1ce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoModernize NetconfDeviceCommunicator 60/108460/1
Robert Varga [Mon, 16 Oct 2023 16:40:35 +0000 (18:40 +0200)]
Modernize NetconfDeviceCommunicator

- use local variable type inference
- use a VarHandle instead of a AtomicIntegerFieldUpdater
- reduce the number of callsites for future.set()
- Request is a record with non-null fields
- guard message logging with .isXyzEnabled()

Change-Id: I9ab92b9184cf1e3045260d384bdc2a0f3091a045
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUpdate BufferedWriter 59/108459/3
Robert Varga [Mon, 16 Oct 2023 15:18:53 +0000 (17:18 +0200)]
Update BufferedWriter

Clarify why this class is still present, as its primary motivation has
been removed in Java 9.

Also use String.formatted() and drop the use of checkArgument().

Change-Id: I3312cc6690dd6fda9d6a28c7915c9f23f6f4b260
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDelete unused SshProxy artifacts for netconf server 98/108198/11
Ruslan Kashapov [Mon, 3 Jul 2023 14:51:49 +0000 (17:51 +0300)]
Delete unused SshProxy artifacts for netconf server

Ssh proxy served as a bridge to local tcp netconf server.
New ssh transport implementation does not require a proxy.

JIRA: NETCONF-1106
Change-Id: I1b5aee1f6128b4e98918176e35f6e80f1b2c7527
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
7 months agoRefactor ConcurrentClientsTest using new transport 02/108202/24
Ruslan Kashapov [Mon, 3 Jul 2023 14:51:49 +0000 (17:51 +0300)]
Refactor ConcurrentClientsTest using new transport

ConcurrentClientsTest is the last user of NetconfServerDispatcher.
Migrate it to use transport-api and remove obsolete code.

JIRA: NETCONF-1106
Change-Id: Id1e7a9148ee2ad8177eb25443a7b184acbd92064
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUpdate netconf device simulator to use new transport 17/108117/23
Ruslan Kashapov [Mon, 2 Oct 2023 10:41:53 +0000 (13:41 +0300)]
Update netconf device simulator to use new transport

Drop use of netconf.northbound.ssh as well as NetconfServerDispatcher,
establishing a proper end-to-end integration test of the
netconf/trasport integration.

JIRA: NETCONF-1106
Change-Id: I3429b28f8a31bfb8af995d25b79b17110823f638
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
7 months agoFix ssh server subsystem initialization sequence. 55/108455/4
Ruslan Kashapov [Mon, 16 Oct 2023 10:27:53 +0000 (13:27 +0300)]
Fix ssh server subsystem initialization sequence.

The start() triggering run() method is executed on very
first client request within an open subsystem channel.
Initializing netconf handlers within run() method causes
hello message reaching the end of pipeline before netconf
negotiation handlers are properly set. This results
hello message from client being dropped and server side
netconf session never established.

Moved channel initialization trigger (future.set)
to dedicated method invoked after ChannelSession#prepareChannelCommand()
during subsystem open request processing.

JIRA: NETCONF-1106
Change-Id: I6ecfacfedba01045644c4d926d9a20a3941dfe1c
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoIssue channelActive event in transport-ssh 51/108451/4
Robert Varga [Sun, 15 Oct 2023 17:49:50 +0000 (19:49 +0200)]
Issue channelActive event in transport-ssh

Channel behaviour in SSH is subtly different to TCP and TLS transports:
in SSH the transport channel pipeline is established lazily and
signalled after channel.pipeline().fireChannelActive(), thus missing
this event.

JIRA: NETCONF-1106
JIRA: NETCONF-1108
Change-Id: I42af65a8b3bbbd0b3674b333c174701aa5c0ed62
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoImprove SSH{Client,Server} logging 47/108447/4
Robert Varga [Sun, 15 Oct 2023 16:38:36 +0000 (18:38 +0200)]
Improve SSH{Client,Server} logging

Improve consistency with surrounding messages mentioning subsystem.

JIRA: NETCONET-1108
Change-Id: I279962885d17a413f4625602a86a8d3d2840d932
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoLog hello message as confidential 52/108452/5
Robert Varga [Sun, 15 Oct 2023 18:34:17 +0000 (20:34 +0200)]
Log hello message as confidential

Just as with any on-wire message, we have no idea whether or not it
contains confidential information.

Mark log output as condidential and clean up surrounding code a bit.

Change-Id: I15e85449ecd7795a4a01b1267a46e4909d1049e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDeprecate legacy SSH integration 26/108426/3
Robert Varga [Sat, 14 Oct 2023 02:51:27 +0000 (04:51 +0200)]
Deprecate legacy SSH integration

transport-api allows for both connect and listen channels, which renders
quite a bit of netconf-netty-util/callhome-protocol obsolete.

Deprecate classes which are used only in legacy wiring, so that clean up
can be focused.

JIRA: NETCONF-1108
Change-Id: I6cd6d351c986b42f6fbb3a0769e8305dc5440704
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove a trailing comment 25/108425/1
Robert Varga [Sat, 14 Oct 2023 02:23:42 +0000 (04:23 +0200)]
Remove a trailing comment

Sonar is picky here, and rightfully so. Do not use a trailing comment.

Change-Id: I624e7ec542703a0a468e6efca66e49178e6b0297
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoSwitch netconf-client to transport-api 31/107431/34
Ruslan Kashapov [Mon, 3 Jul 2023 14:51:49 +0000 (17:51 +0300)]
Switch netconf-client to transport-api

Expand NetconfClientFactory as the alternative to
NetconfClientDispatcher. The entire stack is adjusted to work on
transport-api.

Clients are now required to provide transport-level settings, paving the
way to callhome-protocol integration.

JIRA: NETCONF-1108
Change-Id: I403f9809e366fa004eda49dc63ba569b99206407
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoExternal service integration support for TLS transport 45/108245/22
Ruslan Kashapov [Thu, 5 Oct 2023 09:40:02 +0000 (12:40 +0300)]
External service integration support for TLS transport

Netconf-topology uses own service to build SslHandler based on
certificates/keys data retrieved from datastore.

JIRA: NETCONF-1106
Change-Id: I7f60e7510852054b214c8aa0cc0198e9423d4954
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoClean up SSH server subsystem handling 04/108404/9
Robert Varga [Fri, 13 Oct 2023 21:12:03 +0000 (23:12 +0200)]
Clean up SSH server subsystem handling

SSH transport should not report a connection until it has established
the expected transport channel.

This patch reworks the API to instantiation and internal wiring, so that
we invoke TransportChannelListener only once the subsystem has been
allocated.

This has the nice side-effect of reducing shaded.ssh package
proliferation, as things just end up being better encapsualted.

JIRA: NETCONF-1106
Change-Id: Ifcfc3a99d1fa323b105c87724c34f9bba018b78a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRequire a subsystem for client connections 96/108396/8
Robert Varga [Fri, 13 Oct 2023 12:13:50 +0000 (14:13 +0200)]
Require a subsystem for client connections

SSHClient does not really operate on the raw session, hence we should
not report it as set up after authentication.

Each client is connected to a particular SSH subsystem, and hence we
require the desired name (for example "netconf", but can be anything).

Once we complete authentication, we request the specified subsystem.
When the subsystem is open, we attach it to the Netty channel and only
then do we report the SSHClient to be up.

JIRA: NETCONF-1108
Change-Id: I9210b2924a9b8239161c8f4c649db3677e63b5b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoClean up SSHTransportStack.sessionEvent() 95/108395/3
Robert Varga [Fri, 13 Oct 2023 12:51:43 +0000 (14:51 +0200)]
Clean up SSHTransportStack.sessionEvent()

Event type dispatch should forward to individual methods, so we can
specialize them.

JIRA: NETCONF-1108
Change-Id: I84cf131ccd91b84f587f9ff0ca824e064032c3d7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoHide Netty(Pipeline)AwareChannelSubsystem 92/108392/3
Robert Varga [Fri, 13 Oct 2023 11:41:51 +0000 (13:41 +0200)]
Hide Netty(Pipeline)AwareChannelSubsystem

Just promise a ChannelSubsystem in API and let the implementation detail
with the details.

JIRA: NETCONF-1108
Change-Id: I21d663d4c2d92a5f087579ec9e29804da3bab569
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoClean up NetconfClientSessionImpl 91/108391/3
Robert Varga [Fri, 13 Oct 2023 11:01:12 +0000 (13:01 +0200)]
Clean up NetconfClientSessionImpl

This class should be final and it shares a bunch of code internally.
Also clean up Netty(Pipeline)AwareChannelSubsystem to share code.

JIRA: NETCONF-1108
Change-Id: Idccb4b6398e28d0a68f4e97f1aa2f06b5984d129
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoFix incorrect operational state of device configuration 88/107688/14
Yaroslav Lastivka [Mon, 4 Sep 2023 10:04:51 +0000 (13:04 +0300)]
Fix incorrect operational state of device configuration

Initialization of clientConfig in NetconfNodeHandler can throw
a RuntimeException, leaving no handler to clean up
the operational datastore. This results in garbage
data upon node deletion.

Made clientConfig nullable and wrapped its initialization in
a try/catch block to handle exceptions. Moved input validation
for host/port from AbstractNetconfTopology#setupConnection()
to DefaultNetconfClientConfigurationBuilderFactory
and included relevant unit tests.

JIRA: NETCONF-1114
Change-Id: Ieb74ee3c1a4e0cbab7f0e01c942d1e8c1d6e20e4
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
7 months agoClean up SSHTransportStack a bit 82/108382/1
Robert Varga [Fri, 13 Oct 2023 08:28:54 +0000 (10:28 +0200)]
Clean up SSHTransportStack a bit

Shuffle justification and fields a bit.

JIRA: NETCONF-1106
Change-Id: I5e1f9a0efcc7c50871042045147688b66e5cf3c6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoIntegrate UserAuthSessionListener into SSHTransportStack 81/108381/2
Robert Varga [Thu, 12 Oct 2023 21:24:32 +0000 (23:24 +0200)]
Integrate UserAuthSessionListener into SSHTransportStack

These two classes are inherently tied together. Make sure they do not
expose their internals outside SSHTransportStack.

Change-Id: I492ee6452047a1520f0de978510cdd6d9379f241
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoExpose NetconfSubsystemOutboundChannelHandler 80/108380/2
Robert Varga [Thu, 12 Oct 2023 20:31:51 +0000 (22:31 +0200)]
Expose NetconfSubsystemOutboundChannelHandler

This is a building block for shuffling SSH data, without any
dependencies on NETCONF. Promote it to transport-ssh for reuse.

JIRA: NETCONF-1106
Change-Id: I06086e532744f3b746c98fbfa6680c66cfad60d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDo not propagate empty writes 79/108379/2
Robert Varga [Thu, 12 Oct 2023 20:26:30 +0000 (22:26 +0200)]
Do not propagate empty writes

The API contract says we can see 0-sized events. Do not propagate those,
as they are not changing channel state.

JIRA: NETCONF-1106
Change-Id: I5dab0bca2616627833409eb82da733bec87cc1a4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoFix NetconfMessage not sent on EmbeddedChannel 16/108116/7
Ruslan Kashapov [Mon, 2 Oct 2023 10:41:53 +0000 (13:41 +0300)]
Fix NetconfMessage not sent on EmbeddedChannel

The EmbeddedChannel implementation uses built-in implementation
for event loop (EmbeddedEventLoop) which has no own executor.
The tasks placed via execute() method are queued but not executed
unless predefined events like channel closure.

Explicit triggering of pending tasks processing resolves the issue
for now, but this needs to be revisited.

JIRA: NETCONF-1106
Change-Id: Ief1d9566651c39e10310c961e5899324e73fa923
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDo not reference DefaultPromise 76/108376/2
Robert Varga [Thu, 12 Oct 2023 16:24:44 +0000 (18:24 +0200)]
Do not reference DefaultPromise

Use newPromise() instead, which does the right thing.

JIRA: NETCONF-1106
Change-Id: I0e2a13ae6612d00afc2ac9753e3af5d376d4c167
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoImprove write error handling 75/108375/3
Robert Varga [Thu, 12 Oct 2023 15:45:50 +0000 (17:45 +0200)]
Improve write error handling

We are swallowing errors if the attempt to write out fails. We also fail
to release the buffer in error paths.

Refactor the implementation to:
- release ByteBuf as soon as we have extracted bytes from it
- propagate failure to the promise
- emit a trace message if we encounter a non-ByteBuf

Also add a TODO to consider creating a ByteBufBuffer, which might reduce
the need copy bytes around.

JIRA: NETCONF-1106
Change-Id: I1da71b1f5c9959a5a32a9ce39067d25464b785c2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoSplit out NetconfSubsystemOutboundChannelHandler 74/108374/2
Robert Varga [Thu, 12 Oct 2023 15:32:32 +0000 (17:32 +0200)]
Split out NetconfSubsystemOutboundChannelHandler

Do not use an anonymous class, but rather split the logic into its own
dedicated class.

JIRA: NETCONF-1106
Change-Id: Ic8786dc950225a51d93d61e2c6a9bb64e144a7af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoNetconfSubsystem should be a ChannelDataReceiver 73/108373/3
Robert Varga [Thu, 12 Oct 2023 15:12:42 +0000 (17:12 +0200)]
NetconfSubsystem should be a ChannelDataReceiver

We are tightly bound to our inner channel, do not allocate a separate
object just to shuffle bytes.

JIRA: NETCONF-1106
Change-Id: I2311170bdc6b1566be5062c1ea0ca38273187966
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoFactor out NetconfSubsystem 72/108372/3
Robert Varga [Thu, 12 Oct 2023 15:07:21 +0000 (17:07 +0200)]
Factor out NetconfSubsystem

This is an inner class for no real reason, split it out into a separate
class for clarity.

JIRA: NETCONF-1106
Change-Id: I1267db3475619ff17f4a026a2f6156f62dd50d8a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoThrows RDE exception in case model was not found 48/108248/11
Oleksandr Zharov [Thu, 5 Oct 2023 12:19:57 +0000 (14:19 +0200)]
Throws RDE exception in case model was not found

Added proper response in case model was not found using
RestconfDocumentedException's DATA_MISSING error tag.

Added unit tests to cover this cases.

JIRA: NETCONF-1159
Change-Id: Ife5b3836c8c2d974963d80df4d497ec019a83cc1
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
7 months agoThrow exception when module cannot be found 14/108214/8
Oleksandr Zharov [Thu, 5 Oct 2023 09:01:49 +0000 (11:01 +0200)]
Throw exception when module cannot be found

Made module field in SchemaExportContext class @NonNull.
Added exception in case module not found in
ParserIdentifier#toSchemaExportContextFromIdentifier.

JIRA: NETCONF-1166
Change-Id: I9571496d789a1c499fd4871787e25e562bfec8ae
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
7 months agoRefactor JaxRsRestconfCallback 98/108298/3
Robert Varga [Tue, 10 Oct 2023 08:09:47 +0000 (10:09 +0200)]
Refactor JaxRsRestconfCallback

Rather than using a Function for transform, force users to subclass and
provide the transform function inline.

JIRA: NETCONF-718
Change-Id: I211234113537422996762d17db1f614c32fb4273
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUse RestconfFuture in putData() 97/108297/1
Robert Varga [Tue, 10 Oct 2023 07:53:19 +0000 (09:53 +0200)]
Use RestconfFuture in putData()

RestconfStrategy.putData() is the final caller of
TransactionUtil.syncCommit().

Refactor it to return a RestconfFuture, adjust callers and eliminate
syncCommit().

JIRA: NETCONF-718
Change-Id: I1f34ddf767bb340d479fdd7fffa4287040559c85
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUse RestconfFuture/AsyncResponse for postData() 76/108276/6
Robert Varga [Mon, 9 Oct 2023 08:19:26 +0000 (10:19 +0200)]
Use RestconfFuture/AsyncResponse for postData()

We now have the tooling we need to make POST requests asynchronous, at
least from the JAX-RS perspective.

This patch provides the first-order wiring change, allowing
RestconfStrategy to completely control how the request is dispatched.
Current implementation eliminates synchronous wait for the commit
future, but leaves other blocking calls as they are.

JIRA: NETCONF-718
Change-Id: Iefcbe31b73b9ed85527ce57d75f29145dbc2ab4c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoStreamline GlobalContext retrieving 74/108274/3
Ivan Hrasko [Fri, 6 Oct 2023 10:44:08 +0000 (12:44 +0200)]
Streamline GlobalContext retrieving

We do not have to use flatMap or additional Optional to get
EfffectiveModelContext from DOMSchemaService.

Use just DOMSchemaService::getGlobalContext method reference instead.

Change-Id: I0cbcf59bc65ba84bdcf6c5c921c6628b255af97d
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
7 months agoOpenAPI: Update Swagger UI to v5.9.0 85/108185/3
Yaroslav Lastivka [Tue, 3 Oct 2023 10:49:34 +0000 (13:49 +0300)]
OpenAPI: Update Swagger UI to v5.9.0

Update Swager UI from v4.18.1 to v5.9.0:
https://github.com/swagger-api/swagger-ui/releases/tag/v5.9.0
https://github.com/swagger-api/swagger-ui/releases/tag/v5.0.0

This new UI enables to update to OpenApi spec 3.1.0 in the future.

JIRA: NETCONF-1162
Change-Id: Ide7c6652d36ef5e6d1c2f58eb0b51bd0f4644512
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
7 months agoAdd RestconfCallback 67/108267/2
Robert Varga [Thu, 5 Oct 2023 23:48:54 +0000 (01:48 +0200)]
Add RestconfCallback

Improve RestconfFuture with a .addCallback(RestconfCallback), where
RestconfCallback is specialized to match RestconfFuture's reporting only
RestconfDocumentedException.

This opens up for a further specialization, JaxRsRestconfCallback, which
performs a transform-and-set of an AsyncResponse.

JIRA: NETCONF-718
Change-Id: I912847da952d7c23cc5d08a3da90758e3f065539
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRestconfStrategy.patchData() should result in RestconfFuture 65/108265/5
Robert Varga [Thu, 5 Oct 2023 21:12:25 +0000 (23:12 +0200)]
RestconfStrategy.patchData() should result in RestconfFuture

This method performs an intrinsically asynchronous operation, clarify
that in its contract.

JIRA: NETCONF-718
Change-Id: I1c4584c27ad78107ed5bf8299ab60287b8942a2b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMake ExistenceCheck implement FutureCallback 64/108264/2
Robert Varga [Thu, 5 Oct 2023 20:46:47 +0000 (22:46 +0200)]
Make ExistenceCheck implement FutureCallback

There is some shared state we are expressing, but we are leaving
implicit dependencies up to an anonymous class to capture.

ExistenceCheck is never instantiated, which seems to be a waste. Split
out the stateful bit allocation to start() and let ExistenceCheck be a
FutureCallback dealing the partial outcome.

Having state ownership indicated a bit more clearly, this exposes a
subtle race: if the last two checks complete concurrently, and one would
result in success and the other in failure, the counter-based logic
could result in a false success.

We document the above interactions and reorder operations to close the
above race without introducing additional locking.

JIRA: NETCONF-718
Change-Id: I3aa8edb4df695131be7e0b79e7f1453fb26837f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUse RestconfException in ExistenceCheck 63/108263/2
Robert Varga [Thu, 5 Oct 2023 19:51:32 +0000 (21:51 +0200)]
Use RestconfException in ExistenceCheck

The only caller is wrapping failures with RestconfDocumentedException,
which means we can unify handling by relocating failure handling to the
original site.

The caller gets the benefit of getOrThrow(), which is completely
appropriate in this execution context.

JIRA: NETCONF-718
Change-Id: Id050e627cf1613dec5eb2411a30c353d2af04c60
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoChange reported path in conflict detection 62/108262/2
Robert Varga [Thu, 5 Oct 2023 19:26:08 +0000 (21:26 +0200)]
Change reported path in conflict detection

We really should be reporting a consistent path here, barring the
datastore report.

JIRA: NETCONF-718
Change-Id: Ie7e0c413e3befbba3e941b397b43b88e477d37df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRefactor BatchedExistenceCheck 61/108261/3
Robert Varga [Thu, 5 Oct 2023 18:31:59 +0000 (20:31 +0200)]
Refactor BatchedExistenceCheck

Users are only interested in a ListenableFuture, which now results in a
'Conflict' record, which captures the semantics of the Entry we use to
return.

The 'Batched' part is not entirely useful, as we can handle single
requests just as well (if the need arises) -- just rename the class to
ExistenceCheck.

As a final twist, pass the presence expectation from the caller, so this
turns a more powerful building block -- which we may need later.

JIRA: NETCONF-718
Change-Id: I71f43e02ff91d8e4fd796dee151c59919663cdc6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoIntroduce XmlUtil.requireSingleElement 07/108207/3
Robert Varga [Tue, 3 Oct 2023 16:17:23 +0000 (18:17 +0200)]
Introduce XmlUtil.requireSingleElement

Improve our handling of structural errors, by reporting missing-element
instead of invalid-value. The utility to do so is also independent from
XmlElement.

Change-Id: If1efd60aa268d659b1e5f43686caf49e77e40c05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoTurn ListenersBroker into a component 34/107834/17
Oleksandr Zharov [Tue, 12 Sep 2023 11:57:54 +0000 (13:57 +0200)]
Turn ListenersBroker into a component

Refactored the ListenersBroker class into a component using
osgi.service.component.annotations.

JIRA: NETCONF-1104
Change-Id: I6ef5fa2ab22792c3d408dfa9db92ae7f07b3c63d
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoFix 'End of input' exception on netconf session.close() 15/108115/7
Ruslan Kashapov [Mon, 2 Oct 2023 10:29:05 +0000 (13:29 +0300)]
Fix 'End of input' exception on netconf session.close()

On session.close() the channel is closed before the
session state updated. When processing channel closure
event the endOfInput() detects session is still up and
instructs session listener to throw an exception.
Updating state before channel closure eliminates the issue.

JIRA: NETCONF-1106
Change-Id: I0394c808dd13adb5f82290c625d0a04b14c91179
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>