blob: 57ed48b41d27d4632cda28fe81029e9da8526537 [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
24config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/openstack_config.yaml')
25Config.init(config_file, 'synchronizer-config-schema.yaml')
26
27os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
28from xos.logger import Logger, logging, logger
29import time
30
31from synchronizers.new_base.modelaccessor import *
32from synchronizers.new_base.backend import Backend
33from synchronizers.new_base.event_loop import set_driver
34
35logger = Logger(level=logging.INFO)
36
37# TODO: These two lines are the only difference between this file and
38# new_base/openstack-synchronizer.py. Reconcile these.
39# set the driver.
40from synchronizers.openstack.driver import OpenStackDriver
41set_driver(OpenStackDriver())
42
43
44def main():
45 models_active = False
46 wait = False
47 while not models_active:
48 try:
49 _ = Instance.objects.first()
50 _ = NetworkTemplate.objects.first()
51 models_active = True
52 except Exception,e:
53 logger.info(str(e))
54 logger.info('Waiting for data model to come up before starting...')
55 time.sleep(10)
56 wait = True
57
58 if (wait):
59 time.sleep(60) # Safety factor, seeing that we stumbled waiting for the data model to come up.
60 backend = Backend()
Zack Williams3cee57f2018-05-30 14:20:28 -070061 backend.run()
Matteo Scandoloceccb1f2017-06-05 10:35:44 -070062
63if __name__ == '__main__':
Zack Williams3cee57f2018-05-30 14:20:28 -070064
65 # Update the CA certificates
66 os.system("update-ca-certificates")
67
68 main()