blob: 7b67494970d739b297874b0a281038634b9ac7dd [file] [log] [blame]
Tony Mack79a49c82013-06-15 23:51:57 -04001import threading
Tony Mackb4cf1002014-04-29 12:26:12 -04002import time
Scott Baker03552842015-02-18 16:13:48 -08003from observer.event_loop import XOSObserver
Sapan Bhatia757e0b62013-09-02 16:55:00 -04004from observer.event_manager import EventListener
Tony Mackb4cf1002014-04-29 12:26:12 -04005from util.logger import Logger, logging
Sapan Bhatia8fef2962015-01-23 16:17:12 +00006from model_policy import run_policy
Tony Mackb4cf1002014-04-29 12:26:12 -04007
8logger = Logger(level=logging.INFO)
Tony Mack79a49c82013-06-15 23:51:57 -04009
10class Backend:
11
12 def run(self):
Tony Mackb4cf1002014-04-29 12:26:12 -040013 # start the openstack observer
Scott Baker03552842015-02-18 16:13:48 -080014 observer = XOSObserver()
Tony Mackb4cf1002014-04-29 12:26:12 -040015 observer_thread = threading.Thread(target=observer.run)
16 observer_thread.start()
17
Sapan Bhatia8fef2962015-01-23 16:17:12 +000018 # start model policies thread
19 model_policy_thread = threading.Thread(target=run_policy)
20 model_policy_thread.start()
21
Tony Mackb4cf1002014-04-29 12:26:12 -040022 # start event listene
23 event_manager = EventListener(wake_up=observer.wake_up)
24 event_manager_thread = threading.Thread(target=event_manager.run)
25 event_manager_thread.start()
Tony Mack79a49c82013-06-15 23:51:57 -040026