Robert Varga [Mon, 5 May 2025 23:15:44 +0000 (01:15 +0200)]
Fix potential transaction leak
We allocate the transaction too early and if we end up throwing an
exception we end up not aboring it, leading to a leak.
Move allocation to where we need it, making it clear we not lose track
of it.
JIRA: NETCONF-1449
Change-Id: I3f282cb09ab03251c81e36547a27ba60316efc4f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Peter Suna [Tue, 11 Mar 2025 18:43:44 +0000 (19:43 +0100)]
Fix default case in Edit list processing
If an unknown JSON element is present, it can break our JSON parsing
logic, and it will fail with an IllegalStateException.
Fix unhandled default case in processing Edit list in Yang Patch
request. Throw an exception if any unknown field is present.
JIRA: NETCONF-1438
Change-Id: I2f46ce0ce8903e4dcc818702ef83bb04a5e4aa31
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Ivan Hrasko [Tue, 6 May 2025 08:07:36 +0000 (10:07 +0200)]
Break the loop when we find a child
Break the loop over choice cases when have successfully found
the correct child.
JIRA: NETCONF-1454
Change-Id: If945ae142e67ab2b8eff516beaa552d83bc5c11c
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Robert Varga [Mon, 5 May 2025 22:25:01 +0000 (00:25 +0200)]
Hide resolveFilter()
This is an implementation-internal detail for resolving RPC-based
definition. Filter definitions in the datastore cannot contain
references, so the indirection in parsing filters serves only to
confuse.
JIRA: NETCONF-1459
Change-Id: Ia764cf9d03d8b1e8fc6e73053a5145f4f86b1126
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 5 May 2025 21:13:46 +0000 (23:13 +0200)]
Isolate 'filterSpec == null' case
When we have a filter without a spec we should call removeFilter(), not
try to putFilter(null), which will induce a NPE because we try to put it
into a null-hostile map.
This is a known invariant, so cover it with nullness annotations, which
point out problems which will be addressed in subsequent patches.
JIRA: NETCONF-1459
Change-Id: I1e409464810256a2839532caba552c8026a272fd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 5 May 2025 19:30:56 +0000 (21:30 +0200)]
Add NodeIdentifier constants
NodeIdentifier.create() is an expensive operation, hence we should have
constants all around.
Use QNames from generated model sources for filters NodeIdentifiers
when we are at the place.
Change-Id: I5b603ebc0fac449e79fc3325b75aa152736b0563
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Robert Varga [Mon, 5 May 2025 18:36:43 +0000 (20:36 +0200)]
Shorten NodeIdentifier references
NodeIdentifier is a construct of its own, and we already import it
*anyway*, so drop the YangInstanceIdentifier. prefix.
Change-Id: Iece20cc1e2e659885437830eb2bbf0c7ddd0aa42
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 5 May 2025 19:50:20 +0000 (21:50 +0200)]
Fix DTCL registration leak
We are losing a registration, hence failing to unregister, and thus
completely stop, when shut down.
JIRA: NETCONF-1459
Change-Id: I03181c2eb8b99e1c03ca30e486a12d010de1b0a4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 5 May 2025 18:45:18 +0000 (20:45 +0200)]
Fix RequestException instantiation
RequestException operates on String.format() templates, not on Logger
message strings -- but even then the facility does not preserve
exception.
Use a simple error message and log the filter's on debug when this error
occurs.
JIRA: NETCONF-714
Change-Id: I0dd65137b91669541db87aceba27175557c1e3f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Samuel Schneider [Mon, 5 May 2025 12:36:53 +0000 (14:36 +0200)]
Fix typo in establishFilteredSubscription
The stream name was wrong.
JIRA: NETCONF-1436
Change-Id: I69cc659fa2376159937364f41849b790b79b9df5
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Ivan Hrasko [Mon, 5 May 2025 09:35:47 +0000 (11:35 +0200)]
Make parseSubtreeFilter throw RequestException
Make parseSubtreeFilter throw RequestException as it has been
originally designed as it is used from establish and modify
subscription RPCs mainly.
JIRA: NETCONF-714
Change-Id: I42dc53aae37180417787728ecf96047ca9e9b234
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Robert Varga [Mon, 5 May 2025 11:27:54 +0000 (13:27 +0200)]
Remove unneeded FQCN
This is a leftover from moving things around, just use a simple class
name.
Change-Id: I22ba22deed5599c77cff1e9d5c0e58749920d36c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Oleksandr Zharov [Wed, 30 Apr 2025 11:51:37 +0000 (13:51 +0200)]
Unescape XML values when parsing filter
Unescape text values that came from XML before putting them
into SubtreeFilter.
Change-Id: I0d59f3621cdd9e1fb80721a9a75ecd7174f005bd
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Peter Suna [Fri, 7 Mar 2025 16:26:58 +0000 (17:26 +0100)]
Handle RuntimeException in YangPatch
The JsonPatchBody parses the provided JSON, and if any issue occurs
during parsing, it throws a RuntimeException. This results in a 500
error when users provide incorrect data.
Fix this by properly handling RuntimeException in the JsonPatchBody
class.
JIRA: NETCONF-1438
Change-Id: I1ebe8b8c18f6afe6867b11d3a08f27b388c2dfa3
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Peter Suna [Wed, 2 Apr 2025 12:29:49 +0000 (14:29 +0200)]
Remove redundant non null check in JsonPatchBody
Remove the redundant check for a non-null TargetSchemaNode
in JsonPatchBody. Reason:
- The TargetSchemaNode is not used inside this method or under
this if block.
- If the target is not null, then TargetSchemaNode should also
not be null, or it should fail here as an invalid state:
JsonPatchBody.PatchEdit#setTargetSchemaNode()
- The only place where TargetSchemaNode is used is here:
JsonPatchBody#readEditDefinition()
so in this state, it is already checked.
JIRA: NETCONF-1438
Change-Id: Ia08bcbbeb14f425d0b0a430b21257fa6fcf7bffe
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Oleksandr Zharov [Wed, 30 Apr 2025 11:33:47 +0000 (13:33 +0200)]
Remove unnecessary subscription lookup
Romoved unnecessary lookup for subscription that was already
found few lines above.
Change-Id: Ice0216fafa9ec0c05a46d37c456f0c1c938f21c3
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Peter Suna [Tue, 11 Mar 2025 16:49:07 +0000 (17:49 +0100)]
Improve error messaging in YangPatch
The method readValueNodes returns exception message
"Error parsing input" for several error cases.
Fix this by handling each error case individually with a proper
error message.
Fix ErrorType from PROTOCOL to APLICATION, since this error
is not related to the NETCONF protocol.
Fix ErrorTag from MALFORMED_MESSAGE to MISSING_ELEMENT when 'value'
element is required and missing, and to UNKNOWN_ELEMENT when 'value'
element is provided for DELETE, MOVE and REMOVE operation.
Fix JsonPatchBodyTest target path to throw correct exception.
JIRA: NETCONF-1438
Change-Id: I9226ede2d664c1c8c24db1bccc7f412ab929eb34
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Peter Suna [Fri, 7 Mar 2025 18:09:47 +0000 (19:09 +0100)]
Add exception message for missing YangPatch nodes
If any required schema node is missing, an NullPointerException
is thrown without additional information.
Use a custom requireNonNullValue check, which throws a checked
RequestException and adds an exception message specifying
the missing field.
JIRA: NETCONF-1438
Change-Id: I528a65f44d09ccf115533f73874c109cdf80c022
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Oleksandr Zharov [Tue, 18 Mar 2025 09:28:28 +0000 (10:28 +0100)]
Expand filter tests for RPCs
Added test cases for subscription RPCs with filters.
Change JSON format for filter to XML as we expect better support of
YANG anydata with XML.
JIRA: NETCONF-1436
Change-Id: Ib9dfd5adff40456d027ce80f0aa0a2423019dead
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Ivan Hrasko [Mon, 7 Apr 2025 13:51:49 +0000 (15:51 +0200)]
Implement parseSubtreeFilter
Implemented EventStreamFilter interface for SubtreeFilter.
Added logic to parse SubtreeFilter when establishing and
modifying subscription.
JIRA: NETCONF-714
Change-Id: Ic54351c4ebd85c41ad07303617e20a9e143c54f3
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Oleksandr Zharov [Tue, 25 Mar 2025 01:45:19 +0000 (02:45 +0100)]
Implement databind.SubtreeFilterReader
Implemented SubtreeFilterReader method that processes data from
XMLStreamReader and creates SubtreeFilter structure that
corresponds to EffectiveModelContext.
Added tests to cover RFC examples plus some extra for wildcard
and multiple namespace cases.
JIRA: NETCONF-1454
Change-Id: I4d4a05c818672c12ff42258b41d457eb06ec44f0
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Matej Sramcik [Tue, 15 Apr 2025 12:01:36 +0000 (14:01 +0200)]
Adapt subscription termination on session closed
Logic to remove subscription requires request that initiated removing,
but when subscription remove is invoked by channel being inactive,
there is no request.
Separated method is created for cleaning of subscriptions after the
session is closed. Logic from terminateImpl extracted to separated
method with nullable request, so it can be used for both cases.
Removed sending of subscriptionTerminated as there is no one to send
it to.
JIRA: NETCONF-714
Change-Id: Icc237700900be286cf20134abd52c730ff4a769f
Signed-off-by: Matej Sramcik <matej.sramcik@pantheon.tech>
Samuel Schneider [Tue, 1 Apr 2025 17:10:22 +0000 (19:10 +0200)]
Populate subtree filters using DTCL
Populate subtree filters using DOMDataTreeChangeListener.
Parse filters as they are put in to datastore.
JIRA: NETCONF-1459
Change-Id: Ib2517417bfd28fdfb14d76dfd8e603e05733ce81
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Yaroslav Lastivka [Tue, 1 Apr 2025 08:10:29 +0000 (11:10 +0300)]
Implement (databind) SubtreeFilterWriter
Add support for writing SubtreeFilter to XMLStreamWriter,
including proper prefix handling and namespace declarations.
Include unit tests covering exact and wildcard namespace selections.
Implement a PrettyTree representation for SubtreeFilter that produces
a human-readable, XML-style output with appropriate indentation and
namespace binding information.
JIRA: NETCONF-1455
Change-Id: I064bda642b12f3eada96b8a9930c190befa3640b
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Yaroslav Lastivka [Thu, 27 Mar 2025 09:30:05 +0000 (11:30 +0200)]
Implement SubtreeMatcher
Added recursive matching for containment, content, and selection nodes.
Support content matching via a map of QName→expected value.
Handle wildcard selections by iterating over candidate QNames.
Simulate attributes as child leaf nodes.
Added unit tests to cover exact, wildcard, and attribute matching cases.
JIRA: NETCONF-1456
Change-Id: Icc98c00aef663e9a55923af844451453318a8f69
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Peter Suna [Tue, 15 Apr 2025 09:09:03 +0000 (11:09 +0200)]
Fix Leaf-list PUT with single value
This issue is caused when parsing data from JSON/XML to NormalizedNode.
Similar to the MapNode body parser, it produces a single-entry
LeafSetNode, which creates RequestException with message:
'Payload name ((urn:foo)baz-list) is different from identifier name
((urn:foo)baz-list[delta])'
Fix this by providing LeafSetNode child for PUT requests.
JIRA: NETCONF-1452
Change-Id: Ie119088b8f8db19110c2194cb96641fb9f7b20a1
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Peter Suna [Thu, 17 Apr 2025 09:08:48 +0000 (11:08 +0200)]
Fix YANG-PATCH Leaf-list request
If a YANG-PATCH request is sent to populate a single Leaf-list element,
we receive an IllegalArgumentException with the following messages
Create operation:
LeafSetEntryNode is not valid for parent
Merge operation:
Invalid nesting of data.
Similar to List use parent path for leaf-list requests
to resolve this issue.
JIRA: NETCONF-1453
Change-Id: I4d16d803f524b9ace86850023ed95afe4dd12c5e
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Robert Varga [Sat, 26 Apr 2025 01:17:17 +0000 (03:17 +0200)]
Remove restconf-notifications
Move the two classes we have here to restconf-server and eliminate this
artifact, as it is superfluous.
Change-Id: I2f21da108cc480fc55aebd2dea302ade64e92663
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 11 Apr 2025 00:37:17 +0000 (02:37 +0200)]
Integrate ContextListener
Source routing here is inherent to MdsalRestconfStreamRegistry,
integrate ContextListener there and hide the start method -- it should
only be called by subclasses.
JIRA: CONTROLLER-714
Change-Id: Ifdf74ee9e232d7519f20a872e576bf766834bac3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 25 Apr 2025 16:55:09 +0000 (18:55 +0200)]
Migrate CreateDataChangeEventSubscriptionRpcTest
Use a test subclass and do not worry about the actual DataBroker
invocations.
Change-Id: I70044d1ff099a5c2fab9730e6730ba879c312e11
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Peter Suna [Wed, 16 Apr 2025 11:54:32 +0000 (13:54 +0200)]
Fix GET for Leaf-list entry
When a request is sent to get specific leaf-list data, such as:
“yang-ext:mount/foo:foo/baz-list=alpha"
The request fails with a 500 Server Error.
Fix this by wrapping the result in a LeafSetNode to serialize
it properly.
JIRA: NETCONF-1451
Change-Id: Iab704a09c8a17975ab2470facb40eea096560f02
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Robert Varga [Sun, 20 Apr 2025 06:45:31 +0000 (08:45 +0200)]
Bump upstreams
Adopt:
- odlparent-14.0.9
- infrautils-7.1.3
- yangtools-14.0.13
- mdsal-14.0.12
Change-Id: Ia9ceb5c0eedbdfedcfc7b51bdf1fab56dc0b0903
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 11 Apr 2025 09:16:53 +0000 (11:16 +0200)]
Rename restconf-it packages
Use org.opendaylight.restconf.it prefix for all these in order to
prevent potential clashes.
Change-Id: I5680b18df31362e2bb2b994244830069e2b15425
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 11 Apr 2025 09:01:47 +0000 (11:01 +0200)]
Clean up abstract tests
Do not reference 'Router' services, but rather pick the up from
DOM{Notification,Rpc}Router directly. Also make sure we shut them down
correctly.
Change-Id: I729087829da1f7dbb11b73c0105c5db16865fb50
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Oleksandr Zharov [Wed, 9 Apr 2025 18:35:45 +0000 (20:35 +0200)]
Expand ContentMatchNode values to Map
Since SubtreeFilter supports wildcards in the filter,
there may be to cases when one element can correspond
to multiple nodes in the model context.
This means that wildcard content nodes can also have many
nodes with matching local name. For all these nodes
we should parse and store value separately in the qname
to value map.
JIRA: NETCONF-1454
Change-Id: I681d2ee150392ace2f4d1d9305632a40677e530e
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Peter Suna [Tue, 1 Apr 2025 10:24:27 +0000 (12:24 +0200)]
Move session check before acquiring semaphore
If currentSession is null, we decrease semaphore without
restoring its state afterward.
Check if currentSession is not null before acquiring semaphore to
prevent permanent semaphore decrease.
JIRA NETCONF-1462
Change-Id: I8aad89b137720ef7f805bba7f155f37ef1d6558d
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Robert Varga [Fri, 11 Apr 2025 00:08:43 +0000 (02:08 +0200)]
Move ContextListener
ContextListener is really providing support to MD-SAL version of
RestconfStream.Registry. Move it along DefaultNotificationSource to
restconf-server-mdsal, adjusting dependencies accordingly.
JIRA: NETCONF-714
Change-Id: I06b978b555b36a096d8ad32d28dcc1b657e3105c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 10 Apr 2025 23:19:01 +0000 (01:19 +0200)]
Remove unneeded locals
We are using a fluent builder, hence we can just pass the resulting
object without using a local variable.
Change-Id: Ia375a877d02f83cdc4e771612db3727a19ce47f1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Oleksandr Zharov [Fri, 4 Apr 2025 18:06:03 +0000 (20:06 +0200)]
Remove SubscriptionStateMachine
Move SubscriptionState keeping from SubscriptionStateMachine to
each Subscription, forcing the move of SubscriptionState to
server.spi.RestconfStream.
The moveTo() method is split into SubscriptionState.canMoveTo(), which
performs the check and AbstractRestconfStreamSubscription's part, which
does the exception throwing.
JIRA: NETCONF-1461
Change-Id: I052fcf0a6a540ae8d9c5b0a01719edbb718d6011
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Ivan Hrasko [Mon, 7 Apr 2025 10:20:53 +0000 (12:20 +0200)]
Fix deadlock with KeepaliveTask & Session lock
KeepaliveTask needs to guard suppressed and suppressedCounter fields
using thread locking only.
To avoid deadlock do not lock external method call:
devRpc#invokeNetconf as it uses its own locking mechanism based
on session lock in NetconfDeviceCommunicator class.
JIRA: NETCONF-1458
Change-Id: Idb9a04f2284fc98e5d1d2aee3d1ffafdd318504e
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Ivan Hrasko [Mon, 7 Apr 2025 08:24:41 +0000 (10:24 +0200)]
Remove SubtreeFilterRestconf
Remove SubtreeFilterRestconf, this logic will be replaced by
SubtreeMatcher which will provide just boolean test to accept or
reject notification before sending to the client.
JIRA: NETCONF-714
Change-Id: Ia368d6870f68b9bd498733b421233bbeee638684
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Peter Suna [Wed, 19 Mar 2025 19:40:23 +0000 (20:40 +0100)]
Handle IllegalStateException for Put & PatchData
If the JSON body contains an invalid node while parsing with
JsonParserStream, IllegalStateException is thrown. If this exception
is not caught, it result in a 500 error without additional information.
JIRA: NETCONF-1439
Change-Id: I4c1bf41ad134accc06ebdbffdce4cbdca70c069d
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Samuel Schneider [Wed, 2 Apr 2025 16:26:53 +0000 (18:26 +0200)]
Fix typos in filtering and counters tests
Fix some typos left in filtering and counters tests
JIRA: NETCONF-1436
Change-Id: I9eda3e26d1722c9cb02a244dffc63612159931ca
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Samuel Schneider [Thu, 6 Mar 2025 16:19:58 +0000 (17:19 +0100)]
Adapt ModifySubscriptionRpc
Adapt ModifySubscriptionRpc to changes in RestconfStream.
Add possibility to modify filter in RestconfStream.Subscription
and propagate this change in to operational datastore.
Now we provide correct response to invoke of this rpc,
in case of error correct error message, after filtering is finished
correctly update datastore, instead of "Not implemented yet".
JIRA: NETCONF-714
Change-Id: If6487621d5a2ff378be7f9f9089351df75a50ff4
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Samuel Schneider [Tue, 4 Mar 2025 16:26:03 +0000 (17:26 +0100)]
Add test for filtering part of notification
Test is disabled for now as this logic is not
implemented yet.
JIRA: NETCONF-1436
Change-Id: I1adbb702b9d4e17af6dcd0c82bcd80e43ebd289e
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Samuel Schneider [Wed, 12 Feb 2025 12:11:11 +0000 (13:11 +0100)]
Add test cases for filtering and counters
Add tests for filtering notifications and tests if
sent event record and excluded event records counters
are updated correctly.
Tests are disabled for now as this logic is not
implemented yet.
JIRA: NETCONF-1436
Change-Id: I6c389bcf4c71880784de660fef7824c1bbf8fc57
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Samuel Schneider [Tue, 25 Mar 2025 08:14:59 +0000 (09:14 +0100)]
Change SubscriptionHolder to only store id
Change SubscriptionHolder to only store id, and use
streamRegistry to look up subscription when needed.
We want to keep subscriptions immutable, with this
change there will be no need to update or create new
SubscriptionHolder when subscription is modified.
JIRA: NETCONF-714
Change-Id: Iea68917f5a17bcde7376aa0c381aaba500ca75a2
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Samuel Schneider [Wed, 26 Mar 2025 16:22:51 +0000 (17:22 +0100)]
Separate createLegacyStream in StreamRegistry
Create separate method for creating legacy streams, which will
not close after last subscriber is removed.
JIRA: NETCONF-714
Change-Id: Id3ca9675475247481fec4a1a26c40290d779e269
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Oleksandr Zharov [Thu, 27 Mar 2025 12:01:13 +0000 (13:01 +0100)]
Fix SubtreeFilter wildcard text example
Fixed example xml used for testing wildcard filter node in
SubtreeFilterFromElementTest.
JIRA: NETCONF-1445
Change-Id: I2e256f960e69ebb1d9ced4348971ba92fcb339fb
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Matej Sramcik [Thu, 27 Mar 2025 10:07:13 +0000 (11:07 +0100)]
Use OnCommitFuture in subscription termination
Use OnCommitFutureCallback instead of FutureCallback in subscription
termination, so in case of failure we get Exception instead of
Throwable.
JIRA: NETCONF-714
Change-Id: I147c6a3c3a068d0e4bc47a9d5926f74c3a343f17
Signed-off-by: Matej Sramcik <matej.sramcik@pantheon.tech>
Oleksandr Zharov [Thu, 13 Mar 2025 12:53:11 +0000 (13:53 +0100)]
Finish up the SubtreeFilterPrettyTree
Finished recursion logic in SubtreeFilterPrettyTree that generates
pretty tree from filter and addressed FIXMEs.
Added test to cover this logic.
JIRA: NETCONF-1445
Change-Id: Ib02d3eab83fc1038796d45571d09c451cfc79b42
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Oleksandr Zharov [Wed, 5 Mar 2025 17:18:21 +0000 (18:18 +0100)]
Implement SubtreeFilter#writeTo
Implemented SubtreeFilter method to write filter to an Element.
Added test that covers examples from RFC6241.
JIRA: NETCONF-1445
Change-Id: Idb4c4ef6556457e81454cae65d348c4ba1dde311
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Samuel Schneider [Mon, 24 Mar 2025 14:09:26 +0000 (15:09 +0100)]
Store correct Subscription in StreamRegistry
Currently, we are loosing result of createSubscription(subscription)
and storing only SubscriptionImpl in subscriptions map inside
StreamRegistry. This leads to lookupSubscription() returning only
SubscriptionImpl and for example termination() is only invoked on
SubscriptionImpl and MdsalRestconfStreamSubscription is never
terminated as we don't have access to it, this leads to subscription
not being deleted from datastore.
JIRA: NETCONF-714
Change-Id: I4bb59db9cb432e851f7dd5f372685f708e1b03ff
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Yaroslav Lastivka [Tue, 4 Mar 2025 14:58:49 +0000 (16:58 +0200)]
Add sent-event-records counter
Added updateReceiver() method to MdsalRestconfStreamRegistry to update
per-receiver counters in the operational datastore.
Added ReceiverHolder to encapsulate receiver identification
(subscriptionId, receiverName) and provide access to local counter
values. Added ChannelSenderSubscription class to handle HTTP/1
event streaming and update per-receiver counters via the Registry.
JIRA: NETCONF-1449
Change-Id: Ifa9f101d6d27b13ef74bf5e03084bddbb83af66b
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
Matej Sramcik [Wed, 12 Feb 2025 09:42:22 +0000 (10:42 +0100)]
Create notification listening test
Create test which invoke notification and listen for it on stream and
test if modified, deleted, and killed notification are received after
interaction with subscription.
JIRA: NETCONF-714
Change-Id: Ide8d3603c68cb326d8c382593dccf41f243c2b33
Signed-off-by: Matej Sramcik <matej.sramcik@pantheon.tech>
Matej Sramcik [Tue, 11 Feb 2025 13:47:36 +0000 (14:47 +0100)]
Add Stream client for tests
Added creation of sse stream and listener to subscription stream.
JIRA: NETCONF-714
Change-Id: I4e719ea7e08254e4170eab34e1958e1e62194d7b
Signed-off-by: Matej Sramcik <matej.sramcik@pantheon.tech>
Samuel Schneider [Wed, 5 Mar 2025 13:21:18 +0000 (14:21 +0100)]
Fix termination RPCs requests not being completed
Fix problem with DeleteSubscriptionRpc and KillSubscriptionRpc
requests are not being completed.
JIRA: NETCONF-714
Change-Id: Ieea7e8354a5077d7654c077e309756533c7b4066
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Samuel Schneider [Tue, 18 Mar 2025 08:28:09 +0000 (09:28 +0100)]
Remove stop-time form ModifySubscriptionRpc
Remove stop-time as it won't be supported.
JIRA: NETCONF-714
Change-Id: Ia5c32af028c8f2d69c66a3f278dc78d27c427c32
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Peter Suna [Tue, 11 Mar 2025 18:27:06 +0000 (19:27 +0100)]
Throw RequestException in case of multiple value
If provided JSON body contains multiple "value" leafs,
throw RequestException instead of IllegalArgumentException.
JIRA: NETCONF-1438
Change-Id: I8a61623b9260a6a27c7c2de70bc6b780b9cfa7a9
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Robert Varga [Wed, 19 Mar 2025 22:28:26 +0000 (23:28 +0100)]
Remove maven-bundle-plugin override
We have a workaround for KARAF-7927, hence we can remove the version
override.
Change-Id: I8c913187c1ae8781e94ef3a89ee9a3fc45271324
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Samuel Schneider [Wed, 12 Mar 2025 11:24:25 +0000 (12:24 +0100)]
Disable KillSubscriptionRpc
Disable KillSubscriptionRpc until we get NACM integrated,
as otherwise anybody can kill everybody's subscription.
JIRA: NETCONF-714
Change-Id: I0f628bc145a60c02fd36c55e65f6cee179d028b6
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Oleksandr Zharov [Tue, 4 Mar 2025 12:49:32 +0000 (13:49 +0100)]
Implement SubtreeFilter#readFrom
Implemented SubtreeFilter method to read filter from an Element.
Added more test to cover examples from RFC6241.
JIRA: NETCONF-1445
Change-Id: I6debd0eb7984734b268729ef04b68a3378b01a93
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Robert Varga [Sat, 8 Mar 2025 16:13:35 +0000 (17:13 +0100)]
Bump upstreams
Adopt:
- odlparent-14.0.8
- yangtools-14.0.11
- mdsal-14.0.11
Change-Id: I4559bd855a53d6f613d27b088852ebed17798b8d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Ivan Hrasko [Tue, 4 Mar 2025 12:53:32 +0000 (13:53 +0100)]
Initialize default NETCONF stream
Expose start method in AbstractRestconfStreamRegistry to be able to
start predefined NETCONF stream with its current Source.
JIRA: NETCONF-714
Change-Id: I549eafa141638f9026cfbe222e98151a4d14b4fe
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Ivan Hrasko [Tue, 4 Mar 2025 12:17:18 +0000 (13:17 +0100)]
Move context listener to MDSAL plugins
Move MDSAL based context listener to MDSAL based plugins.
In addition, we can remove NetconfStream class and directly initialize
ContextListener as component instead.
JIRA: NETCONF-714
Change-Id: I7217ba99076df936c892e6341925d0a5ba878526
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Robert Varga [Wed, 5 Mar 2025 12:27:50 +0000 (13:27 +0100)]
Bump mina-sshd to 2.15.0
https://github.com/apache/mina-sshd/releases/tag/sshd-2.15.0
Change-Id: Iac2cc0ed6f29767af029ffd7211a20829ba130da
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 25 Feb 2025 19:29:14 +0000 (20:29 +0100)]
Add netconf.databind.Subtree
This adds the basic structure of a netconf subtree filter bound to a
DatabindContext.
JIRA: NETCONF-1446
Change-Id: Ic2d952522b9bccc4c1d4353cd7255d915c511c39
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 4 Mar 2025 13:00:21 +0000 (14:00 +0100)]
Remove deprecated constructors
ApiPath.ApiIdentifier and ApiPath.Step have deprecated constructors,
remove them.
Change-Id: Iac1841ef985738877febc4def36724e41c698088
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 4 Mar 2025 12:56:10 +0000 (13:56 +0100)]
Remove EffectiveOperation methods
isAsDefaultPermitted() and isOnElementPermitted() have been deprecated
for a long time, remove them now.
Change-Id: Id81a8b0da96fad7c03a51ea58144ee8288b0d9a5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 4 Mar 2025 11:51:06 +0000 (12:51 +0100)]
Remove unnecessary method
ContentMatchNode is a record, hence we do not need the accessor method.
JIRA: NETCONF-1445
Change-Id: Ia5883905956eb46bd0ba5e44f61619ac2ab015f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 3 Mar 2025 13:07:56 +0000 (14:07 +0100)]
Eliminate netconf/tools/
Move the two utilities we have into usecase/, as these really are
specific use cases.
Change-Id: Ibc39da22da86de48c4741a7819515f2018934c57
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 3 Mar 2025 13:05:23 +0000 (14:05 +0100)]
Be more defensive when converting subscription id
Uint32.valueOf() can throw an IAE, make sure we intercept it.
JIRA: NETCONF-714
Change-Id: I49da217e3139e2ff53d620a274c81e545a807c11
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 3 Mar 2025 10:57:52 +0000 (11:57 +0100)]
Implement lookupSubscription()
This is similar to what we are doing for streams: populate on estabish,
remove when the subscription is terminated.
JIRA: NETCONF-714
Change-Id: I97641150218953dac0ef01a68aee6aab02eb0edf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 2 Mar 2025 21:44:49 +0000 (22:44 +0100)]
Add AbstractRequest.principal()
Require the principal to be passed down as an invariant. This codifies
what JAX-RS needs to do and what Netty has as an invariant in the
attached structure.
Change-Id: I74020f0a0824583ce604a9c9fd5665986d3f880d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 2 Mar 2025 20:50:29 +0000 (21:50 +0100)]
Factor out netconf.databind.Request
This is the counterpart to yang.common.RpcRequest, except having a nice
tie in with RequestException as the error reporting tool.
Change-Id: Ic6c3df7351fe4c7fd3e33509d1fc5af208cc6c59
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 2 Mar 2025 16:16:47 +0000 (17:16 +0100)]
Promote restconf.server.api.ServerException
Move this construct to netconf.binding.RequestException, so it can be
used outside of RESTCONF server.
Change-Id: I3e58668b83c9c70c2222385ceddb0980191a4547
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 2 Mar 2025 12:01:03 +0000 (13:01 +0100)]
Introduce netconf.databind.RequestError
Promote restconf.server.api.ServerError for reuse by all components that
use netconf.databind.
Change-Id: I631219aff53b24c31acb5ab29844493266feef05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 21 Feb 2025 02:18:36 +0000 (03:18 +0100)]
Merge RestconfStreamRegistry implementations
Move code around so that the RPC implements ends up calling down to
RestconfStream.Registry, which does the book-keeping.
Operational store maintenance is done via registration mechanics in
MdsalRestconfStreamRegistry.
ModifySubscriptionRpc is neutered for now, as are some tests which need
more work around assertions and setup.
JIRA: NETCONF-714
Change-Id: I665e20f9d12bb5800b3749ada0cf009a7c3b4423
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 2 Mar 2025 07:45:09 +0000 (08:45 +0100)]
Disconnect netconf-common-mdsal from netconf-api
The only user of NormalizedDataUtil is netconf-client-mdsal, so we move
that class and all of its supports there.
This allows us to disconnect from netconf-api, improving the dependency
graph.
Change-Id: I8151460ef01439249a8ea7018c93c3af75140e18
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 2 Mar 2025 07:51:26 +0000 (08:51 +0100)]
Fix sal-remote-impl dependencies
We do not need netconf-dom-api, do not import it.
Change-Id: I17ef125736da011d8fa44545042248b13ac3546e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 2 Mar 2025 07:31:56 +0000 (08:31 +0100)]
Disconnect netconf-{common,server}-mdsal
The only reason for netconf-server-mdsal's use of netconf-common-mdsal
is a simple ContainerNode writeout. Inline the callout and drop
the dependency.
Change-Id: I7628e17a6048b2a524c42875681d687f169ebe9f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 27 Feb 2025 08:37:51 +0000 (09:37 +0100)]
Bump upstreams
Use mdsal-14.0.10.
Change-Id: I999a5e337410fced0e77d2c1a14f6b962ff5fc11
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 23 Feb 2025 02:05:28 +0000 (03:05 +0100)]
Add netconf.api.subtree.SubtreeFilter
SubtreeFilter is the object model of a RFC6241 Subtree Filter. It can be
read from and written to a org.w3c.dom.Element.
JIRA: NETCONF-1445
Change-Id: I86d471cf3eb064ef980f79af91858dfa6d247a25
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Peter Suna [Tue, 18 Feb 2025 11:16:31 +0000 (12:16 +0100)]
Notify channel on KeyEstablished exception
Call notifyTransportChannelFailed method when SshClient
failed on KeyEstablished with the IOException.
If IOException close the session and TransportChannel
is not ready, then it is necessary to call
notifyTransportChannelFailed which triggers the reconnection process.
JIRA: NETCONF-1423
Change-Id: I5aa4714a3d941b7ba6b1a26d95ea10b7af83840a
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Peter Suna [Mon, 17 Feb 2025 08:16:50 +0000 (09:16 +0100)]
Notify channel if authentication throw exception
Call notifyTransportChannelFailed method when SshClient
or SshServer invokes IOException. Propagate this exception and
notifyTransportChannelFailed, which triggers the
reconnection process.
JIRA: NETCONF-1423
Change-Id: I52c775634df61e2ce1a85cdd10e6e10de4e0c695
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Peter Suna [Mon, 17 Feb 2025 08:28:34 +0000 (09:28 +0100)]
Notify transport channel on session disconnect
Call notifyTransportChannelFailed method when SshClient
or SshServer invokes sessionDisconnect.
This state call the session close. If TransportChannel
is not ready, then it is necessary to call
notifyTransportChannelFailed which triggers the reconnection process.
JIRA: NETCONF-1423
Change-Id: I1b96f36e8bd6d15865a8b1a9718bb45e401898e2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Robert Varga [Fri, 22 Nov 2024 19:44:39 +0000 (20:44 +0100)]
Notify transport channel on session exception
Call notifyTransportChannelFailed method when SshClient
or SshServer invokes sessionException. Propagate exception
from the parameter and notifyTransportChannelFailed which
triggers the reconnection process.
JIRA: NETCONF-1423
Change-Id: Id4ab70c0b1f37c5a8f52c5447cefb77f4b708265
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Peter Suna [Tue, 5 Nov 2024 12:25:18 +0000 (13:25 +0100)]
Notify transport channel on session close
Call notifyTransportChannelFailed method when SshClient
or SshServer invokes sessionClosed.
If ChannelInactive close the session and TransportChannel
is not ready, then it is necessary to call
notifyTransportChannelFailed which triggers the reconnection process.
This needs to be handled here, because the NetconfClientSession
lifecycle has not started yet. The NetconfClientSession is created
in NetconfNodeHandler only when ClientTransportChannelListener is
successful. If ClientTransportChannelListener is successful and session
is closed, then ConnectingTask will never finish nor provide any
additional information.
JIRA: NETCONF-1423
Change-Id: Ief230b2d28a747628488d0dba3700fbb552d163d
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Robert Varga [Tue, 25 Feb 2025 23:24:41 +0000 (00:24 +0100)]
Modernize ApiPathParser
Two things to do here:
- use arrow switches
- eliminate the need to suppress checkstyle
Change-Id: I533f03a20d089c1e9a71033801d119cbe5d4731b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Samuel Schneider [Thu, 13 Feb 2025 16:09:07 +0000 (17:09 +0100)]
Fix subscription state notifications
Fix NodeIdentifiers for subscription state notifications
currently have wrong NodeIdentifier which is not recognized
by registered listener.
Also fix node structure as is not correct and EventFormatter
is not able to processes them when we are trying to publish.
JIRA: NETCONF-714
Change-Id: I41f67e76be7933c4cb65973a4e26730f2c4004bd
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Robert Varga [Tue, 25 Feb 2025 00:39:21 +0000 (01:39 +0100)]
Use "xc" instead of "op"
We are using a made-up prefix here, use the prefix RFC4741 uses.
Change-Id: I2442dbf6fed9fb56f3b4bd1048878d1b3b172ac3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 25 Feb 2025 00:09:42 +0000 (01:09 +0100)]
Encapsulate NormalizedDataUtil.XML_FACTORY
NormalizedDataUtil is performing some namespace plumbing with
XMLStreamWriter. Document what is going on and why, moving the entire
chunk into XMLSupport.
Change-Id: Ifec14bfa2e04bf7c7a66bfc29c022ca38b25f7f5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 24 Feb 2025 22:06:37 +0000 (23:06 +0100)]
Add netconf.api.xml.XMLSupport
netconf-common-mdsal is interfacing with java.xml side of things here.
Encapsulate these in a netconf-api class.
Change-Id: I9bbc0fe736148a3455fc6c19a25441f033c8cbbe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 25 Feb 2025 00:08:31 +0000 (01:08 +0100)]
Strip message-id from rpc-reply
We are the final processor of a NetconfMessage containg a rpc-reply:
strip message-id from it, as does not belong to YANG world.
JIRA: NETCONF-856
Change-Id: Ib8e7b9922682343a3bb28d84ce40179fe7c4dc42
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 24 Feb 2025 20:32:30 +0000 (21:32 +0100)]
Propagate DatabindContext to NetconfBaseOps
This is where Rpcs and DatabindContext meet for the first time,
providing the core anchor point where things need to be consistent.
JIRA: NETCONF-1352
Change-Id: I035c134c2c37d8c559402322a6ff9dc1d80affeb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 24 Feb 2025 20:44:59 +0000 (21:44 +0100)]
Expose DatabindContext.builderFactory()
NormalizedNode.BuilderFactory is the interface for modular injection of
builders. Expose it from the databind, showing off its versatility.
Change-Id: I82ecf1306f429433ecd5aa6aa14f1c273bfaa40e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 25 Feb 2025 01:49:35 +0000 (02:49 +0100)]
Mock NetconfTimer
We are already mocking a ton of things here, another mock does not
matter.
Change-Id: I0d89389fbc75add2b86383cbff6359d21dbf8995
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 24 Feb 2025 23:49:46 +0000 (00:49 +0100)]
Do not instantiate Inference
XMLStreamWriter can resolve SchemaNodeIdentifiers, so just pass
outputPath down.
Change-Id: I9c304ed580b06ba0d6b32b30ad3fa315da724db5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 24 Feb 2025 19:50:59 +0000 (20:50 +0100)]
Improve DatabindContext reuse
Carry the DatabindContext through discovery, so when there is nothing
to do we just return it as is.
JIRA: NETCONF-1352
Change-Id: I5a9ac0254f88cc071f5bc29eb3b6aa08cda8d340
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 24 Feb 2025 19:00:44 +0000 (20:00 +0100)]
Use NetconfDeviceSchema in NetconfDeviceSchema
We have a MountPointContext, from which we invariably end up creating a
DatabindContext. Replace it with DatabindContext an equivalent
DatabindContext.
JIRA: NETCONF-1352
Change-Id: I461d40bf4a87e5e8bca0f9595731791885c433d5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>