X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fconnect%2Fnetconf%2FNetconfDeviceListener.java;h=94f5e166a115e216cf839e52a044bc870c34c661;hp=7ef4569600cb6c10433ec439f16ec6d98e220fa6;hb=6dae254dbc2940d1f0f372d65d69b0e0dda415fe;hpb=2b379f8680220cf2a387cbb120deb38f299d4596 diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceListener.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceListener.java index 7ef4569600..94f5e166a1 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceListener.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceListener.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.sal.connect.netconf; +import com.google.common.collect.Sets; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.FutureListener; @@ -17,6 +18,7 @@ import java.util.Iterator; import java.util.Queue; import java.util.Set; +import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.api.NetconfTerminationReason; import org.opendaylight.controller.netconf.client.NetconfClientSession; @@ -39,6 +41,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; class NetconfDeviceListener implements NetconfClientSessionListener { + private static final class Request { final UncancellableFuture> future; final NetconfMessage request; @@ -80,7 +83,14 @@ class NetconfDeviceListener implements NetconfClientSessionListener { delegate = SchemaSourceProviders.noopProvider(); } - device.bringUp(delegate, caps); + device.bringUp(delegate, caps, isRollbackSupported(session.getServerCapabilities())); + + } + + private static boolean isRollbackSupported(final Collection serverCapabilities) { + // TODO rollback capability cannot be searched for in Set caps + // since this set does not contain module-less capabilities + return Sets.newHashSet(serverCapabilities).contains(NetconfMapping.NETCONF_ROLLBACK_ON_ERROR_URI.toString()); } private synchronized void tearDown(final Exception e) { @@ -137,9 +147,22 @@ class NetconfDeviceListener implements NetconfClientSessionListener { requests.poll(); LOG.debug("Matched {} to {}", r.request, message); - // FIXME: this can throw exceptions, which should result - // in the future failing - NetconfMapping.checkValidReply(r.request, message); + try { + NetconfMapping.checkValidReply(r.request, message); + } catch (IllegalStateException e) { + LOG.warn("Invalid request-reply match, reply message contains different message-id", e); + r.future.setException(e); + return; + } + + try { + NetconfMapping.checkSuccessReply(message); + } catch (NetconfDocumentedException | IllegalStateException e) { + LOG.warn("Error reply from remote device", e); + r.future.setException(e); + return; + } + r.future.set(Rpcs.getRpcResult(true, NetconfMapping.toNotificationNode(message, device.getSchemaContext()), Collections.emptyList())); } else {