Revision e173e7c2
b/flowspec/admin.py | ||
---|---|---|
7 | 7 |
from django.contrib.auth.admin import UserAdmin |
8 | 8 |
from accounts.models import UserProfile |
9 | 9 |
|
10 |
|
|
11 | 10 |
class RouteAdmin(admin.ModelAdmin): |
12 | 11 |
|
13 | 12 |
actions = ['deactivate'] |
14 | 13 |
|
15 | 14 |
def deactivate(self, request, queryset): |
16 | 15 |
queryset = queryset.filter(status='ACTIVE') |
17 |
rows = queryset.update(status='PENDING') |
|
18 | 16 |
response = batch_delete.delay(queryset, reason="ADMININACTIVE") |
19 | 17 |
self.message_user(request, "Added request %s to job que. Check in a while for result" % response) |
20 | 18 |
deactivate.short_description = "Remove selected routes from network" |
b/flowspec/models.py | ||
---|---|---|
249 | 249 |
except: |
250 | 250 |
pass |
251 | 251 |
if found and self.status != "ACTIVE": |
252 |
logger.error('Rule is applied on device but appears as offline')
|
|
253 |
self.status = "ACTIVE"
|
|
254 |
self.save()
|
|
255 |
found = True
|
|
256 |
if not found and self.status == "ADMININACTIVE":
|
|
257 |
found = True
|
|
252 |
logger.error('Rule is applied on device but appears as offline') |
|
253 |
self.status = "ACTIVE" |
|
254 |
self.save() |
|
255 |
found = True |
|
256 |
if self.status == "ADMININACTIVE":
|
|
257 |
found = True |
|
258 | 258 |
return found |
259 | 259 |
|
260 | 260 |
def get_then(self): |
b/flowspec/tasks.py | ||
---|---|---|
61 | 61 |
@task |
62 | 62 |
def batch_delete(routes, **kwargs): |
63 | 63 |
if routes: |
64 |
for route in routes: |
|
65 |
route.status='PENDING';route.save() |
|
64 | 66 |
applier = PR.Applier(route_objects=routes) |
65 | 67 |
conf = applier.delete_routes() |
66 | 68 |
commit, response = applier.apply(configuration = conf) |
Also available in: Unified diff