blob: dab9e8ad03fed1c2eea13a5a243807afda301b7b [file] [log] [blame]
Tony Mackbd3b26e2013-04-30 17:43:48 -04001import os
Tony Macked163d72013-05-02 20:05:42 -04002import sys
Tony Mackbd3b26e2013-04-30 17:43:48 -04003os.environ.setdefault("DJANGO_SETTINGS_MODULE", "plstackapi.planetstack.settings")
4import time
5from plstackapi.core.models.site import Site
Tony Macked163d72013-05-02 20:05:42 -04006from plstackapi.openstack.manager import OpenStackManager
Tony Mackbd3b26e2013-04-30 17:43:48 -04007
8class SiteAgent:
9 def run(self):
Tony Macked163d72013-05-02 20:05:42 -040010 manager = OpenStackManager()
11 # exit if openstack is disable or unavailable
12 if manager.enabled and manager.has_openstack:
13 # fill in null tenant ids
14 sites = Site.objects.filter(tenant_id__in=[None, ''])
15 for site in sites:
16 # calling save() on the model should force the tenant_id to be set
17 site.os_manager = manager
18 site.save()
Tony Mackbd3b26e2013-04-30 17:43:48 -040019
20if __name__ == '__main__':
21 SiteAgent().run()
22