sites work when openstack is disabled or unavailable
diff --git a/plstackapi/core/admin.py b/plstackapi/core/admin.py
index 58f5f58..e332c29 100644
--- a/plstackapi/core/admin.py
+++ b/plstackapi/core/admin.py
@@ -144,9 +144,9 @@
if obj is None:
continue
# give inline object access to driver and caller
- client = OpenStackClient(tenant=request.user.site.login_base, **request.session.get('auth', {}))
- inline.model.driver = OpenStackDriver(client=client)
- inline.model.caller = request.user
+ auth = request.session.get('auth', {})
+ auth['tenant'] = request.user.site.login_base
+ inline.model.os_manager = OpenStackManager(auth=auth, caller=request.user)
yield inline.get_formset(request, obj)
class SitePrivilegeAdmin(PlanetStackBaseAdmin):
diff --git a/plstackapi/core/models/site.py b/plstackapi/core/models/site.py
index 76cc0a4..2c60e16 100644
--- a/plstackapi/core/models/site.py
+++ b/plstackapi/core/models/site.py
@@ -21,26 +21,12 @@
def __unicode__(self): return u'%s' % (self.name)
def save(self, *args, **kwds):
- if not self.tenant_id:
- tenant = self.driver.create_tenant(tenant_name=self.login_base,
- description=self.name,
- enabled=self.enabled)
- self.tenant_id = tenant.id
- # give caller an admin role at the tenant they've created
- self.driver.add_user_role(self.caller.user_id, tenant.id, 'admin')
-
- # update the record
- if self.id:
- self.driver.update_tenant(self.tenant_id,
- description=self.name,
- enabled=self.enabled)
-
+ self.os_manager.save_site(self)
super(Site, self).save(*args, **kwds)
def delete(self, *args, **kwds):
- if self.tenant_id:
- self.driver.delete_tenant(self.tenant_id)
+ self.os_manager.delete_site(self)
super(Site, self).delete(*args, **kwds)