import static org.opendaylight.controller.sal.connect.netconf.InventoryUtils.*
import static extension org.opendaylight.controller.sal.connect.netconf.NetconfMapping.*
+import com.google.common.util.concurrent.Futures
class NetconfDevice implements Provider, //
DataReader<InstanceIdentifier, CompositeNode>, //
val listener = new NetconfDeviceListener(this);
val task = startClientTask(dispatcher, listener)
- if (mountInstance != null) {
- commitHandlerReg = mountInstance.registerCommitHandler(ROOT_PATH, this)
- }
return processingExecutor.submit(task) as Future<Void>;
- //commitHandlerReg = mountInstance.registerCommitHandler(path,this);
}
def Optional<SchemaContext> getSchemaContext() {
deviceContextProvider.createContextFromCapabilities(initialCapabilities);
if (mountInstance != null && schemaContext.isPresent) {
mountInstance.schemaContext = schemaContext.get();
+ val operations = schemaContext.get().operations;
+ for (rpc : operations) {
+ mountInstance.addRpcImplementation(rpc.QName, this);
+ }
}
updateDeviceState()
if (mountInstance != null && confReaderReg == null && operReaderReg == null) {
confReaderReg = mountInstance.registerConfigurationReader(ROOT_PATH, this);
operReaderReg = mountInstance.registerOperationalReader(ROOT_PATH, this);
+ commitHandlerReg = mountInstance.registerCommitHandler(ROOT_PATH, this);
}
} catch (Exception e) {
logger.error("Netconf client NOT started. ", e)
override readConfigurationData(InstanceIdentifier path) {
val result = invokeRpc(NETCONF_GET_CONFIG_QNAME,
- wrap(NETCONF_GET_CONFIG_QNAME, CONFIG_SOURCE_RUNNING, path.toFilterStructure()));
+ wrap(NETCONF_GET_CONFIG_QNAME, CONFIG_SOURCE_RUNNING, path.toFilterStructure())).get();
val data = result.result.getFirstCompositeByName(NETCONF_DATA_QNAME);
return data?.findNode(path) as CompositeNode;
}
override readOperationalData(InstanceIdentifier path) {
- val result = invokeRpc(NETCONF_GET_QNAME, wrap(NETCONF_GET_QNAME, path.toFilterStructure()));
+ val result = invokeRpc(NETCONF_GET_QNAME, wrap(NETCONF_GET_QNAME, path.toFilterStructure())).get();
val data = result.result.getFirstCompositeByName(NETCONF_DATA_QNAME);
return data?.findNode(path) as CompositeNode;
}
Collections.emptySet;
}
- def createSubscription(String streamName) {
- val it = ImmutableCompositeNode.builder()
- QName = NETCONF_CREATE_SUBSCRIPTION_QNAME
- addLeaf("stream", streamName);
- invokeRpc(QName, toInstance())
- }
+// def createSubscription(String streamName) {
+// val it = ImmutableCompositeNode.builder()
+// QName = NETCONF_CREATE_SUBSCRIPTION_QNAME
+// addLeaf("stream", streamName);
+// invokeRpc(QName, toInstance())
+// }
override invokeRpc(QName rpc, CompositeNode input) {
try {
val message = rpc.toRpcMessage(input,schemaContext);
val result = sendMessageImpl(message, messegeRetryCount, messageTimeoutCount);
- return result.toRpcResult(rpc, schemaContext);
-
+ return Futures.immediateFuture(result.toRpcResult(rpc, schemaContext));
} catch (Exception e) {
logger.error("Rpc was not processed correctly.", e)
throw e;
operReaderReg?.close()
client?.close()
}
-
}
package class NetconfDeviceSchemaContextProvider {