updating deleters
diff --git a/planetstack/observer/deleters/site_deleter.py b/planetstack/observer/deleters/site_deleter.py
index a558eaf..468dfe8 100644
--- a/planetstack/observer/deleters/site_deleter.py
+++ b/planetstack/observer/deleters/site_deleter.py
@@ -1,4 +1,4 @@
-from core.models import Site
+from core.models import Site, SiteDeployments
from observer.deleter import Deleter
class SiteDeleter(Deleter):
@@ -6,6 +6,10 @@
def call(self, pk):
site = Site.objects.get(pk=pk)
- if site.tenant_id:
- self.driver.delete_tenant(site.tenant_id)
+ site_deployments = SiteDeployments.objects.filter(site=site)
+ for site_deployment in site_deployments:
+ if site_deployment.tenant_id:
+ driver = self.driver.admin_driver(deployment=site_deployment.deployment.name
+ driver.delete_tenant(site_deployment.tenant_id)
+ site_deployment.delete()
site.delete()
diff --git a/planetstack/observer/deleters/slice_deleter.py b/planetstack/observer/deleters/slice_deleter.py
index 6796d7a..d007a68 100644
--- a/planetstack/observer/deleters/slice_deleter.py
+++ b/planetstack/observer/deleters/slice_deleter.py
@@ -1,4 +1,4 @@
-from core.models import Slice
+from core.models import Slice, SliceDeployments, User
from observer.deleter import Deleter
class SliceDeleter(Deleter):
@@ -6,17 +6,26 @@
def call(self, pk):
slice = Slice.objects.get(pk=pk)
- self.driver.delete_router_interface(slice.router_id, slice.subnet_id)
- self.driver.delete_subnet(slice.subnet_id)
- self.driver.delete_router(slice.router_id)
- self.driver.delete_network(slice.network_id)
- self.driver.delete_tenant(slice.tenant_id)
- # delete external route
- subnet = None
- subnets = self.driver.shell.quantum.list_subnets()['subnets']
- for snet in subnets:
- if snet['id'] == slice.subnet_id:
- subnet = snet
- if subnet:
- self.driver.delete_external_route(subnet)
+ slice_deployments = SliceDeployments.objects.filter(slice=slice)
+ for slice_deployment in slice_deployments:
+ user = User.get(user=slice.creator)
+ driver = self.driver.admin_driver(deployment=slice_deployment.deployment.name)
+ client_driver = self.driver.client_driver(caller=user,
+ tenant=slice.name,
+ deployment=slice_deployment.deployment.name)
+
+ client_driver.delete_router_interface(slice.router_id, slice.subnet_id)
+ client_driver.delete_subnet(slice.subnet_id)
+ client_driver.delete_router(slice.router_id)
+ client_driver.delete_network(slice.network_id)
+ driver.delete_tenant(slice.tenant_id)
+ # delete external route
+ subnet = None
+ subnets = client_driver.shell.quantum.list_subnets()['subnets']
+ for snet in subnets:
+ if snet['id'] == slice.subnet_id:
+ subnet = snet
+ if subnet:
+ driver.delete_external_route(subnet)
+ slice_deployment.delete()
slice.delete()
diff --git a/planetstack/observer/deleters/sliver_deleter.py b/planetstack/observer/deleters/sliver_deleter.py
index d76b533..097f0f7 100644
--- a/planetstack/observer/deleters/sliver_deleter.py
+++ b/planetstack/observer/deleters/sliver_deleter.py
@@ -1,4 +1,4 @@
-from core.models import Sliver
+from core.models import Sliver, SliceDeployments
from observer.deleter import Deleter
class SliverDeleter(Deleter):
@@ -7,5 +7,8 @@
def call(self, pk):
sliver = Sliver.objects.get(pk=pk)
if sliver.instance_id:
- self.driver.destroy_instance(sliver.instance_id)
+ driver = self.driver.client_driver(caller=sliver.creator,
+ tenant=sliver.slice.name,
+ deployment=sliver.deploymentNetwork.name)
+ driver.destroy_instance(sliver.instance_id)
sliver.delete()
diff --git a/planetstack/observer/deleters/user_deleter.py b/planetstack/observer/deleters/user_deleter.py
index f250993..b82ea4a 100644
--- a/planetstack/observer/deleters/user_deleter.py
+++ b/planetstack/observer/deleters/user_deleter.py
@@ -1,4 +1,4 @@
-from core.models import User
+from core.models import User, UserDeployments
from observer.deleter import Deleter
class UserDeleter(Deleter):
@@ -6,6 +6,10 @@
def call(self, pk):
user = User.objects.get(pk=pk)
- if user.kuser_id:
- self.driver.delete_user(user.kuser_id)
+ user_deployments = UserDeployments.objects.filter(user=user)
+ for user_deployment in user_deployments:
+ if user_deployment.user.kuser_id:
+ driver = self.driver.admin_driver(deployment=user_deployment.deployment.name)
+ driver.delete_user(user_deployment.user.kuser_id)
+ user_deployment.delete()
user.delete()