blob: 4d33bf06ef2b35594b111edad9f19c4db4cab53d [file] [log] [blame]
Matteo Scandolof0441032017-08-08 13:05:26 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Matteo Scandoloceccb1f2017-06-05 10:35:44 -070017#!/usr/bin/env python
18import os
19import argparse
20import sys
21
22sys.path.append('/opt/xos')
23from xosconfig import Config
24
25config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/openstack_config.yaml')
26Config.init(config_file, 'synchronizer-config-schema.yaml')
27
28os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
29from xos.logger import Logger, logging, logger
30import time
31
32from synchronizers.new_base.modelaccessor import *
33from synchronizers.new_base.backend import Backend
34from synchronizers.new_base.event_loop import set_driver
35
36logger = Logger(level=logging.INFO)
37
38# TODO: These two lines are the only difference between this file and
39# new_base/openstack-synchronizer.py. Reconcile these.
40# set the driver.
41from synchronizers.openstack.driver import OpenStackDriver
42set_driver(OpenStackDriver())
43
44
45def main():
46 models_active = False
47 wait = False
48 while not models_active:
49 try:
50 _ = Instance.objects.first()
51 _ = NetworkTemplate.objects.first()
52 models_active = True
53 except Exception,e:
54 logger.info(str(e))
55 logger.info('Waiting for data model to come up before starting...')
56 time.sleep(10)
57 wait = True
58
59 if (wait):
60 time.sleep(60) # Safety factor, seeing that we stumbled waiting for the data model to come up.
61 backend = Backend()
62 backend.run()
63
64if __name__ == '__main__':
65
66 main()