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