ONOS-3577 Adding getConfig with realtive config XML-tree argument
Change-Id: I3ee69bea55352e35007826659277c839d8457d3f
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
index 2a19514..2f02125 100644
--- a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
@@ -28,6 +28,7 @@
/**
* Retrives the requested configuration, different from get-config.
+ *
* @param request the XML containing the request to the server.
* @return device running configuration
*/
@@ -35,6 +36,7 @@
/**
* Executes an RPC to the server.
+ *
* @param request the XML containing the RPC for the server.
* @return Server response or ERROR
*/
@@ -69,6 +71,16 @@
boolean editConfig(String newConfiguration) throws IOException;
/**
+ * Retrives part of the specified configuration based on the filterSchema.
+ * @param targetConfiguration the targetConfiguration to change
+ * @param mode selected mode to change the configuration
+ * @param newConfiguration configuration to set
+ * @return true if the configuration was edited correctly
+ */
+ boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
+ throws IOException;
+
+ /**
* Copies the new configuration, an Url or a complete configuration xml tree
* to the target configuration.
* The target configuration can't be the running one
@@ -105,6 +117,7 @@
/**
* Closes the Netconf session with the device.
* the first time it tries gracefully, then kills it forcefully
+ *
* @return true if closed
*/
boolean close() throws IOException;
@@ -125,6 +138,7 @@
/**
* Sets the device capabilities.
+ *
* @param capabilities list of capabilities the device has.
*/
void setDeviceCapabilities(List<String> capabilities);
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
index 1eff32a..ab7c746 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
@@ -195,6 +195,29 @@
}
@Override
+ public boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
+ throws IOException {
+ newConfiguration = newConfiguration.trim();
+ StringBuilder rpc = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ rpc.append("<rpc message-id=\"" + messageID + "\" "
+ + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
+ rpc.append("<edit-config>");
+ rpc.append("<target>");
+ rpc.append("<" + targetConfiguration + "/>");
+ rpc.append("</target>");
+ rpc.append("<default-operation>");
+ rpc.append(mode);
+ rpc.append("</default-operation>");
+ rpc.append("<config>");
+ rpc.append(newConfiguration);
+ rpc.append("</config>");
+ rpc.append("</edit-config>");
+ rpc.append("</rpc>");
+ rpc.append(endpattern);
+ return checkReply(doRequest(rpc.toString()));
+ }
+
+ @Override
public boolean copyConfig(String targetConfiguration, String newConfiguration)
throws IOException {
newConfiguration = newConfiguration.trim();
@@ -322,6 +345,7 @@
return true;
}
}
+ log.warn("Error in reply {}", reply);
return false;
}