aboutsummaryrefslogtreecommitdiffstats
path: root/src/python/netconf_server
diff options
context:
space:
mode:
authorTomasz Pietruszkiewicz <tomasz.pietruszkiewicz@nokia.com>2021-03-31 12:23:33 +0200
committerTomasz Pietruszkiewicz <tomasz.pietruszkiewicz@nokia.com>2021-03-31 12:23:33 +0200
commit06daadc4403397935c647dca2bbb92459864d12a (patch)
treefb90e8d96781479875be1371e806ab4836ed3044 /src/python/netconf_server
parent172e5045cead09db8af3715b62b5b87c919f7f8d (diff)
Add endpoint for config gethonolulu
Change-Id: I3e58a2e0e60a71920460908ef20b322ff328154a Issue-ID: INT-1869 Signed-off-by: Tomasz Pietruszkiewicz <tomasz.pietruszkiewicz@nokia.com>
Diffstat (limited to 'src/python/netconf_server')
-rw-r--r--src/python/netconf_server/netconf_rest_server.py7
-rw-r--r--src/python/netconf_server/sysrepo_configuration/sysrepo_configuration_manager.py6
2 files changed, 12 insertions, 1 deletions
diff --git a/src/python/netconf_server/netconf_rest_server.py b/src/python/netconf_server/netconf_rest_server.py
index e90c104..8568454 100644
--- a/src/python/netconf_server/netconf_rest_server.py
+++ b/src/python/netconf_server/netconf_rest_server.py
@@ -78,6 +78,13 @@ class NetconfRestServer:
return NetconfRestServer.__create_http_response(202, "Accepted")
@staticmethod
+ @_rest_server.route("/get_config/<path:module_name>", methods=['GET'])
+ def _get_config(module_name):
+ data = NetconfRestServer._configuration_manager.get_configuration(module_name)
+ return NetconfRestServer.__create_http_response(200, data)
+
+
+ @staticmethod
def __create_http_response(code, message):
return make_response(
Response(message, headers={'Content-Type': 'application/json'}),
diff --git a/src/python/netconf_server/sysrepo_configuration/sysrepo_configuration_manager.py b/src/python/netconf_server/sysrepo_configuration/sysrepo_configuration_manager.py
index 0e8ad94..7e209e6 100644
--- a/src/python/netconf_server/sysrepo_configuration/sysrepo_configuration_manager.py
+++ b/src/python/netconf_server/sysrepo_configuration/sysrepo_configuration_manager.py
@@ -14,7 +14,7 @@
# limitations under the License.
# ============LICENSE_END=========================================================
###
-
+import json
import logging
@@ -39,3 +39,7 @@ class SysrepoConfigurationManager(object):
def change_configuration(self, config_data: str, module_name: str):
data = self.__parse_config_data(config_data)
self._session.replace_config_ly(data, module_name)
+
+ def get_configuration(self, module_name: str):
+ data = self._session.get_data("/" + module_name + ":*")
+ return json.dumps(data, indent=4)