[CORD-3078] Pulling ONUs
Change-Id: I211f3669bc59ee217d5c084a69383be535a9c4c6
diff --git a/xos/synchronizer/steps/helpers.py b/xos/synchronizer/steps/helpers.py
deleted file mode 100644
index cb310af..0000000
--- a/xos/synchronizer/steps/helpers.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# 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.
-
-class Helpers():
- @staticmethod
- def format_url(url):
- if 'http' in url:
- return url
- else:
- return 'http://%s' % url
-
- @staticmethod
- def get_voltha_info(olt_service):
- return {
- 'url': Helpers.format_url(olt_service.voltha_url),
- 'port': olt_service.voltha_port,
- 'user': olt_service.voltha_user,
- 'pass': olt_service.voltha_pass
- }
-
- @staticmethod
- def get_onos_voltha_info(olt_service):
- 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
- }
-
- @staticmethod
- def datapath_id_to_hex(id):
- if isinstance(id, basestring):
- id = int(id)
- return "{0:0{1}x}".format(id, 16)
\ No newline at end of file
diff --git a/xos/synchronizer/steps/sync_olt_device.py b/xos/synchronizer/steps/sync_olt_device.py
index 4aaebdf..5997de5 100644
--- a/xos/synchronizer/steps/sync_olt_device.py
+++ b/xos/synchronizer/steps/sync_olt_device.py
@@ -12,15 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import json
-from synchronizers.new_base.SyncInstanceUsingAnsible import SyncStep
-from synchronizers.new_base.modelaccessor import OLTDevice
-
-from xosconfig import Config
-from multistructlog import create_logger
from time import sleep
+
import requests
+from multistructlog import create_logger
from requests.auth import HTTPBasicAuth
+from synchronizers.new_base.SyncInstanceUsingAnsible import SyncStep
+from synchronizers.new_base.modelaccessor import OLTDevice, model_accessor
+from xosconfig import Config
+
+import os, sys
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
from helpers import Helpers
log = create_logger(Config().get('logging'))
diff --git a/xos/synchronizer/steps/sync_volt_service_instance.py b/xos/synchronizer/steps/sync_volt_service_instance.py
index eef6f7e..6703d82 100644
--- a/xos/synchronizer/steps/sync_volt_service_instance.py
+++ b/xos/synchronizer/steps/sync_volt_service_instance.py
@@ -12,16 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from synchronizers.new_base.syncstep import SyncStep, DeferredException
-from synchronizers.new_base.modelaccessor import model_accessor
-from synchronizers.new_base.modelaccessor import VOLTService, VOLTServiceInstance, ServiceInstance, OLTDevice
+import os, sys
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from xosconfig import Config
-from multistructlog import create_logger
-import requests
-from requests.auth import HTTPBasicAuth
from helpers import Helpers
+import requests
+from multistructlog import create_logger
+from requests.auth import HTTPBasicAuth
+from synchronizers.new_base.modelaccessor import VOLTService, VOLTServiceInstance, ServiceInstance, OLTDevice, model_accessor
+from synchronizers.new_base.syncstep import SyncStep, DeferredException
+from xosconfig import Config
+
log = create_logger(Config().get("logging"))
class SyncVOLTServiceInstance(SyncStep):
diff --git a/xos/synchronizer/steps/test_helpers.py b/xos/synchronizer/steps/test_helpers.py
deleted file mode 100644
index f97625e..0000000
--- a/xos/synchronizer/steps/test_helpers.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# 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 unittest
-from mock import patch, call, Mock, PropertyMock
-from helpers import Helpers
-
-class TestHelpers(unittest.TestCase):
-
- def setUp(self):
- # 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"
-
- self.o = o
-
- def test_format_url(self):
- url = Helpers.format_url("onf.com")
- self.assertEqual(url, "http://onf.com")
- url = Helpers.format_url("http://onf.com")
- self.assertEqual(url, "http://onf.com")
-
- def test_get_voltha_info(self):
- voltha_dict = Helpers.get_voltha_info(self.o)
-
- self.assertEqual(voltha_dict["url"], "http://voltha_url")
- self.assertEqual(voltha_dict["port"], 1234)
- self.assertEqual(voltha_dict["user"], "voltha_user")
- self.assertEqual(voltha_dict["pass"], "voltha_pass")
-
- def test_get_onos_info(self):
- onos_voltha_dict = Helpers.get_onos_voltha_info(self.o)
-
- self.assertEqual(onos_voltha_dict["url"], "http://onos_voltha_url")
- self.assertEqual(onos_voltha_dict["port"], 4321)
- self.assertEqual(onos_voltha_dict["user"], "onos_voltha_user")
- self.assertEqual(onos_voltha_dict["pass"], "onos_voltha_pass")
-
- def test_datapath_id_to_hex(self):
- hex = Helpers.datapath_id_to_hex(55334486016)
- self.assertEqual(hex, "0000000ce2314000")
-
- hex = Helpers.datapath_id_to_hex("55334486016")
- self.assertEqual(hex, "0000000ce2314000")
-
-if __name__ == "__main__":
- unittest.main()
\ 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 60d2d7d..cacf765 100644
--- a/xos/synchronizer/steps/test_sync_volt_service_instance.py
+++ b/xos/synchronizer/steps/test_sync_volt_service_instance.py
@@ -43,7 +43,7 @@
def mock_get_westbound_service_instance_properties(prop):
return prop
-class TestSyncOLTDevice(unittest.TestCase):
+class TestSyncVOLTServiceInstance(unittest.TestCase):
def setUp(self):
global DeferredException