blob: fe6bab2d17a3239fbe06035c452f509f9f746417 [file] [log] [blame]
Matteo Scandoloceccb1f2017-06-05 10:35:44 -07001#!/usr/bin/env python
2import os
3import argparse
4import sys
5
6sys.path.append('/opt/xos')
7from xosconfig import Config
8
9config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/openstack_config.yaml')
10Config.init(config_file, 'synchronizer-config-schema.yaml')
11
12os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
13from xos.logger import Logger, logging, logger
14import time
15
16from synchronizers.new_base.modelaccessor import *
17from synchronizers.new_base.backend import Backend
18from synchronizers.new_base.event_loop import set_driver
19
20logger = Logger(level=logging.INFO)
21
22# TODO: These two lines are the only difference between this file and
23# new_base/openstack-synchronizer.py. Reconcile these.
24# set the driver.
25from synchronizers.openstack.driver import OpenStackDriver
26set_driver(OpenStackDriver())
27
28
29def main():
30 models_active = False
31 wait = False
32 while not models_active:
33 try:
34 _ = Instance.objects.first()
35 _ = NetworkTemplate.objects.first()
36 models_active = True
37 except Exception,e:
38 logger.info(str(e))
39 logger.info('Waiting for data model to come up before starting...')
40 time.sleep(10)
41 wait = True
42
43 if (wait):
44 time.sleep(60) # Safety factor, seeing that we stumbled waiting for the data model to come up.
45 backend = Backend()
46 backend.run()
47
48if __name__ == '__main__':
49
50 main()