[CORD-1360] Using new config
Change-Id: I949ebac5e3ef267b8da70c61e8cf4f9d1c654907
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..723ef36
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.idea
\ No newline at end of file
diff --git a/xos/synchronizer/onos-synchronizer.py b/xos/synchronizer/onos-synchronizer.py
index 26b44df..77ee91c 100755
--- a/xos/synchronizer/onos-synchronizer.py
+++ b/xos/synchronizer/onos-synchronizer.py
@@ -5,6 +5,11 @@
import importlib
import os
import sys
+from xosconfig import Config
+
+config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/onos_config.yaml')
+Config.init(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")
diff --git a/xos/synchronizer/onos_config.yaml b/xos/synchronizer/onos_config.yaml
new file mode 100644
index 0000000..c78ce54
--- /dev/null
+++ b/xos/synchronizer/onos_config.yaml
@@ -0,0 +1,7 @@
+name: onos-synchronizer
+accessor:
+ username: xosadmin@opencord.org
+ password: "@/opt/xos/services/onos/credentials/xosadmin@opencord.org"
+dependency_graph: "/opt/xos/synchronizers/onos/model-deps"
+steps_dir: "/opt/xos/synchronizers/onos/steps"
+sys_dir: "/opt/xos/synchronizers/onos/sys"
\ No newline at end of file
diff --git a/xos/synchronizer/onos_from_api_config b/xos/synchronizer/onos_from_api_config
deleted file mode 100644
index 5510aca..0000000
--- a/xos/synchronizer/onos_from_api_config
+++ /dev/null
@@ -1,20 +0,0 @@
-# Sets options for the synchronizer
-[observer]
-name=onos
-dependency_graph=/opt/xos/synchronizers/onos/model-deps
-steps_dir=/opt/xos/synchronizers/onos/steps
-sys_dir=/opt/xos/synchronizers/onos/sys
-#logfile=/var/log/xos_backend.log
-log_file=console
-log_level=debug
-pretend=False
-backoff_disabled=True
-save_ansible_output=True
-proxy_ssh=True
-proxy_ssh_key=/opt/cord_profile/node_key
-proxy_ssh_user=root
-accessor_kind=api
-accessor_password=@/opt/xos/services/onos/credentials/xosadmin@opencord.org
-
-[networking]
-use_vtn=True
diff --git a/xos/synchronizer/run-from-api.sh b/xos/synchronizer/run-from-api.sh
index 5fe9bc9..474d154 100755
--- a/xos/synchronizer/run-from-api.sh
+++ b/xos/synchronizer/run-from-api.sh
@@ -1,2 +1 @@
-export XOS_DIR=/opt/xos
-python onos-synchronizer.py -C $XOS_DIR/synchronizers/onos/onos_from_api_config
+python onos-synchronizer.py
diff --git a/xos/synchronizer/steps/sync_onosapp.py b/xos/synchronizer/steps/sync_onosapp.py
index cba8290..ae9c5d7 100644
--- a/xos/synchronizer/steps/sync_onosapp.py
+++ b/xos/synchronizer/steps/sync_onosapp.py
@@ -7,7 +7,7 @@
import re
import json
from collections import OrderedDict
-from xos.config import Config
+from xosconfig import Config
from synchronizers.new_base.ansible_helper import run_template
from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
from synchronizers.new_base.modelaccessor import *
@@ -58,12 +58,7 @@
return self.is_no_container(o)
def get_files_dir(self, o):
- if not hasattr(Config(), "observer_steps_dir"):
- # make steps_dir mandatory; there's no valid reason for it to not
- # be defined.
- raise Exception("observer_steps_dir is not defined in config file")
-
- step_dir = Config().observer_steps_dir
+ step_dir = Config.get("steps_dir")
return os.path.join(step_dir, "..", "files", str(self.get_onos_service(o).id), o.name)
diff --git a/xos/synchronizer/steps/sync_onosservice.py b/xos/synchronizer/steps/sync_onosservice.py
index e038949..c8abe57 100644
--- a/xos/synchronizer/steps/sync_onosservice.py
+++ b/xos/synchronizer/steps/sync_onosservice.py
@@ -4,7 +4,6 @@
import sys
import base64
import time
-from xos.config import Config
from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
from synchronizers.new_base.modelaccessor import *
from xos.logger import Logger, logging