1) Handles chuncked xml requests from Netconf client, 2) Handles nested xml parameters from Netconf client, 3) Handles all currently exposed rpcs
Change-Id: Id478f355ab53afc876c4f5fd9ad8f1a048a50748
diff --git a/netconf/nc_rpc/ext/voltha_rpc.py b/netconf/nc_rpc/ext/voltha_rpc.py
index 835f900..9d4bf33 100644
--- a/netconf/nc_rpc/ext/voltha_rpc.py
+++ b/netconf/nc_rpc/ext/voltha_rpc.py
@@ -83,17 +83,29 @@
self.request_xml)
return
+ # Helper function to parse a complex xml into a dict
+ def _parse_params(self, node):
+ params = {}
+ if node is not None:
+ for r in node:
+ children = r.getchildren()
+ if children:
+ params[ r.tag.replace(qmap(C.VOLTHA), "")] = \
+ self._parse_params(children)
+ else:
+ params[
+ r.tag.replace(qmap(C.VOLTHA), "")] = r.text
+ return params
+
def _extract_parameters(self):
try:
rpc_node = self.request_xml.find(''.join(
[qmap(C.VOLTHA),
self.request['command']])
)
- self.request['params'] = {}
- if rpc_node is not None:
- for r in rpc_node:
- self.request['params'][
- r.tag.replace(qmap(C.VOLTHA), "")] = r.text
+
+ # Parse rpc the parameters
+ self.request['params'] = self._parse_params(rpc_node)
# Remove the subclass element in the request if it is present as
# it is not required for rpc calls