Tony Mack | 79a49c8 | 2013-06-15 23:51:57 -0400 | [diff] [blame] | 1 | import threading |
Tony Mack | b4cf100 | 2014-04-29 12:26:12 -0400 | [diff] [blame] | 2 | import time |
Sapan Bhatia | 757e0b6 | 2013-09-02 16:55:00 -0400 | [diff] [blame] | 3 | from observer.event_loop import PlanetStackObserver |
| 4 | from observer.event_manager import EventListener |
Tony Mack | b4cf100 | 2014-04-29 12:26:12 -0400 | [diff] [blame] | 5 | from util.logger import Logger, logging |
Sapan Bhatia | 8fef296 | 2015-01-23 16:17:12 +0000 | [diff] [blame] | 6 | from model_policy import run_policy |
Tony Mack | b4cf100 | 2014-04-29 12:26:12 -0400 | [diff] [blame] | 7 | |
| 8 | logger = Logger(level=logging.INFO) |
Tony Mack | 79a49c8 | 2013-06-15 23:51:57 -0400 | [diff] [blame] | 9 | |
| 10 | class Backend: |
| 11 | |
| 12 | def run(self): |
Tony Mack | b4cf100 | 2014-04-29 12:26:12 -0400 | [diff] [blame] | 13 | # start the openstack observer |
| 14 | observer = PlanetStackObserver() |
| 15 | observer_thread = threading.Thread(target=observer.run) |
| 16 | observer_thread.start() |
| 17 | |
Sapan Bhatia | 8fef296 | 2015-01-23 16:17:12 +0000 | [diff] [blame] | 18 | # start model policies thread |
| 19 | model_policy_thread = threading.Thread(target=run_policy) |
| 20 | model_policy_thread.start() |
| 21 | |
Tony Mack | b4cf100 | 2014-04-29 12:26:12 -0400 | [diff] [blame] | 22 | # 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 Mack | 79a49c8 | 2013-06-15 23:51:57 -0400 | [diff] [blame] | 26 | |