blob: 98fedaebef7fb04603a23c192fe364e43e8a42a3 [file] [log] [blame]
Tony Mackbd3b26e2013-04-30 17:43:48 -04001import os
2os.environ.setdefault("DJANGO_SETTINGS_MODULE", "plstackapi.planetstack.settings")
3import time
4from plstackapi.core.models.site import Site
5from plstackapi.openstack.driver import OpenStackDriver
6
7class SiteAgent:
8 def run(self):
9 driver = OpenStackDriver()
10 # fill in null tenant ids
Tony Mackea4de1a2013-04-30 19:07:45 -040011 sites = Site.objects.filter(tenant_id__in=[None, ''])
Tony Mackbd3b26e2013-04-30 17:43:48 -040012 for site in sites:
13 # calling save() on the model should force the tenant_id to be set
14 site.driver = driver
Tony Mackea4de1a2013-04-30 19:07:45 -040015 site.caller = driver.admin_user
16 site.caller.user_id = site.caller.id
Tony Mackbd3b26e2013-04-30 17:43:48 -040017 site.save()
18
19if __name__ == '__main__':
20 SiteAgent().run()
21