From 9470af8c9d8e26b487b88f8175506bf0b0ca2d04 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 18 Feb 2024 19:22:04 +0100 Subject: [PATCH] Correct device-notification output Stream subscription always results in to stream name, with the actual location being discoverable via stream state. JIRA: NETCONF-1102 Change-Id: Ia66c8d944053536f8d7676e120ab4a558137a6a7 Signed-off-by: Robert Varga --- .../main/yang/odl-device-notification.yang | 26 +++++++++++-------- .../SubscribeDeviceNotificationRpc.java | 13 +++++----- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/restconf/restconf-common-models/src/main/yang/odl-device-notification.yang b/restconf/restconf-common-models/src/main/yang/odl-device-notification.yang index cf6849a99d..266b9a8537 100644 --- a/restconf/restconf-common-models/src/main/yang/odl-device-notification.yang +++ b/restconf/restconf-common-models/src/main/yang/odl-device-notification.yang @@ -20,6 +20,10 @@ module odl-device-notification { accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html"; + revision "2024-02-18" { + description "Corrected output to result in a stream name"; + } + revision "2022-11-06" { description "Initial revision"; @@ -30,16 +34,16 @@ module odl-device-notification { "Subscribe to notifications on specified device."; input { - leaf path { - type instance-identifier; - description "Device mount point path"; - } - } - output { - leaf stream-path { - type inet:uri; - description "Device Notification stream URL"; - } - } + leaf path { + type instance-identifier; + description "Device mount point path"; + } + } + output { + leaf stream-name { + type string; + description "Notification stream name."; + } + } } } diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/mdsal/streams/devnotif/SubscribeDeviceNotificationRpc.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/mdsal/streams/devnotif/SubscribeDeviceNotificationRpc.java index d1918f2e09..b75086a5cb 100644 --- a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/mdsal/streams/devnotif/SubscribeDeviceNotificationRpc.java +++ b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/mdsal/streams/devnotif/SubscribeDeviceNotificationRpc.java @@ -20,9 +20,9 @@ import org.opendaylight.restconf.server.api.OperationsPostResult; import org.opendaylight.restconf.server.spi.OperationInput; import org.opendaylight.restconf.server.spi.RestconfStream; import org.opendaylight.restconf.server.spi.RpcImplementation; -import org.opendaylight.yang.gen.v1.urn.opendaylight.device.notification.rev221106.SubscribeDeviceNotification; -import org.opendaylight.yang.gen.v1.urn.opendaylight.device.notification.rev221106.SubscribeDeviceNotificationInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.device.notification.rev221106.SubscribeDeviceNotificationOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.device.notification.rev240218.SubscribeDeviceNotification; +import org.opendaylight.yang.gen.v1.urn.opendaylight.device.notification.rev240218.SubscribeDeviceNotificationInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.device.notification.rev240218.SubscribeDeviceNotificationOutput; import org.opendaylight.yangtools.yang.common.ErrorTag; import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.QName; @@ -42,9 +42,8 @@ import org.osgi.service.component.annotations.Reference; public final class SubscribeDeviceNotificationRpc extends RpcImplementation { private static final NodeIdentifier DEVICE_NOTIFICATION_PATH_NODEID = NodeIdentifier.create(QName.create(SubscribeDeviceNotificationInput.QNAME, "path").intern()); - // FIXME: NETCONF-1102: this should be 'stream-name' - private static final NodeIdentifier DEVICE_NOTIFICATION_STREAM_PATH_NODEID = - NodeIdentifier.create(QName.create(SubscribeDeviceNotificationInput.QNAME, "stream-path").intern()); + private static final NodeIdentifier DEVICE_NOTIFICATION_STREAM_NAME_NODEID = + NodeIdentifier.create(QName.create(SubscribeDeviceNotificationInput.QNAME, "stream-name").intern()); private final DOMMountPointService mountPointService; private final RestconfStream.Registry streamRegistry; @@ -85,7 +84,7 @@ public final class SubscribeDeviceNotificationRpc extends RpcImplementation { + new YangInstanceIdentifierSerializer(input.databind()).serializePath(path)) .transform(stream -> input.newOperationOutput(ImmutableNodes.newContainerBuilder() .withNodeIdentifier(new NodeIdentifier(SubscribeDeviceNotificationOutput.QNAME)) - .withChild(ImmutableNodes.leafNode(DEVICE_NOTIFICATION_STREAM_PATH_NODEID, stream.name())) + .withChild(ImmutableNodes.leafNode(DEVICE_NOTIFICATION_STREAM_NAME_NODEID, stream.name())) .build())); } } -- 2.36.6