fix openstack integration
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index 58e9689..20c3a81 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -423,14 +423,14 @@
list_filter = ('site',)
inlines = [SitePrivilegeInline, SliceMembershipInline]
fieldsets = (
- (None, {'fields': ('email', 'password', 'site')}),
+ (None, {'fields': ('email', 'password', 'site', 'is_admin')}),
('Personal info', {'fields': ('firstname','lastname','phone', 'key')}),
#('Important dates', {'fields': ('last_login',)}),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
- 'fields': ('email', 'firstname', 'lastname', 'phone', 'site', 'key','password1', 'password2')}
+ 'fields': ('email', 'firstname', 'lastname', 'phone', 'site', 'key','password1', 'password2', 'is_admin')}
),
)
search_fields = ('email',)
diff --git a/planetstack/core/models/__init__.py b/planetstack/core/models/__init__.py
index 0fe5e47..d922802 100644
--- a/planetstack/core/models/__init__.py
+++ b/planetstack/core/models/__init__.py
@@ -10,7 +10,5 @@
from .slice import Slice
from .slice import SliceMembership
from .sliver import Sliver
-from .subnet import Subnet
from .serviceclass import ServiceClass
from .serviceresource import ServiceResource
-
diff --git a/planetstack/core/models/key.py b/planetstack/core/models/key.py
index 7a8b322..6fd7c34 100644
--- a/planetstack/core/models/key.py
+++ b/planetstack/core/models/key.py
@@ -1,8 +1,6 @@
import os
from django.db import models
from core.models import PlCoreBase
-from openstack.manager import OpenStackManager
-
# Create your models here.
@@ -17,13 +15,15 @@
def save(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.save_key(self)
+ self.os_manager.save_key(self)
super(Key, self).save(*args, **kwds)
def delete(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.delete_key(self)
+ self.os_manager.delete_key(self)
super(Key, self).delete(*args, **kwds)
diff --git a/planetstack/core/models/role.py b/planetstack/core/models/role.py
index d3c577d..f6c2f2c 100644
--- a/planetstack/core/models/role.py
+++ b/planetstack/core/models/role.py
@@ -2,7 +2,6 @@
import datetime
from django.db import models
from core.models import PlCoreBase
-from openstack.manager import OpenStackManager
class Role(PlCoreBase):
@@ -15,13 +14,15 @@
def save(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.save_role(self)
+ self.os_manager.save_role(self)
super(Role, self).save(*args, **kwds)
def delete(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.delete_role(self)
+ self.os_manager.delete_role(self)
super(Role, self).delete(*args, **kwds)
diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py
index 11e6a28..8626a0d 100644
--- a/planetstack/core/models/site.py
+++ b/planetstack/core/models/site.py
@@ -2,7 +2,6 @@
from django.db import models
from core.models import PlCoreBase
from core.models import DeploymentNetwork
-from openstack.manager import OpenStackManager
class Site(PlCoreBase):
@@ -22,15 +21,17 @@
def save(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.save_site(self)
+ self.os_manager.save_site(self)
super(Site, self).save(*args, **kwds)
def delete(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.delete_site(self)
+ self.os_manager.delete_site(self)
super(Site, self).delete(*args, **kwds)
@@ -44,12 +45,14 @@
def save(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
self.os_manager.driver.add_user_role(self.user.kuser_id, self.site.tenant_id, self.role.role_type)
super(SitePrivilege, self).save(*args, **kwds)
def delete(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
self.os_manager.driver.delete_user_role(self.user.kuser_id, self.site.tenant_id, self.role.role_type)
super(SitePrivilege, self).delete(*args, **kwds)
diff --git a/planetstack/core/models/slice.py b/planetstack/core/models/slice.py
index 2fd9fd3..edbe824 100644
--- a/planetstack/core/models/slice.py
+++ b/planetstack/core/models/slice.py
@@ -5,7 +5,6 @@
from core.models import User
from core.models import Role
from core.models import DeploymentNetwork
-from openstack.manager import OpenStackManager
# Create your models here.
@@ -29,14 +28,16 @@
def save(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.save_slice(self)
+ self.os_manager.save_slice(self)
super(Slice, self).save(*args, **kwds)
def delete(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.delete_slice(self)
+ self.os_manager.delete_slice(self)
super(Slice, self).delete(*args, **kwds)
class SliceMembership(PlCoreBase):
@@ -48,6 +49,7 @@
def save(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
if self.os_manager.driver:
self.os_manager.driver.add_user_role(self.user.kuser_id, self.slice.tenant_id, self.role.role_type)
@@ -55,6 +57,7 @@
def delete(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
if self.os_manager.driver:
self.os_manager.driver.delete_user_role(self.user.kuser_id, self.slice.tenant_id, self.role.role_type)
diff --git a/planetstack/core/models/sliver.py b/planetstack/core/models/sliver.py
index 8ebcbd4..ff074a6 100644
--- a/planetstack/core/models/sliver.py
+++ b/planetstack/core/models/sliver.py
@@ -8,7 +8,6 @@
from core.models import Node
from core.models import Site
from core.models import DeploymentNetwork
-from openstack.manager import OpenStackManager
# Create your models here.
class Sliver(PlCoreBase):
@@ -30,12 +29,14 @@
if not self.name:
self.name = self.slice.name
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.save_sliver(self)
+ self.os_manager.save_sliver(self)
super(Sliver, self).save(*args, **kwds)
def delete(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.delete_sliver(self)
+ self.os_manager.delete_sliver(self)
super(Sliver, self).delete(*args, **kwds)
diff --git a/planetstack/core/models/subnet.py b/planetstack/core/models/subnet.py
deleted file mode 100644
index 37175ec..0000000
--- a/planetstack/core/models/subnet.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import os
-import commands
-from django.db import models
-from core.models import PlCoreBase
-from core.models import Slice
-from openstack.manager import OpenStackManager
-
-# Create your models here.
-
-class Subnet(PlCoreBase):
- subnet_id = models.CharField(max_length=256, unique=True)
- cidr = models.CharField(max_length=20)
- ip_version = models.IntegerField()
- start = models.IPAddressField()
- end = models.IPAddressField()
- slice = models.ForeignKey(Slice, related_name='subnet')
-
- def __unicode__(self): return u'%s' % (self.slice.name)
-
- def save(self, *args, **kwds):
- if not hasattr(self, 'os_manager'):
- setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.save_subnet(self)
- super(Subnet, self).save(*args, **kwds)
-
- def delete(self, *args, **kwds):
- if not hasattr(self, 'os_manager'):
- setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.delete_subnet(self)
- super(Subnet, self).delete(*args, **kwds)
diff --git a/planetstack/core/models/user.py b/planetstack/core/models/user.py
index 38c0d89..e6c42e7 100644
--- a/planetstack/core/models/user.py
+++ b/planetstack/core/models/user.py
@@ -5,7 +5,6 @@
from core.models import PlCoreBase
from core.models import Site
from core.models import Key
-from openstack.manager import OpenStackManager
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
# Create your models here.
@@ -110,8 +109,9 @@
def save(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.save_user(self)
+ self.os_manager.save_user(self)
if not self.id:
self.set_password(self.password)
@@ -119,7 +119,8 @@
def delete(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
+ from openstack.manager import OpenStackManager
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.delete_user(self)
+ self.os_manager.delete_user(self)
super(User, self).delete(*args, **kwds)