[SEBA-297] Standardized onu.events format
Change-Id: Ie34462c13a5733c871652af0678f538119c187bc
diff --git a/docs/README.md b/docs/README.md
index fcd2d98..569e90b 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -96,9 +96,9 @@
{
"timestamp": "2018-09-11T01:00:49.506Z",
"status": "activated", // or disabled
- "serial_number": "ALPHe3d1cfde", // ONU serial number
- "uni_port_id": 16, // uni port
- "of_dpid": "of:000000000a5a0072" // OLT OpenFlow Id
+ "serialNumber": "ALPHe3d1cfde", // ONU serial number
+ "portNumber": "16", // uni port
+ "deviceId": "of:000000000a5a0072" // OLT OpenFlow Id
}
```
diff --git a/xos/synchronizer/event_steps/onu_event.py b/xos/synchronizer/event_steps/onu_event.py
index 386942f..3a18c26 100644
--- a/xos/synchronizer/event_steps/onu_event.py
+++ b/xos/synchronizer/event_steps/onu_event.py
@@ -28,17 +28,17 @@
def get_tt_si(self, event):
try:
- tt_si = self.model_accessor.TtWorkflowDriverServiceInstance.objects.get(serial_number=event["serial_number"])
+ tt_si = self.model_accessor.TtWorkflowDriverServiceInstance.objects.get(serial_number=event["serialNumber"])
tt_si.no_sync = False;
- tt_si.uni_port_id = event["uni_port_id"]
- tt_si.of_dpid = event["of_dpid"]
+ tt_si.uni_port_id = long(event["portNumber"])
+ tt_si.of_dpid = event["deviceId"]
self.log.debug("onu.events: Found existing TtWorkflowDriverServiceInstance", si=tt_si)
except IndexError:
# create an TtWorkflowDriverServiceInstance, the validation will be triggered in the corresponding sync step
tt_si = self.model_accessor.TtWorkflowDriverServiceInstance(
- serial_number=event["serial_number"],
- of_dpid=event["of_dpid"],
- uni_port_id=event["uni_port_id"],
+ serial_number=event["serialNumber"],
+ of_dpid=event["deviceId"],
+ uni_port_id=long(event["portNumber"]),
owner=self.model_accessor.TtWorkflowDriverService.objects.first() # we assume there is only one TtWorkflowDriverService
)
self.log.debug("onu.events: Created new TtWorkflowDriverServiceInstance", si=tt_si)
diff --git a/xos/synchronizer/event_steps/test_onu_events.py b/xos/synchronizer/event_steps/test_onu_events.py
index ea368d5..0bd1c31 100644
--- a/xos/synchronizer/event_steps/test_onu_events.py
+++ b/xos/synchronizer/event_steps/test_onu_events.py
@@ -58,9 +58,9 @@
self.event = Mock()
self.event_dict = {
'status': 'activated',
- 'serial_number': 'BRCM1234',
- 'of_dpid': 'of:109299321',
- 'uni_port_id': 16
+ 'serialNumber': 'BRCM1234',
+ 'deviceId': 'of:109299321',
+ 'portNumber': '16'
}
self.event.value = json.dumps(self.event_dict)
@@ -85,15 +85,15 @@
self.assertEqual(mock_save.call_count, 1)
- self.assertEqual(tt_si.serial_number, self.event_dict['serial_number'])
- self.assertEqual(tt_si.of_dpid, self.event_dict['of_dpid'])
- self.assertEqual(tt_si.uni_port_id, self.event_dict['uni_port_id'])
+ self.assertEqual(tt_si.serial_number, self.event_dict['serialNumber'])
+ self.assertEqual(tt_si.of_dpid, self.event_dict['deviceId'])
+ self.assertEqual(tt_si.uni_port_id, long(self.event_dict['portNumber']))
self.assertEqual(tt_si.onu_state, "ENABLED")
def test_reuse_instance(self):
si = TtWorkflowDriverServiceInstance(
- serial_number=self.event_dict["serial_number"],
+ serial_number=self.event_dict["serialNumber"],
of_dpid="foo",
uni_port_id="foo"
)
@@ -109,17 +109,17 @@
self.assertEqual(mock_save.call_count, 1)
- self.assertEqual(tt_si.serial_number, self.event_dict['serial_number'])
- self.assertEqual(tt_si.of_dpid, self.event_dict['of_dpid'])
- self.assertEqual(tt_si.uni_port_id, self.event_dict['uni_port_id'])
+ self.assertEqual(tt_si.serial_number, self.event_dict['serialNumber'])
+ self.assertEqual(tt_si.of_dpid, self.event_dict['deviceId'])
+ self.assertEqual(tt_si.uni_port_id, long(self.event_dict['portNumber']))
self.assertEqual(tt_si.onu_state, "ENABLED")
def test_disable_onu(self):
self.event_dict = {
'status': 'disabled',
- 'serial_number': 'BRCM1234',
- 'of_dpid': 'of:109299321',
- 'uni_port_id': 16
+ 'serialNumber': 'BRCM1234',
+ 'deviceId': 'of:109299321',
+ 'portNumber': '16'
}
self.event.value = json.dumps(self.event_dict)
@@ -132,4 +132,4 @@
if __name__ == '__main__':
sys.path.append("..") # for import of helpers.py
- unittest.main()
\ No newline at end of file
+ unittest.main()