[ONOS-7566] Implementation of NetconfProxySession
Change-Id: I01cbe0b10ac36cb6db53127555b551f405acdeb1
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/AbstractNetconfSession.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/AbstractNetconfSession.java
index 2254572..7843f7d 100644
--- a/protocols/netconf/api/src/main/java/org/onosproject/netconf/AbstractNetconfSession.java
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/AbstractNetconfSession.java
@@ -80,6 +80,21 @@
@Override
public abstract CompletableFuture<String> rpc(String request) throws NetconfException;
+ protected CompletableFuture<CharSequence> executeRpc(String rpcString) throws NetconfException {
+ return rpc(rpcString)
+ .thenApply(msg -> {
+ // crude way of removing rpc-reply envelope
+ int begin = msg.indexOf("<data>");
+ int end = msg.lastIndexOf("</data>");
+ if (begin != -1 && end != -1) {
+ return msg.subSequence(begin, end + "</data>".length());
+ } else {
+ // FIXME probably should exceptionally fail here.
+ return msg;
+ }
+ });
+ }
+
@Override
public CompletableFuture<CharSequence> asyncGetConfig(DatastoreId datastore) throws NetconfException {
StringBuilder rpc = new StringBuilder();
@@ -102,7 +117,6 @@
@Override
public CompletableFuture<CharSequence> asyncGet() throws NetconfException {
StringBuilder rpc = new StringBuilder();
-
rpc.append(RPC_OPEN);
rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
rpc.append(GET_OPEN).append(NEW_LINE);
@@ -113,22 +127,6 @@
return executeRpc(rpc.toString());
}
- protected CompletableFuture<CharSequence> executeRpc(String rpcString) throws NetconfException {
- return rpc(rpcString)
- .thenApply(msg -> {
- // crude way of removing rpc-reply envelope
- int begin = msg.indexOf("<data>");
- int end = msg.lastIndexOf("</data>");
- if (begin != -1 && end != -1) {
- return msg.subSequence(begin, end + "</data>".length());
- } else {
- // FIXME probably should exceptionally fail here.
- return msg;
- }
- });
-
- }
-
@Override
public String get(String request) throws NetconfException {
return requestSync(request);
@@ -362,10 +360,14 @@
public abstract Set<String> getDeviceCapabilitiesSet();
@Override
- public abstract void addDeviceOutputListener(NetconfDeviceOutputEventListener listener);
+ public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) throws NetconfException {
+ throw new NetconfException("Only master session can call addDeviceOutputListener");
+ }
@Override
- public abstract void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener);
+ public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) throws NetconfException {
+ throw new NetconfException("Only master session can call removeDeviceOutputListener");
+ }
/**
* Checks errors in reply from the session.