|
31 | 31 | import java.nio.charset.Charset;
|
32 | 32 | import java.util.Arrays;
|
33 | 33 | import java.util.List;
|
| 34 | +import java.util.Locale; |
34 | 35 |
|
35 | 36 | /**
|
36 | 37 | * A <code>Device</code> is used to define a Netconf server.
|
@@ -838,14 +839,48 @@ public XML getRunningConfig(String configTree) throws SAXException,
|
838 | 839 | return this.netconfSession.getRunningConfig(configTree);
|
839 | 840 | }
|
840 | 841 |
|
841 |
| - public XML getRunningConfigAndState(String filter) throws IOException, SAXException { |
| 842 | + /** |
| 843 | + * Retrieve the running configuration, or part of the configuration. |
| 844 | + * |
| 845 | + * @param xpathFilter example <code><filter xmlns:model='urn:path:for:my:model' select='/model:*'></filter></code> |
| 846 | + * @return configuration data as XML object. |
| 847 | + * @throws java.io.IOException If there are errors communicating with the netconf server. |
| 848 | + * @throws org.xml.sax.SAXException If there are errors parsing the XML reply. |
| 849 | + */ |
| 850 | + public XML getRunningConfigAndState(String xpathFilter) throws IOException, SAXException { |
| 851 | + if (netconfSession == null) { |
| 852 | + throw new IllegalStateException("Cannot execute RPC, you need to " + |
| 853 | + "establish a connection first."); |
| 854 | + } |
| 855 | + return this.netconfSession.getRunningConfigAndState(xpathFilter); |
| 856 | + } |
| 857 | + |
| 858 | + |
| 859 | + /** |
| 860 | + * Run the <get-data> call to netconf server and retrieve data as an XML. |
| 861 | + * |
| 862 | + * @param xpathFilter example <code><filter xmlns:model='urn:path:for:my:model' select='/model:*'></filter></code> |
| 863 | + * @param datastore running, startup, candidate, or operational |
| 864 | + * @return configuration data as XML object. |
| 865 | + * @throws java.io.IOException If there are errors communicating with the netconf server. |
| 866 | + * @throws org.xml.sax.SAXException If there are errors parsing the XML reply. |
| 867 | + */ |
| 868 | + public XML getData(String xpathFilter, String datastore) throws IOException, SAXException { |
842 | 869 | if (netconfSession == null) {
|
843 | 870 | throw new IllegalStateException("Cannot execute RPC, you need to " +
|
844 | 871 | "establish a connection first.");
|
845 | 872 | }
|
846 |
| - return this.netconfSession.getRunningConfigAndState(filter); |
| 873 | + if (datastore != null) switch (datastore.trim().toLowerCase(Locale.US)) { |
| 874 | + case "running": |
| 875 | + case "startup": |
| 876 | + case "candidate": |
| 877 | + case "operational": |
| 878 | + return this.netconfSession.getData(xpathFilter, datastore.trim().toLowerCase(Locale.US)); |
| 879 | + } |
| 880 | + throw new IllegalStateException("Unable to process datastore: " + datastore); |
847 | 881 | }
|
848 | 882 |
|
| 883 | + |
849 | 884 | /**
|
850 | 885 | * Retrieve the whole candidate configuration.
|
851 | 886 | *
|
|
0 commit comments