Tony Mack | bd3b26e | 2013-04-30 17:43:48 -0400 | [diff] [blame] | 1 | import os |
| 2 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "plstackapi.planetstack.settings") |
| 3 | import time |
| 4 | from plstackapi.core.models.site import Site |
| 5 | from plstackapi.openstack.driver import OpenStackDriver |
| 6 | |
| 7 | class SiteAgent: |
| 8 | def run(self): |
| 9 | driver = OpenStackDriver() |
| 10 | # fill in null tenant ids |
Tony Mack | ea4de1a | 2013-04-30 19:07:45 -0400 | [diff] [blame] | 11 | sites = Site.objects.filter(tenant_id__in=[None, '']) |
Tony Mack | bd3b26e | 2013-04-30 17:43:48 -0400 | [diff] [blame] | 12 | for site in sites: |
| 13 | # calling save() on the model should force the tenant_id to be set |
| 14 | site.driver = driver |
Tony Mack | ea4de1a | 2013-04-30 19:07:45 -0400 | [diff] [blame] | 15 | site.caller = driver.admin_user |
| 16 | site.caller.user_id = site.caller.id |
Tony Mack | bd3b26e | 2013-04-30 17:43:48 -0400 | [diff] [blame] | 17 | site.save() |
| 18 | |
| 19 | if __name__ == '__main__': |
| 20 | SiteAgent().run() |
| 21 | |