Tony Mack | 71592a5 | 2013-03-28 20:17:47 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | import os |
| 3 | import sys |
Tony Mack | 745bf6e | 2013-04-17 11:06:35 -0400 | [diff] [blame] | 4 | import threading |
Tony Mack | 71592a5 | 2013-03-28 20:17:47 -0400 | [diff] [blame] | 5 | |
Tony Mack | 2ff8622 | 2013-05-10 16:54:14 -0400 | [diff] [blame] | 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "planetstack.settings") |
Siobhan Tully | 30fd429 | 2013-05-10 08:59:56 -0400 | [diff] [blame] | 7 | from planetstack.config import Config |
| 8 | from openstack.sliveragent import SliverAgent |
Tony Mack | 0553f28 | 2013-06-10 22:54:50 -0400 | [diff] [blame] | 9 | from openstack.observer import OpenStackObserver |
Tony Mack | 71592a5 | 2013-03-28 20:17:47 -0400 | [diff] [blame] | 10 | |
| 11 | if __name__ == '__main__': |
| 12 | |
Tony Mack | cd6bf66 | 2013-04-30 18:20:27 -0400 | [diff] [blame] | 13 | # bootstrap envirnment |
Tony Mack | 71592a5 | 2013-03-28 20:17:47 -0400 | [diff] [blame] | 14 | from django.core.management import ManagementUtility |
| 15 | config = Config() |
Tony Mack | e02d720 | 2013-03-29 11:23:56 -0400 | [diff] [blame] | 16 | url = "%s:%s" % (config.api_host, config.api_port) |
Tony Mack | 71592a5 | 2013-03-28 20:17:47 -0400 | [diff] [blame] | 17 | args = [__file__, 'runserver', url] |
Tony Mack | cd6bf66 | 2013-04-30 18:20:27 -0400 | [diff] [blame] | 18 | |
Tony Mack | cd6bf66 | 2013-04-30 18:20:27 -0400 | [diff] [blame] | 19 | |
| 20 | # start the sliver agent thread |
Tony Mack | 704c1b0 | 2013-04-17 10:45:45 -0400 | [diff] [blame] | 21 | sliver_agent = SliverAgent() |
Tony Mack | 745bf6e | 2013-04-17 11:06:35 -0400 | [diff] [blame] | 22 | sliver_agent_thread = threading.Thread(target=sliver_agent.run) |
| 23 | sliver_agent_thread.start() |
Tony Mack | cd6bf66 | 2013-04-30 18:20:27 -0400 | [diff] [blame] | 24 | |
Tony Mack | 0553f28 | 2013-06-10 22:54:50 -0400 | [diff] [blame] | 25 | # start the openstack observer |
| 26 | observer = OpenStackObserver() |
| 27 | observer_thread = threading.Thread(target=observer.run) |
| 28 | observer_thread.start() |
| 29 | |
Tony Mack | cd6bf66 | 2013-04-30 18:20:27 -0400 | [diff] [blame] | 30 | # start the server |
| 31 | server = ManagementUtility(args) |
Tony Mack | 745bf6e | 2013-04-17 11:06:35 -0400 | [diff] [blame] | 32 | server.execute() |