SEBA-405 Update openstack synchronizer to use synchronizer library
Change-Id: I9adae42fa7eec94ee496b728c32a7ce5db3c39e0
diff --git a/xos/synchronizer/openstack-synchronizer.py b/xos/synchronizer/openstack-synchronizer.py
index e86e6f3..8d71f3a 100644
--- a/xos/synchronizer/openstack-synchronizer.py
+++ b/xos/synchronizer/openstack-synchronizer.py
@@ -15,10 +15,7 @@
# limitations under the License.
import os
-import argparse
-import sys
-
-sys.path.append('/opt/xos')
+from xossynchronizer import Synchronizer
from xosconfig import Config
base_config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/config.yaml')
@@ -29,45 +26,11 @@
else:
Config.init(base_config_file, 'synchronizer-config-schema.yaml')
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
-from xos.logger import Logger, logging, logger
-import time
-
-from synchronizers.new_base.modelaccessor import *
-from synchronizers.new_base.backend import Backend
-from synchronizers.new_base.event_loop import set_driver
-
-logger = Logger(level=logging.INFO)
-
-# TODO: These two lines are the only difference between this file and
-# new_base/openstack-synchronizer.py. Reconcile these.
-# set the driver.
-from synchronizers.openstack.driver import OpenStackDriver
+from xossynchronizer.event_loop import set_driver
+from driver import OpenStackDriver
set_driver(OpenStackDriver())
+# Update the CA certificates
+os.system("update-ca-certificates")
-def main():
- models_active = False
- wait = False
- while not models_active:
- try:
- _ = Instance.objects.first()
- _ = NetworkTemplate.objects.first()
- models_active = True
- except Exception,e:
- logger.info(str(e))
- logger.info('Waiting for data model to come up before starting...')
- time.sleep(10)
- wait = True
-
- if (wait):
- time.sleep(60) # Safety factor, seeing that we stumbled waiting for the data model to come up.
- backend = Backend()
- backend.run()
-
-if __name__ == '__main__':
-
- # Update the CA certificates
- os.system("update-ca-certificates")
-
- main()
+Synchronizer().run()