Minor change to set ONUs to unreachable state when their parent OLT is being rebooted

Change-Id: I8518016f803bf47e222407331fcb00f7695fa73c
diff --git a/voltha/adapters/ponsim_olt/ponsim_olt.py b/voltha/adapters/ponsim_olt/ponsim_olt.py
index 3d60633..3405038 100644
--- a/voltha/adapters/ponsim_olt/ponsim_olt.py
+++ b/voltha/adapters/ponsim_olt/ponsim_olt.py
@@ -476,6 +476,10 @@
         device.connect_status = ConnectStatus.UNREACHABLE
         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,
+                                    connect_status=ConnectStatus.UNREACHABLE)
+
         # Sleep 10 secs, simulating a reboot
         # TODO: send alert and clear alert after the reboot
         yield asleep(10)
@@ -488,6 +492,11 @@
         device.oper_status = previous_oper_status
         device.connect_status = previous_conn_status
         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,
+                                    connect_status=ConnectStatus.REACHABLE)
+
         self.log.info('rebooted', device_id=self.device_id)
 
     def disable(self):
diff --git a/voltha/core/adapter_agent.py b/voltha/core/adapter_agent.py
index c822c42..dbd6031 100644
--- a/voltha/core/adapter_agent.py
+++ b/voltha/core/adapter_agent.py
@@ -37,7 +37,7 @@
 from voltha.protos.device_pb2 import Device, Port, PmConfigs
 from voltha.protos.events_pb2 import KpiEvent
 from voltha.protos.voltha_pb2 import DeviceGroup, LogicalDevice, \
-    LogicalPort, AdminState, OperStatus
+    LogicalPort, AdminState, OperStatus, ConnectStatus
 from voltha.registry import registry
 from voltha.core.flow_decomposer import OUTPUT
 import sys
@@ -479,6 +479,25 @@
             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
+            self._make_up_to_date(
+                '/devices', device.id, device)
+
     def _gen_rx_proxy_address_topic(self, proxy_address):
         """Generate unique topic name specific to this proxy address for rx"""
         topic = 'rx:' + MessageToJson(proxy_address)