Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
| 3 | from planetstack.config import Config |
Tony Mack | 66646d5 | 2013-09-24 21:47:12 -0400 | [diff] [blame] | 4 | from observer.openstacksyncstep import OpenStackSyncStep |
Sapan Bhatia | 475c597 | 2014-11-05 10:32:41 -0500 | [diff] [blame] | 5 | from core.models.site import Deployment |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 6 | |
Tony Mack | 66646d5 | 2013-09-24 21:47:12 -0400 | [diff] [blame] | 7 | class SyncExternalRoutes(OpenStackSyncStep): |
| 8 | # XXX what does this provide? |
| 9 | provides=[] |
| 10 | requested_interval = 86400 # This step is slow like a pig. Let's run it infrequently |
Sapan Bhatia | 2ef36c8 | 2013-09-02 14:30:37 -0400 | [diff] [blame] | 11 | |
Tony Mack | a76b895 | 2013-10-05 23:36:30 -0400 | [diff] [blame] | 12 | def call(self, **args): |
Sapan Bhatia | 475c597 | 2014-11-05 10:32:41 -0500 | [diff] [blame] | 13 | deployments = Deployment.objects.all() |
| 14 | self.driver = self.driver.admin_driver(deployment=deployments[0],tenant='admin') |
Tony Mack | 66646d5 | 2013-09-24 21:47:12 -0400 | [diff] [blame] | 15 | routes = self.driver.get_external_routes() |
| 16 | subnets = self.driver.shell.quantum.list_subnets()['subnets'] |
| 17 | for subnet in subnets: |
| 18 | try: |
| 19 | self.driver.add_external_route(subnet, routes) |
| 20 | except: |
| 21 | logger.log_exc("failed to add external route for subnet %s" % subnet) |