VOL-1208 Openolt state machine ordering fix

start indications thread post transition to init state instead of while transiting to init state. Otherwise the indication thread was trying to go to connected state before the state machine reached init state

Change-Id: I63e866116868869efc3fa8c48032c3e03d0a3bfc
diff --git a/voltha/adapters/openolt/openolt_device.py b/voltha/adapters/openolt/openolt_device.py
index 087179c..2bf6047 100644
--- a/voltha/adapters/openolt/openolt_device.py
+++ b/voltha/adapters/openolt/openolt_device.py
@@ -71,7 +71,8 @@
          {'trigger': 'go_state_init',
           'source': ['state_null', 'state_connected', 'state_down'],
           'dest': 'state_init',
-          'before': 'do_state_init'},
+          'before': 'do_state_init',
+          'after': 'post_init'},
          {'trigger': 'go_state_connected',
           'source': 'state_init',
           'dest': 'state_connected',
@@ -152,6 +153,19 @@
         self.channel = grpc.insecure_channel(self.host_and_port)
         self.channel_ready_future = grpc.channel_ready_future(self.channel)
 
+        self.alarm_mgr = OpenOltAlarmMgr(self.log, self.adapter_agent,
+                                         self.device_id,
+                                         self.logical_device_id)
+        self.stats_mgr = OpenOltStatisticsMgr(self, self.log)
+        self.bw_mgr = OpenOltBW(self.log, self.proxy)
+
+        self.log.info('openolt-device-created', device_id=self.device_id)
+
+    def post_init(self, event):
+        self.log.debug('post_init')
+
+        # We have reached init state, starting the indications thread
+
         # Catch RuntimeError exception
         try:
             # Start indications thread
@@ -164,15 +178,7 @@
             self.indications_thread_handle.setDaemon(True)
             self.indications_thread_handle.start()
         except Exception as e:
-            self.log.exception('do_state_init failed', e=e)
-
-        self.alarm_mgr = OpenOltAlarmMgr(self.log, self.adapter_agent,
-                                         self.device_id,
-                                         self.logical_device_id)
-        self.stats_mgr = OpenOltStatisticsMgr(self, self.log)
-        self.bw_mgr = OpenOltBW(self.log, self.proxy)
-
-        self.log.info('openolt-device-created', device_id=self.device_id)
+            self.log.exception('post_init failed', e=e)
 
     def do_state_connected(self, event):
         self.log.debug("do_state_connected")