Microsemi OLT now activates through voltha.

The Microsemi OLT can now be activated from VOLTHA.
This adaptor still lacks ability to register
ONUs and there is still not functional.

Change-Id: Ia0b66332ea4cb9ea5252db0500e64cbd61588f02
diff --git a/voltha/adapters/microsemi/ActivationWatcher.py b/voltha/adapters/microsemi/ActivationWatcher.py
index c15d076..8036b1d 100644
--- a/voltha/adapters/microsemi/ActivationWatcher.py
+++ b/voltha/adapters/microsemi/ActivationWatcher.py
@@ -14,7 +14,6 @@
 # limitations under the License.
 #
 from scapy.automaton import ATMT
-from twisted.internet import reactor
 import structlog
 from voltha.adapters.microsemi.BaseOltAutomaton import BaseOltAutomaton
 from voltha.adapters.microsemi.PAS5211 import PAS5211EventOnuActivation, PAS5211MsgGetActivationAuthMode, \
diff --git a/voltha/adapters/microsemi/DeviceManager.py b/voltha/adapters/microsemi/DeviceManager.py
index 1bfa83c..c785c58 100644
--- a/voltha/adapters/microsemi/DeviceManager.py
+++ b/voltha/adapters/microsemi/DeviceManager.py
@@ -36,7 +36,7 @@
         self.adapter_agent = adapter_agent
         self.logical_device = None
 
-    def update_device(self, pkt):
+    def update_device_info_from_pkt(self, pkt):
 
         self.device.root = True
         self.device.vendor = 'Celestica Inc.'
@@ -49,7 +49,7 @@
                                                          pkt.build_firmware_version)
         self.device.software_version = '0.0.1'
         self.device.serial_number = self.device.mac_address
-        self.device.connect_status = ConnectStatus.REACHABLE
+        self.device.oper_status = ConnectStatus.REACHABLE
         self.adapter_agent.update_device(self.device)
 
     def create_logical_device(self):
@@ -102,6 +102,7 @@
                                             logical_port)
 
     def activate(self):
+        self.device = self.adapter_agent.get_device(self.device.id)
         self.device.parent_id = self.logical_device.id
         self.device.oper_status = OperStatus.ACTIVE
         self.adapter_agent.update_device(self.device)
diff --git a/voltha/adapters/microsemi/OltStateMachine.py b/voltha/adapters/microsemi/OltStateMachine.py
index b343e7e..0913247 100644
--- a/voltha/adapters/microsemi/OltStateMachine.py
+++ b/voltha/adapters/microsemi/OltStateMachine.py
@@ -31,6 +31,8 @@
 
 import structlog
 
+from voltha.protos.common_pb2 import ConnectStatus
+
 log = structlog.get_logger()
 
 
@@ -192,7 +194,7 @@
         log.debug("Received proto version {}".format(pkt))
         if PAS5211MsgGetOltVersionResponse in pkt:
             log.info("updating device")
-            self.device.update_device(pkt)
+            self.device.update_device_info_from_pkt(pkt)
             raise self.got_olt_version()
         else:
             log.error("Got garbage packet {}".format(pkt))
@@ -262,7 +264,8 @@
 
     @ATMT.receive_condition(wait_olt_optics)
     def receive_set_optics_response(self, pkt):
-        if pkt.opcode == PAS5211MsgSetOltOpticsResponse.opcode:
+        if PAS5211MsgSetOltOpticsResponse in pkt:
+            print "GOT OPTICS RESP"
             self.send_state[pkt.channel_id] = True
             if self.check_channel_state():
                 raise self.got_olt_optics()
@@ -298,7 +301,7 @@
 
     @ATMT.receive_condition(wait_olt_io_optics)
     def receive_io_optics_response(self, pkt):
-        if pkt.opcode == PAS5211MsgSetOpticsIoControlResponse.opcode:
+        if PAS5211MsgSetOpticsIoControlResponse in pkt:
             self.send_state[pkt.channel_id] = True
             if self.check_channel_state():
                 raise self.got_olt_io_optics()
@@ -351,7 +354,7 @@
 
     @ATMT.receive_condition(wait_olt_add)
     def wait_for_olt_add(self, pkt):
-        if pkt.opcode == PAS5211MsgAddOltChannelResponse.opcode:
+        if PAS5211MsgAddOltChannelResponse in pkt:
             self.send_state[pkt.channel_id] = True
             if self.check_channel_state():
                 raise self.got_olt_add()
@@ -374,7 +377,7 @@
 
     @ATMT.receive_condition(wait_alarm_set)
     def wait_for_alarm_set(self, pkt):
-        if pkt.opcode == PAS5211MsgSetAlarmConfigResponse.opcode:
+        if PAS5211MsgSetAlarmConfigResponse in pkt:
             self.send_state[pkt.channel_id] = True
             if self.check_channel_state():
                 raise self.got_alarm_set()
@@ -430,7 +433,7 @@
 
     @ATMT.receive_condition(wait_dba_start)
     def wait_for_dba_start(self, pkt):
-        if pkt.opcode == PAS5211MsgStartDbaAlgorithmResponse.opcode:
+        if PAS5211MsgStartDbaAlgorithmResponse in pkt:
             self.send_state[pkt.channel_id] = True
             if self.check_channel_state():
                 raise self.got_dba_start()
@@ -453,11 +456,12 @@
 
     @ATMT.receive_condition(wait_activation)
     def wait_for_activation(self, pkt):
-        if pkt.opcode == PAS5211MsgSetOltChannelActivationPeriodResponse.opcode:
+        if PAS5211MsgSetOltChannelActivationPeriodResponse in pkt:
             self.send_state[pkt.channel_id] = True
             if self.check_channel_state():
                 log.info("Ruby OLT at {} initialised".format(self.target))
                 self.device.create_logical_device()
+                self.device.activate()
                 raise self.initialized()
         raise self.wait_activation()
 
diff --git a/voltha/adapters/microsemi/PAS5211.py b/voltha/adapters/microsemi/PAS5211.py
index d0acc70..7939e91 100644
--- a/voltha/adapters/microsemi/PAS5211.py
+++ b/voltha/adapters/microsemi/PAS5211.py
@@ -198,6 +198,13 @@
 PON_OLT_HW_CLASSIFICATION_LAST_RULE                = 108
 
 
+PON_ACTIVATION_AUTH_AUTO 			  				= 0
+PON_ACTIVATION_AUTH_HOST_CONTROLLED_SEPARATE_EVENTS = 1 # Host controlled: Separate events
+PON_ACTIVATION_AUTH_HOST_CONTROLLED_LUMPED_SN   	= 2 # Host controlled: Lumped-SN-Response
+PON_ACTIVATION_AUTH_REGISTRATION_ID_RAW   			= 3 # Registration-ID Raw
+PON_ACTIVATION_AUTH_REGISTRATION_ID_LEARN   		= 4  # Registration-ID Learn
+
+
 class XLESignedIntField(Field):
     def __init__(self, name, default):
         Field.__init__(self, name, default, "<i")