instantiate sycn steps with openstack driver. Implement garbage collector and deleters
diff --git a/planetstack/observer/deleters/network_deleter.py b/planetstack/observer/deleters/network_deleter.py
new file mode 100644
index 0000000..51f9fcb
--- /dev/null
+++ b/planetstack/observer/deleters/network_deleter.py
@@ -0,0 +1,17 @@
+from core.models import Network
+from deleter import Deleter
+
+class NetworkDeleter(Deleter):
+ model='Network'
+
+ def call(self, pk):
+ network = Network.objects.get(pk=pk)
+ if (network.router_id) and (network.subnet_id):
+ self.driver.delete_router_interface(network.router_id, network.subnet_id)
+ if network.subnet_id:
+ self.driver.delete_subnet(network.subnet_id)
+ if network.router_id:
+ self.driver.delete_router(network.router_id)
+ if network.network_id:
+ self.driver.delete_network(network.network_id)
+ network.delete()
diff --git a/planetstack/observer/deleters/network_sliver_deleter.py b/planetstack/observer/deleters/network_sliver_deleter.py
new file mode 100644
index 0000000..71ba040
--- /dev/null
+++ b/planetstack/observer/deleters/network_sliver_deleter.py
@@ -0,0 +1,13 @@
+from core.models import NetworkSliver
+from observer.deleter import Deleter
+
+class NetworkSliverDeleter(Deleter):
+ model='NetworkSliver'
+
+ def call(self, pk):
+ network_sliver = NetworkSlivers.objects.get(pk=pk)
+ # handle openstack delete
+
+ network_sliver.delete()
+
+
diff --git a/planetstack/observer/deleters/site_deleter.py b/planetstack/observer/deleters/site_deleter.py
new file mode 100644
index 0000000..bb29c94
--- /dev/null
+++ b/planetstack/observer/deleters/site_deleter.py
@@ -0,0 +1,11 @@
+from core.models import Site
+from observer.delete import Deleter
+
+class SiteDeleter(Deleter):
+ model='Site'
+
+ def call(self, pk):
+ site = Site.objects.get(pk=pk)
+ if site.tenant_id:
+ self.driver.delete_tenant(site.tenant_id)
+ site.delete()
diff --git a/planetstack/observer/deleters/slice_deleter.py b/planetstack/observer/deleters/slice_deleter.py
index 4cb0a72..6796d7a 100644
--- a/planetstack/observer/deleters/slice_deleter.py
+++ b/planetstack/observer/deleters/slice_deleter.py
@@ -1,9 +1,22 @@
-#from code.models import Slice
+from core.models import Slice
+from observer.deleter import Deleter
-class SliceDeleter:
+class SliceDeleter(Deleter):
model='Slice'
def call(self, pk):
- s = Slice.objects.get(pk=pk)
-
- # Proceed with delete
+ 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.delete()
diff --git a/planetstack/observer/deleters/sliver_deleter.py b/planetstack/observer/deleters/sliver_deleter.py
new file mode 100644
index 0000000..d76b533
--- /dev/null
+++ b/planetstack/observer/deleters/sliver_deleter.py
@@ -0,0 +1,11 @@
+from core.models import Sliver
+from observer.deleter import Deleter
+
+class SliverDeleter(Deleter):
+ model='Sliver'
+
+ def call(self, pk):
+ sliver = Sliver.objects.get(pk=pk)
+ if sliver.instance_id:
+ self.driver.destroy_instance(sliver.instance_id)
+ sliver.delete()
diff --git a/planetstack/observer/deleters/user_deleter.py b/planetstack/observer/deleters/user_deleter.py
new file mode 100644
index 0000000..f250993
--- /dev/null
+++ b/planetstack/observer/deleters/user_deleter.py
@@ -0,0 +1,11 @@
+from core.models import User
+from observer.deleter import Deleter
+
+class UserDeleter(Deleter):
+ model='User'
+
+ def call(self, pk):
+ user = User.objects.get(pk=pk)
+ if user.kuser_id:
+ self.driver.delete_user(user.kuser_id)
+ user.delete()