SEBA-206 manage and report switchport state

Change-Id: I9499cb24f66b4c64125cc5c8bfd97afe9104cdb6
diff --git a/xos/synchronizer/event_steps/onos_event.py b/xos/synchronizer/event_steps/onos_event.py
new file mode 100644
index 0000000..8458516
--- /dev/null
+++ b/xos/synchronizer/event_steps/onos_event.py
@@ -0,0 +1,59 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import json
+from xossynchronizer.event_steps.eventstep import EventStep
+from xosconfig import Config
+from multistructlog import create_logger
+
+log = create_logger(Config().get('logging'))
+
+
+class OnosPortEventStep(EventStep):
+    topics = ["onos.events.port"]
+    technology = "kafka"
+
+    def __init__(self, *args, **kwargs):
+        super(OnosPortEventStep, self).__init__(*args, **kwargs)
+
+    def process_event(self, event):
+        value = json.loads(event.value)
+
+        switch = self.model_accessor.Switch.objects.filter(
+            ofId=value["deviceId"]
+        )
+        if not switch:
+            log.info("Event for unknown switch", deviceId=value["deviceId"])
+            return
+
+        switch = switch[0]
+
+        port = self.model_accessor.SwitchPort.objects.filter(
+            switch_id=switch.id,
+            portId=value["portId"]
+        )
+        if not port:
+            log.info("Event for unknown port",
+                     deviceId=value["deviceId"],
+                     portId=value["portId"])
+            return
+
+        port = port[0]
+
+        oper_status = "enabled" if value["enabled"] else "disabled"
+        if oper_status != port.oper_status:
+            port.oper_status = oper_status
+            port.save_changed_fields()