SEBA-450 Update rcord profile to use synchronizer library
Change-Id: I07ca22d1fd6b4e1e9990c6f97eadc13a96ae1cd6
diff --git a/Dockerfile.synchronizer b/Dockerfile.synchronizer
index 9eb9c94..e6c6c50 100644
--- a/Dockerfile.synchronizer
+++ b/Dockerfile.synchronizer
@@ -16,7 +16,7 @@
# docker build -t xosproject/rcord-synchronizer:candidate -f Dockerfile.synchronizer .
# xosproject/rcord-synchronizer
-FROM xosproject/xos-synchronizer-base:2.1.32
+FROM xosproject/xos-synchronizer-base:2.1.38
COPY xos/synchronizer /opt/xos/synchronizers/rcord
COPY VERSION /opt/xos/synchronizers/rcord/
diff --git a/VERSION b/VERSION
index 59e9e60..bb83058 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.11
+1.0.12
diff --git a/xos/synchronizer/model_policies/model_policy_rcordsubscriber.py b/xos/synchronizer/model_policies/model_policy_rcordsubscriber.py
index bee0679..cb260ed 100644
--- a/xos/synchronizer/model_policies/model_policy_rcordsubscriber.py
+++ b/xos/synchronizer/model_policies/model_policy_rcordsubscriber.py
@@ -13,8 +13,8 @@
# limitations under the License.
-from synchronizers.new_base.modelaccessor import ServiceInstanceLink, model_accessor
-from synchronizers.new_base.policy import Policy
+from xossynchronizer.modelaccessor import ServiceInstanceLink, model_accessor
+from xossynchronizer.model_policies.policy import Policy
class RCORDSubscriberPolicy(Policy):
model_name = "RCORDSubscriber"
diff --git a/xos/synchronizer/model_policies/test_model_policy_rcordsubscriber.py b/xos/synchronizer/model_policies/test_model_policy_rcordsubscriber.py
index 93bb7d1..a07c681 100644
--- a/xos/synchronizer/model_policies/test_model_policy_rcordsubscriber.py
+++ b/xos/synchronizer/model_policies/test_model_policy_rcordsubscriber.py
@@ -20,44 +20,31 @@
import os, sys
test_path=os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
-service_dir=os.path.join(test_path, "../../../..")
-xos_dir=os.path.join(test_path, "../../..")
-if not os.path.exists(os.path.join(test_path, "new_base")):
- xos_dir=os.path.join(test_path, "../../../../../../orchestration/xos/xos")
- services_dir=os.path.join(xos_dir, "../../xos_services")
-
-# While transitioning from static to dynamic load, the path to find neighboring xproto files has changed. So check
-# both possible locations...
-def get_models_fn(service_name, xproto_name):
- name = os.path.join(service_name, "xos", xproto_name)
- if os.path.exists(os.path.join(services_dir, name)):
- return name
- else:
- name = os.path.join(service_name, "xos", "synchronizer", "models", xproto_name)
- if os.path.exists(os.path.join(services_dir, name)):
- return name
- raise Exception("Unable to find service=%s xproto=%s" % (service_name, xproto_name))
class TestModelPolicyRCORDSubscriber(unittest.TestCase):
def setUp(self):
self.sys_path_save = sys.path
- sys.path.append(xos_dir)
- sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base'))
config = os.path.join(test_path, "../test_config.yaml")
from xosconfig import Config
Config.clear()
Config.init(config, 'synchronizer-config-schema.yaml')
- from synchronizers.new_base.mock_modelaccessor_build import build_mock_modelaccessor
- build_mock_modelaccessor(xos_dir, services_dir, [
- get_models_fn("../profiles/rcord", "rcord.xproto"),
- get_models_fn("olt-service", "volt.xproto") # in test create we spy on VOLTServiceInstance
- ])
+ from xossynchronizer.mock_modelaccessor_build import mock_modelaccessor_config
+ mock_modelaccessor_config(test_path, [
+ ("../profiles/rcord", "rcord.xproto"),
+ ("olt-service", "volt.xproto")])
- import synchronizers.new_base.modelaccessor
- from model_policy_rcordsubscriber import RCORDSubscriberPolicy, model_accessor
+ import xossynchronizer.modelaccessor
+ import mock_modelaccessor
+ reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
+ reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous test
+
+ from xossynchronizer.modelaccessor import model_accessor
+ self.model_accessor = model_accessor
+
+ from model_policy_rcordsubscriber import RCORDSubscriberPolicy
from mock_modelaccessor import MockObjectList
@@ -69,7 +56,7 @@
# tags. Ideally, this wouldn't happen, but it does. So make sure we reset the world.
model_accessor.reset_all_object_stores()
- self.policy = RCORDSubscriberPolicy()
+ self.policy = RCORDSubscriberPolicy(model_accessor=self.model_accessor)
self.si = Mock(name="myTestSubscriber")
def tearDown(self):
diff --git a/xos/synchronizer/rcord-synchronizer.py b/xos/synchronizer/rcord-synchronizer.py
index f9ea235..205bd4a 100644
--- a/xos/synchronizer/rcord-synchronizer.py
+++ b/xos/synchronizer/rcord-synchronizer.py
@@ -18,9 +18,8 @@
# This imports and runs ../../xos-observer.py
-import importlib
import os
-import sys
+from xossynchronizer import Synchronizer
from xosconfig import Config
base_config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/config.yaml')
@@ -31,7 +30,4 @@
else:
Config.init(base_config_file, 'synchronizer-config-schema.yaml')
-observer_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"../../synchronizers/new_base")
-sys.path.append(observer_path)
-mod = importlib.import_module("xos-synchronizer")
-mod.main()
+Synchronizer().run()