[SEBA-723] Removing ONOS parameters from vOLT Service

Change-Id: I18a44dace5aa7b7c26f06d0b320631cc23114b71
diff --git a/xos/synchronizer/helpers.py b/xos/synchronizer/helpers.py
index cb310af..ade07e0 100644
--- a/xos/synchronizer/helpers.py
+++ b/xos/synchronizer/helpers.py
@@ -31,11 +31,20 @@
 
     @staticmethod
     def get_onos_voltha_info(olt_service):
+
+        # get the onos_fabric service
+        onos = [s.leaf_model for s in olt_service.provider_services if "onos" in s.name.lower()]
+
+        if len(onos) == 0:
+            raise Exception('Cannot find ONOS service in provider_services of vOLTService')
+
+        onos = onos[0]
+
         return {
-            'url': Helpers.format_url(olt_service.onos_voltha_url),
-            'port': olt_service.onos_voltha_port,
-            'user': olt_service.onos_voltha_user,
-            'pass': olt_service.onos_voltha_pass
+            'url': Helpers.format_url(onos.rest_hostname),
+            'port': onos.rest_port,
+            'user': onos.rest_username,
+            'pass': onos.rest_password
         }
 
     @staticmethod
diff --git a/xos/synchronizer/migrations/0009_auto_20190610_1723.py b/xos/synchronizer/migrations/0009_auto_20190610_1723.py
new file mode 100644
index 0000000..588317c
--- /dev/null
+++ b/xos/synchronizer/migrations/0009_auto_20190610_1723.py
@@ -0,0 +1,45 @@
+# 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.
+
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.21 on 2019-06-10 21:23
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('volt', '0008_auto_20190520_1814'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='voltservice_decl',
+            name='onos_voltha_pass',
+        ),
+        migrations.RemoveField(
+            model_name='voltservice_decl',
+            name='onos_voltha_port',
+        ),
+        migrations.RemoveField(
+            model_name='voltservice_decl',
+            name='onos_voltha_url',
+        ),
+        migrations.RemoveField(
+            model_name='voltservice_decl',
+            name='onos_voltha_user',
+        ),
+    ]
diff --git a/xos/synchronizer/models/volt.xproto b/xos/synchronizer/models/volt.xproto
index 9ceb2d2..e7fef4b 100644
--- a/xos/synchronizer/models/volt.xproto
+++ b/xos/synchronizer/models/volt.xproto
@@ -22,21 +22,6 @@
         help_text = "The Voltha password. By default admin",
         default = "admin",
         max_length = 256];
-    required string onos_voltha_url = 5 [
-        help_text = "The ONOS Voltha address. By default onos-voltha-ui.voltha.svc.cluster.local",
-        default = "onos-voltha-ui.voltha.svc.cluster.local",
-        max_length = 256];
-    required int32 onos_voltha_port = 6 [
-        help_text = "The Voltha API port. By default 8181",
-        default = 8181];
-    required string onos_voltha_user = 7 [
-        help_text = "The ONOS Voltha username. By default sdn",
-        max_length = 256,
-        default = "onos"];
-    required string onos_voltha_pass = 8 [
-        help_text = "The ONOS Voltha password. By default rocks",
-        max_length = 256,
-        default = "rocks"];
 }
 
 message OLTDevice (XOSBase){
diff --git a/xos/synchronizer/steps/test_sync_olt_device.py b/xos/synchronizer/steps/test_sync_olt_device.py
index 1ecb04f..307cae1 100644
--- a/xos/synchronizer/steps/test_sync_olt_device.py
+++ b/xos/synchronizer/steps/test_sync_olt_device.py
@@ -56,6 +56,14 @@
         pon_port = Mock()
         pon_port.port_id = "00ff00"
 
+        # create a mock ONOS Service
+        onos = Mock()
+        onos.name = "ONOS"
+        onos.leaf_model.rest_hostname = "onos"
+        onos.leaf_model.rest_port = 4321
+        onos.leaf_model.rest_username = "karaf"
+        onos.leaf_model.rest_password = "karaf"
+
         # Create a mock OLTDevice
         o = Mock()
         o.volt_service.voltha_url = "voltha_url"
@@ -63,10 +71,7 @@
         o.volt_service.voltha_user = "voltha_user"
         o.volt_service.voltha_pass = "voltha_pass"
 
-        o.volt_service.onos_voltha_port = 4321
-        o.volt_service.onos_voltha_url = "onos"
-        o.volt_service.onos_voltha_user = "karaf"
-        o.volt_service.onos_voltha_pass = "karaf"
+        o.volt_service.provider_services = [onos]
 
         o.device_type = "ponsim_olt"
         o.host = "172.17.0.1"
diff --git a/xos/synchronizer/steps/test_sync_volt_service_instance.py b/xos/synchronizer/steps/test_sync_volt_service_instance.py
index 492b4fc..8bbdf6f 100644
--- a/xos/synchronizer/steps/test_sync_volt_service_instance.py
+++ b/xos/synchronizer/steps/test_sync_volt_service_instance.py
@@ -53,11 +53,16 @@
 
         self.sync_step = SyncVOLTServiceInstance
 
+        # create a mock ONOS Service
+        onos = Mock()
+        onos.name = "ONOS"
+        onos.leaf_model.rest_hostname = "onos_voltha_url"
+        onos.leaf_model.rest_port = 4321
+        onos.leaf_model.rest_username = "onos_voltha_user"
+        onos.leaf_model.rest_password = "onos_voltha_pass"
+
         volt_service = Mock()
-        volt_service.onos_voltha_url = "onos_voltha_url"
-        volt_service.onos_voltha_port = 4321
-        volt_service.onos_voltha_user = "onos_voltha_user"
-        volt_service.onos_voltha_pass = "onos_voltha_pass"
+        volt_service.provider_services = [onos]
 
         uni_port = Mock()
         uni_port.port_no = "uni_port_id"
diff --git a/xos/synchronizer/test_helpers.py b/xos/synchronizer/test_helpers.py
index 1ec5df7..a2b392d 100644
--- a/xos/synchronizer/test_helpers.py
+++ b/xos/synchronizer/test_helpers.py
@@ -22,16 +22,23 @@
 class TestHelpers(unittest.TestCase):
 
     def setUp(self):
+
+        # create a mock ONOS Service
+        onos = Mock()
+        onos.name = "ONOS"
+        onos.leaf_model.rest_hostname = "onos_voltha_url"
+        onos.leaf_model.rest_port = 4321
+        onos.leaf_model.rest_username = "onos_voltha_user"
+        onos.leaf_model.rest_password = "onos_voltha_pass"
+
         # Create a mock service instance
         o = Mock()
         o.voltha_url = "voltha_url"
         o.voltha_port = 1234
         o.voltha_user = "voltha_user"
         o.voltha_pass = "voltha_pass"
-        o.onos_voltha_url = "onos_voltha_url"
-        o.onos_voltha_port = 4321
-        o.onos_voltha_user = "onos_voltha_user"
-        o.onos_voltha_pass = "onos_voltha_pass"
+
+        o.provider_services = [onos]
 
         self.o = o