blob: a57fa0ba7adfce4bc77d21a7b1f47f667caa9572 [file] [log] [blame]
Tony Mackbd3b26e2013-04-30 17:43:48 -04001import os
Tony Macked163d72013-05-02 20:05:42 -04002import sys
Siobhan Tully30fd4292013-05-10 08:59:56 -04003#os.environ.setdefault("DJANGO_SETTINGS_MODULE", "planetstack.settings")
Tony Mackbd3b26e2013-04-30 17:43:48 -04004import time
Siobhan Tully30fd4292013-05-10 08:59:56 -04005from core.models.site import Site
6from 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