Storing backend handle to delete object
Change-Id: I0781e20796836e347514a0623f6315c42b378854
diff --git a/xos/synchronizer/steps/sync_volt_service_instance.py b/xos/synchronizer/steps/sync_volt_service_instance.py
index 11675a4..5ec0328 100644
--- a/xos/synchronizer/steps/sync_volt_service_instance.py
+++ b/xos/synchronizer/steps/sync_volt_service_instance.py
@@ -61,7 +61,9 @@
onos_voltha = Helpers.get_onos_voltha_info(volt_service)
onos_voltha_basic_auth = HTTPBasicAuth(onos_voltha['user'], onos_voltha['pass'])
- full_url = "%s:%d/onos/olt/oltapp/%s/%s" % (onos_voltha['url'], onos_voltha['port'], olt_device.dp_id, uni_port_id)
+ handle = "%s/%s" % (olt_device.dp_id, uni_port_id)
+
+ full_url = "%s:%d/onos/olt/oltapp/%s" % (onos_voltha['url'], onos_voltha['port'], handle)
log.info("Sending request to onos-voltha", url=full_url)
@@ -70,6 +72,9 @@
if request.status_code != 200:
raise Exception("Failed to add subscriber in onos-voltha: %s" % request.text)
+ o.backend_handle = handle
+ o.save(update_fields=["backend_handle"])
+
log.info("Added Subscriber in onos voltha", response=request.text)
def delete_record(self, o):
@@ -80,11 +85,7 @@
onos_voltha = Helpers.get_onos_voltha_info(volt_service)
onos_voltha_basic_auth = HTTPBasicAuth(onos_voltha['user'], onos_voltha['pass'])
- olt_device = o.onu_device.pon_port.olt_device
- # NOTE each ONU has only one UNI port!
- uni_port_id = o.onu_device.uni_ports.first().port_no
-
- full_url = "%s:%d/onos/olt/oltapp/%s/%s" % (onos_voltha['url'], onos_voltha['port'], olt_device.dp_id, uni_port_id)
+ full_url = "%s:%d/onos/olt/oltapp/%s" % (onos_voltha['url'], onos_voltha['port'], o.backend_handle)
request = requests.delete(full_url, auth=onos_voltha_basic_auth)
diff --git a/xos/synchronizer/steps/test_sync_volt_service_instance.py b/xos/synchronizer/steps/test_sync_volt_service_instance.py
index 1f9505d..efc946d 100644
--- a/xos/synchronizer/steps/test_sync_volt_service_instance.py
+++ b/xos/synchronizer/steps/test_sync_volt_service_instance.py
@@ -130,6 +130,7 @@
self.sync_step().sync_record(self.o)
self.assertTrue(m.called)
+ self.assertEqual(self.o.backend_handle, "of:dp_id/uni_port_id")
@requests_mock.Mocker()
def test_do_sync_fail(self, m):
@@ -151,6 +152,7 @@
m.delete("http://onos_voltha_url:4321/onos/olt/oltapp/of:dp_id/uni_port_id", status_code=204)
self.onu_device.pon_port.olt_device.dp_id = "of:dp_id"
+ self.o.backend_handle = "of:dp_id/uni_port_id"
with patch.object(VOLTService.objects, "get") as olt_service_mock:
olt_service_mock.return_value = self.volt_service