[CORD-3120] Adding remove subscriber call in ONOS-VOLTHA

Change-Id: Ife1561f71f59e73b7659db236af95f9c70f109d1
diff --git a/samples/pon_port.yaml b/samples/pon_port.yaml
index a97d315..28218e2 100644
--- a/samples/pon_port.yaml
+++ b/samples/pon_port.yaml
@@ -27,9 +27,7 @@
     device#olt:
       type: tosca.nodes.OLTDevice
       properties:
-        device_type: simulated_olt
-        host: 172.17.0.1
-        port: 50060
+        name: test_olt
         must-exist: true
 
     pon_port:
diff --git a/xos/synchronizer/steps/sync_volt_service_instance.py b/xos/synchronizer/steps/sync_volt_service_instance.py
index 2598f60..9f005bd 100644
--- a/xos/synchronizer/steps/sync_volt_service_instance.py
+++ b/xos/synchronizer/steps/sync_volt_service_instance.py
@@ -67,4 +67,25 @@
         if request.status_code != 200:
             raise Exception("Failed to add subscriber in onos-voltha: %s" % request.text)
 
-        log.info("onos voltha response", response=request.text)
\ No newline at end of file
+        log.info("Added Subscriber in onos voltha", response=request.text)
+    
+    def delete_record(self, o):
+
+        log.info("Removing OLTServiceInstance", object=str(o), **o.tologdict())
+
+        volt_service = VOLTService.objects.get(id=o.owner_id)
+        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)
+
+        request = requests.delete(full_url, auth=onos_voltha_basic_auth)
+
+        if request.status_code != 204:
+            raise Exception("Failed to remove subscriber from onos-voltha: %s" % request.text)
+
+        log.info("Removed Subscriber from onos voltha", response=request.text)
\ No newline at end of file
diff --git a/xos/synchronizer/steps/test_sync_volt_service_instance.py b/xos/synchronizer/steps/test_sync_volt_service_instance.py
index 6fc377a..bf994d3 100644
--- a/xos/synchronizer/steps/test_sync_volt_service_instance.py
+++ b/xos/synchronizer/steps/test_sync_volt_service_instance.py
@@ -155,5 +155,18 @@
                 self.assertTrue(m.called)
                 self.assertEqual(e.exception.message, "Failed to add subscriber in onos voltha: Mock Error")
 
+    @requests_mock.Mocker()
+    def test_delete(self, m):
+        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"
+
+        with patch.object(VOLTService.objects, "get") as olt_service_mock:
+            olt_service_mock.return_value = self.volt_service
+
+            self.sync_step().delete_record(self.o)
+            self.assertTrue(m.called)
+            self.assertEqual(m.call_count, 1)
+
 if __name__ == "__main__":
     unittest.main()