root / flowspec / tasks.py @ 971645d6
History | View | Annotate | Download (1.2 kB)
1 |
from utils import proxy as PR |
---|---|
2 |
from celery.task import task |
3 |
|
4 |
@task
|
5 |
def add(route): |
6 |
applier = PR.Applier(route_object=route) |
7 |
commit, response = applier.apply() |
8 |
if commit:
|
9 |
is_online = True
|
10 |
is_active = True
|
11 |
else:
|
12 |
is_online = False
|
13 |
is_active = True
|
14 |
route.is_online = is_online |
15 |
route.is_active = is_active |
16 |
route.response = response |
17 |
route.save() |
18 |
|
19 |
@task
|
20 |
def multi(x,y): |
21 |
return x*y
|
22 |
#
|
23 |
#@task
|
24 |
#def delete(route):
|
25 |
#
|
26 |
# applier = PR.Applier(route_object=route)
|
27 |
# commit, response = applier.apply(configuration=applier.delete_routes())
|
28 |
# if commit:
|
29 |
# rows = queryset.update(is_online=False, is_active=False)
|
30 |
# queryset.update(response="Successfully removed route from network")
|
31 |
# self.message_user(request, "Successfully removed %s routes from network" % rows)
|
32 |
# else:
|
33 |
# self.message_user(request, "Could not remove routes from network")
|
34 |
# if commit:
|
35 |
# is_online = False
|
36 |
# is_active = False
|
37 |
# response = "Successfully removed route from network"
|
38 |
# else:
|
39 |
# is_online = False
|
40 |
# is_active = True
|
41 |
# route.is_online = is_online
|
42 |
# route.is_active = is_active
|
43 |
# route.response = response
|
44 |
# route.save()
|