fix Subnet bugs
diff --git a/plstackapi/core/api/subnets.py b/plstackapi/core/api/subnets.py
index 44cd56f..1da9cf1 100644
--- a/plstackapi/core/api/subnets.py
+++ b/plstackapi/core/api/subnets.py
@@ -41,7 +41,8 @@
#driver.update_subnet(subnet.id, {'dns_nameservers': ['8.8.8.8', '8.8.4.4']})
# add subnet as interface to slice's router
- driver.add_router_interface(subnet.slice.router_id, subnet.subnet_id)
+ try: driver.add_router_interface(subnet.slice.router_id, subnet.subnet_id)
+ except: pass
add_route = 'route add -net %s dev br-ex gw 10.100.0.5' % self.cidr
commands.getstatusoutput(add_route)
subnet.save()
@@ -54,10 +55,11 @@
driver = OpenStackDriver(client = auth_check(auth))
subnets = Subnet.objects.filter(**filter)
for subnet in subnets:
- driver.delete_router_interface(subnet.slice.router_id, subnet.subnet_id)
+ try: driver.delete_router_interface(subnet.slice.router_id, subnet.subnet_id)
+ except: pass
driver.delete_subnet(subnet.subnet_id)
subnet.delete()
- del_route = 'route del -net %s' % self.cidr
+ del_route = 'route del -net %s' % subnet.cidr
commands.getstatusoutput(del_route)
return 1
diff --git a/plstackapi/core/models/subnet.py b/plstackapi/core/models/subnet.py
index 93a7ba5..8b1969a 100644
--- a/plstackapi/core/models/subnet.py
+++ b/plstackapi/core/models/subnet.py
@@ -29,7 +29,8 @@
end = self.end)
self.subnet_id = quantum_subnet['id']
# add subnet as interface to slice's router
- driver.add_router_interface(self.slice.router_id, self.subnet_id)
+ try: driver.add_router_interface(self.slice.router_id, self.subnet_id)
+ except: pass
add_route = 'route add -net %s dev br-ex gw 10.100.0.5' % self.cidr
commands.getstatusoutput(add_route)
@@ -38,8 +39,9 @@
def delete(self, *args, **kwds):
driver = OpenStackDriver()
if self.subnet_id:
- #driver.delete_router_interface(self.slice.router_id, self.subnet_id)
+ try: driver.delete_router_interface(self.slice.router_id, self.subnet_id)
+ except: pass
driver.delete_subnet(self.subnet_id)
- del_route = 'route del -net %s' % self.cidr
+ del_route = 'route del -net %s' % self.cidr
commands.getstatusoutput(del_route)
super(Subnet, self).delete(*args, **kwds)