From 09b370c46b569841501b85e1b54b602af2e3e327 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 28 Jan 2024 04:50:14 +0100 Subject: [PATCH] NetconfRpcService should be extensible We are capturing a good base contract, but the documentation contradicts the actual implementation. The difference is that the API says it supports RFC4741/6241, but in reality we also support RFC6020 and (optionally) RFC5277/6470. This patch turns to DOMExtensibleService to allow for a baseline service which potentially has extensions. Change-Id: I541b9f76c6eecbbf85f593b68cd0ade6c5c286e6 Signed-off-by: Robert Varga --- .../client/mdsal/api/NetconfRpcService.java | 110 +++++++++++++++++- 1 file changed, 106 insertions(+), 4 deletions(-) diff --git a/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/api/NetconfRpcService.java b/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/api/NetconfRpcService.java index 94be90bcbe..67b1e30f4e 100644 --- a/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/api/NetconfRpcService.java +++ b/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/api/NetconfRpcService.java @@ -9,19 +9,50 @@ package org.opendaylight.netconf.client.mdsal.api; import com.google.common.util.concurrent.ListenableFuture; import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.mdsal.dom.api.DOMExtensibleService; import org.opendaylight.mdsal.dom.api.DOMRpcException; import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.mdsal.dom.api.DOMService; +import org.opendaylight.mdsal.dom.api.DOMServiceExtension; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.CancelCommit; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.CloseSession; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.Commit; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.CopyConfig; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.DeleteConfig; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.DiscardChanges; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditConfig; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.Get; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.GetConfig; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.KillSession; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.Lock; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.Unlock; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.Validate; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscription; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.GetSchema; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.YangConstants; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; /** - * A {@link DOMService} capturing the ability to invoke RPCs which are defined in RFC4741 and in RFC6241. + * A {@link DOMService} capturing the ability to invoke NETCONF RPCs through + * {@link #invokeNetconf(QName, ContainerNode)}. */ -public interface NetconfRpcService extends DOMService { +public interface NetconfRpcService extends DOMExtensibleService { /** - * Invoke a base RFC4741/RFC6241 RPC, e.g. those in {@link YangConstants#NETCONF_NAMESPACE}. + * Invoke a well-known RPC. This method is guaranteed to support the following RPCs: + *
    + *
  • {@link CloseSession}
  • + *
  • {@link CopyConfig}
  • + *
  • {@link DeleteConfig}
  • + *
  • {@link EditConfig}
  • + *
  • {@link Get}
  • + *
  • {@link GetConfig}
  • + *
  • {@link KillSession}
  • + *
  • {@link Lock}
  • + *
  • {@link Unlock}
  • + *
+ * + *

+ * The support for other RPCs is advertized through {@link #getExtensions()}. * * @param type QName of the RPC to be invoked * @param input Input arguments, null if the RPC does not take any. @@ -29,4 +60,75 @@ public interface NetconfRpcService extends DOMService { * of {@link DOMRpcException} reporting a transport error. */ @NonNull ListenableFuture invokeNetconf(@NonNull QName type, @NonNull ContainerNode input); + + /** + * Extensions to {@link NetconfRpcService} defining additional RPC availability. + */ + // Note: This is not an interface on purpose, to make the set of extensions well-known + enum Extension implements DOMServiceExtension { + /** + * This device supports + * Candidate Configuration Capability. + * The following RPCs are supported: + *

    + *
  • {@link Commit}
  • + *
  • {@link DiscardChanges}
  • + *
+ */ + CANDIDATE, + /** + * This device supports + * Confirmed Commit Capability 1.0. + * The following RPCs are supported: + *
    + *
  • {@link Commit}
  • + *
  • {@link DiscardChanges}
  • + *
+ */ + CONFIRMED_COMMIT_1_0, + /** + * This device supports + * Confirmed Commit Capability 1.1. + * The following RPCs are supported: + *
    + *
  • {@link CancelCommit}
  • + *
  • {@link Commit}
  • + *
  • {@link DiscardChanges}
  • + *
+ */ + CONFIRMED_COMMIT_1_1, + /** + * This device supports NETCONF Monitoring. The following + * RPCs are supported: + *
    + *
  • {@link GetSchema}
  • + *
+ */ + MONITORING, + /** + * This device supports Event Notifications. The following + * RPCs are supported: + *
    + *
  • {@link CreateSubscription}
  • + *
+ * {@link CreateSubscription} is supported. + */ + NOTIFICATIONS, + /** + * This device supports Validate Capability. + * The following RPCs are supported: + *
    + *
  • {@link Validate}
  • + *
+ */ + VALIDATE_1_0, + /** + * This device supports Validate Capability. + * The following RPCs are supported: + *
    + *
  • {@link Validate}
  • + *
+ */ + VALIDATE_1_1; + } } -- 2.36.6