- Fixes an issue in parsing complex xml params in request
- Consolidate 3 methods of state change into one

Change-Id: I2214e926a56488064925f6d8edd22cc1fc869cff
diff --git a/netconf/nc_rpc/ext/voltha_rpc.py b/netconf/nc_rpc/ext/voltha_rpc.py
index 9d4bf33..d4707dd 100644
--- a/netconf/nc_rpc/ext/voltha_rpc.py
+++ b/netconf/nc_rpc/ext/voltha_rpc.py
@@ -83,18 +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()
+                tag = r.tag.replace(qmap(C.VOLTHA), "")
                 if children:
-                    params[ r.tag.replace(qmap(C.VOLTHA), "")] = \
-                        self._parse_params(children)
+                    if tag in params:
+                        if not isinstance(params[tag], list):
+                            temp = []
+                            temp.append(params[tag])
+                            params[tag] = temp
+                        params[tag].append(self._parse_params(children))
+                    else:
+                        params[tag] = self._parse_params(children)
                 else:
-                    params[
-                        r.tag.replace(qmap(C.VOLTHA), "")] = r.text
+                    # Convert string boolean to boolean
+                    if r.text == 'true':
+                        params[tag] = True
+                    elif r.text == 'false':
+                        params[tag] = False
+                    else:
+                        params[tag] = r.text
         return params
 
     def _extract_parameters(self):
diff --git a/voltha/adapters/ponsim_olt/ponsim_olt.py b/voltha/adapters/ponsim_olt/ponsim_olt.py
index 3405038..3213a29 100644
--- a/voltha/adapters/ponsim_olt/ponsim_olt.py
+++ b/voltha/adapters/ponsim_olt/ponsim_olt.py
@@ -477,7 +477,7 @@
         self.adapter_agent.update_device(device)
 
         # Update the child devices connect state to UNREACHABLE
-        self.adapter_agent.change_status_of_all_child_devices(self.device_id,
+        self.adapter_agent.update_child_devices_state(self.device_id,
                                     connect_status=ConnectStatus.UNREACHABLE)
 
         # Sleep 10 secs, simulating a reboot
@@ -494,7 +494,7 @@
         self.adapter_agent.update_device(device)
 
         # Update the child devices connect state to REACHABLE
-        self.adapter_agent.change_status_of_all_child_devices(self.device_id,
+        self.adapter_agent.update_child_devices_state(self.device_id,
                                     connect_status=ConnectStatus.REACHABLE)
 
         self.log.info('rebooted', device_id=self.device_id)
@@ -516,7 +516,8 @@
         self.adapter_agent.delete_logical_device(logical_device)
 
         # Disable all child devices first
-        self.adapter_agent.disable_all_child_devices(self.device_id)
+        self.adapter_agent.update_child_devices_state(self.device_id,
+                                            admin_state=AdminState.DISABLED)
 
         # Remove the peer references from this device
         self.adapter_agent.delete_all_peer_references(self.device_id)
@@ -599,7 +600,8 @@
         self.logical_device_id = ld_initialized.id
 
         # Reenable all child devices
-        self.adapter_agent.reenable_all_child_devices(device.id)
+        self.adapter_agent.update_child_devices_state(device.id,
+                                            admin_state=AdminState.ENABLED)
 
         # finally, open the frameio port to receive in-band packet_in messages
         self.log.info('registering-frameio')
diff --git a/voltha/core/adapter_agent.py b/voltha/core/adapter_agent.py
index dbd6031..06688ed 100644
--- a/voltha/core/adapter_agent.py
+++ b/voltha/core/adapter_agent.py
@@ -452,49 +452,29 @@
         for child_id in children_ids:
             self._remove_node('/devices', child_id)
 
-    def reenable_all_child_devices(self, parent_device_id):
-        """ Re-enable all ONUs from a given OLT """
+    def update_child_devices_state(self,
+                                   parent_device_id,
+                                   oper_status=None,
+                                   connect_status=None,
+                                   admin_state=None):
+        """ Update status of all child devices """
         devices = self.root_proxy.get('/devices')
         children_ids = set(d.id for d in devices if d.parent_id == parent_device_id)
-        self.log.debug('devices-to-reenable',
+        self.log.debug('update-devices',
                        parent_id=parent_device_id,
-                       children_ids=children_ids)
-        for child_id in children_ids:
-            device = self.get_device(child_id)
-            device.admin_state = AdminState.ENABLED
-            self._make_up_to_date(
-                '/devices', device.id, device)
+                       children_ids=children_ids,
+                       oper_status=oper_status,
+                       connect_status=connect_status,
+                       admin_state=admin_state)
 
-    def disable_all_child_devices(self, parent_device_id):
-        """ Disable all ONUs from a given OLT """
-        devices = self.root_proxy.get('/devices')
-        children_ids = set(d.id for d in devices if d.parent_id == parent_device_id)
-        self.log.debug('devices-to-disable',
-                       parent_id=parent_device_id,
-                       children_ids=children_ids)
-        for child_id in children_ids:
-            # Change the admin state pf the device to DISABLE
-            device = self.get_device(child_id)
-            device.admin_state = AdminState.DISABLED
-            self._make_up_to_date(
-                '/devices', device.id, device)
-
-    def change_status_of_all_child_devices(self, parent_device_id, **kw):
-        """ Change status of all child devices """
-        devices = self.root_proxy.get('/devices')
-        children_ids = set(d.id for d in devices if d.parent_id == parent_device_id)
-        self.log.debug('devices-to-change-status',
-                       parent_id=parent_device_id,
-                       children_ids=children_ids)
         for child_id in children_ids:
             device = self.get_device(child_id)
-            for k, v in kw.items():
-                if k == 'oper_status':
-                    device.oper_status = v
-                if k == 'connect_status':
-                    device.connect_status = v
-                if k == 'admin_status':
-                    device.admin_state = v
+            if oper_status:
+                device.oper_status = oper_status
+            if connect_status:
+                device.connect_status = connect_status
+            if admin_state:
+                device.admin_state = admin_state
             self._make_up_to_date(
                 '/devices', device.id, device)