SEBA-360 Pass logger to AttHelper rather than reinitialize

Change-Id: I41c0c1b75ba1c28b69a162b498ced039650db762
diff --git a/Dockerfile.synchronizer b/Dockerfile.synchronizer
index 519f4df..ffcaa88 100644
--- a/Dockerfile.synchronizer
+++ b/Dockerfile.synchronizer
@@ -16,7 +16,7 @@
 
 # xosproject/att-workflow-driver-synchronizer
 
-FROM xosproject/xos-synchronizer-base:2.1.22
+FROM xosproject/xos-synchronizer-base:2.1.24
 
 COPY xos/synchronizer /opt/xos/synchronizers/att-workflow-driver
 COPY VERSION /opt/xos/synchronizers/att-workflow-driver/
diff --git a/VERSION b/VERSION
index b0f3d96..ffcb6c9 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1,2 @@
-1.0.8
+1.0.9
+
diff --git a/xos/synchronizer/event_steps/auth_event.py b/xos/synchronizer/event_steps/auth_event.py
index e534aee..b181121 100644
--- a/xos/synchronizer/event_steps/auth_event.py
+++ b/xos/synchronizer/event_steps/auth_event.py
@@ -31,8 +31,8 @@
     def process_event(self, event):
         value = json.loads(event.value)
 
-        onu_sn = AttHelpers.get_onu_sn(value)
-        si = AttHelpers.get_si_by_sn(onu_sn)
+        onu_sn = AttHelpers.get_onu_sn(self.log, value)
+        si = AttHelpers.get_si_by_sn(self.log, onu_sn)
         if not si:
             self.log.exception("authentication.events: Cannot find att-workflow-driver service instance for this event", kafka_event=value)
             raise Exception("authentication.events: Cannot find att-workflow-driver service instance for this event")
diff --git a/xos/synchronizer/event_steps/dhcp_event.py b/xos/synchronizer/event_steps/dhcp_event.py
index 74a7696..1b3033a 100644
--- a/xos/synchronizer/event_steps/dhcp_event.py
+++ b/xos/synchronizer/event_steps/dhcp_event.py
@@ -31,8 +31,8 @@
     def process_event(self, event):
         value = json.loads(event.value)
 
-        onu_sn = AttHelpers.get_onu_sn(value)
-        si = AttHelpers.get_si_by_sn(onu_sn)
+        onu_sn = AttHelpers.get_onu_sn(self.log, value)
+        si = AttHelpers.get_si_by_sn(self.log, onu_sn)
 
         if not si:
             self.log.exception("dhcp.events: Cannot find att-workflow-driver service instance for this event", kafka_event=value)
@@ -40,8 +40,8 @@
 
         self.log.info("dhcp.events: Got event for subscriber", event_value=value, onu_sn=onu_sn, si=si)
 
-        si.dhcp_state = value["messageType"];
-        si.ip_address = value["ipAddress"];
-        si.mac_address = value["macAddress"];
+        si.dhcp_state = value["messageType"]
+        si.ip_address = value["ipAddress"]
+        si.mac_address = value["macAddress"]
 
         si.save_changed_fields(always_update_timestamp=True)
diff --git a/xos/synchronizer/helpers.py b/xos/synchronizer/helpers.py
index 9fffd7c..6b4b2b5 100644
--- a/xos/synchronizer/helpers.py
+++ b/xos/synchronizer/helpers.py
@@ -15,15 +15,9 @@
 from synchronizers.new_base.syncstep import DeferredException
 from synchronizers.new_base.modelaccessor import AttWorkflowDriverWhiteListEntry, AttWorkflowDriverServiceInstance, ONUDevice, VOLTService, model_accessor
 
-from xosconfig import Config
-from multistructlog import create_logger
-
-log = create_logger(Config().get('logging'))
-
 class AttHelpers():
-
     @staticmethod
-    def validate_onu(att_si):
+    def validate_onu(log, att_si):
         """
         This method validate an ONU against the whitelist and set the appropriate state.
         It's expected that the deferred exception is managed in the caller method,
@@ -65,7 +59,7 @@
         return [True, "ONU has been validated"]
 
     @staticmethod
-    def get_onu_sn(event):
+    def get_onu_sn(log, event):
         olt_service = VOLTService.objects.first()
         onu_sn = olt_service.get_onu_sn_from_openflow(event["deviceId"], event["portNumber"])
         if not onu_sn or onu_sn is None:
@@ -75,7 +69,7 @@
         return onu_sn
 
     @staticmethod
-    def get_si_by_sn(serial_number):
+    def get_si_by_sn(log, serial_number):
         try:
             return AttWorkflowDriverServiceInstance.objects.get(serial_number=serial_number)
         except IndexError:
diff --git a/xos/synchronizer/model_policies/model_policy_att_workflow_driver_serviceinstance.py b/xos/synchronizer/model_policies/model_policy_att_workflow_driver_serviceinstance.py
index 525d6ce..602aded 100644
--- a/xos/synchronizer/model_policies/model_policy_att_workflow_driver_serviceinstance.py
+++ b/xos/synchronizer/model_policies/model_policy_att_workflow_driver_serviceinstance.py
@@ -58,7 +58,7 @@
         si.save_changed_fields()
 
     def validate_onu_state(self, si):
-        [valid, message] = AttHelpers.validate_onu(si)
+        [valid, message] = AttHelpers.validate_onu(self.logger, si)
         si.status_message = message
         if valid:
             si.onu_state = "ENABLED"
diff --git a/xos/synchronizer/model_policies/model_policy_att_workflow_driver_whitelistentry.py b/xos/synchronizer/model_policies/model_policy_att_workflow_driver_whitelistentry.py
index cb1e20d..51f2ba4 100644
--- a/xos/synchronizer/model_policies/model_policy_att_workflow_driver_whitelistentry.py
+++ b/xos/synchronizer/model_policies/model_policy_att_workflow_driver_whitelistentry.py
@@ -31,7 +31,7 @@
         self.handle_update(whitelist)
 
     def validate_onu_state(self, si):
-        [valid, message] = AttHelpers.validate_onu(si)
+        [valid, message] = AttHelpers.validate_onu(self.logger, si)
         si.status_message = message
         if valid:
             si.onu_state = "ENABLED"
diff --git a/xos/synchronizer/test_helpers.py b/xos/synchronizer/test_helpers.py
index 910930b..c30cac3 100644
--- a/xos/synchronizer/test_helpers.py
+++ b/xos/synchronizer/test_helpers.py
@@ -49,6 +49,9 @@
         Config.init(config, "synchronizer-config-schema.yaml")
         # END Setting up the config module
 
+        from multistructlog import create_logger
+        self.log = create_logger(Config().get('logging'))
+
         from synchronizers.new_base.mock_modelaccessor_build import build_mock_modelaccessor
 
         build_mock_modelaccessor(xos_dir, services_dir, [
@@ -104,7 +107,7 @@
         with patch.object(AttWorkflowDriverWhiteListEntry.objects, "get_items") as whitelist_mock:
             whitelist_mock.return_value = []
 
-            [res, message] = self.helpers.validate_onu(self.att_si)
+            [res, message] = self.helpers.validate_onu(self.log, self.att_si)
 
             self.assertFalse(res)
             self.assertEqual(message, "ONU not found in whitelist")
@@ -116,7 +119,7 @@
             whitelist_mock.return_value = [self.whitelist_entry]
             onu_mock.return_value = [self.onu]
 
-            [res, message] = self.helpers.validate_onu(self.att_si)
+            [res, message] = self.helpers.validate_onu(self.log, self.att_si)
 
             self.assertFalse(res)
             self.assertEqual(message, "ONU activated in wrong location")
@@ -128,7 +131,7 @@
             whitelist_mock.return_value = [self.whitelist_entry]
             onu_mock.return_value = [self.onu]
 
-            [res, message] = self.helpers.validate_onu(self.att_si)
+            [res, message] = self.helpers.validate_onu(self.log, self.att_si)
 
             self.assertFalse(res)
             self.assertEqual(message, "ONU activated in wrong location")
@@ -140,7 +143,7 @@
             onu_mock.return_value = []
 
             with self.assertRaises(Exception) as e:
-                self.helpers.validate_onu(self.att_si)
+                self.helpers.validate_onu(self.log, self.att_si)
 
             self.assertEqual(e.exception.message, "ONU device %s is not know to XOS yet" % self.att_si.serial_number)
 
@@ -150,7 +153,7 @@
             whitelist_mock.return_value = [self.whitelist_entry]
             onu_mock.return_value = [self.onu]
 
-            [res, message] = self.helpers.validate_onu(self.att_si)
+            [res, message] = self.helpers.validate_onu(self.log, self.att_si)
 
             self.assertTrue(res)
             self.assertEqual(message, "ONU has been validated")
@@ -162,7 +165,7 @@
             whitelist_mock.return_value = [self.whitelist_entry]
             onu_mock.return_value = [self.onu]
 
-            [res, message] = self.helpers.validate_onu(self.att_si)
+            [res, message] = self.helpers.validate_onu(self.log, self.att_si)
 
             self.assertTrue(res)
             self.assertEqual(message, "ONU has been validated")