Skip to content

Commit 11171aa

Browse files
author
Sergios Aftsidis
committed
Fix REST API issues
* Fix errors not allowing `PUT` method from the API * Validate `status`, to allow for status changes when using PUT (allow changing a `Route` to `INACTIVE`, re-submitting `Route`s with `ERROR` state & more) * Move decision for whether to `commit_*` a `Route` from `post_save` to `update` since we need to know both the current `status` of the `Route` and the desired (new) to pick which `commit` we want * We need to expose `id`s in all REST API models since those are needed when creating relationships between those models * Register `MatchDscp` model (`Route` uses it) * Add REST API documentation * When creating / editing / deleting a `Route` from the API an asynchronous task is issued which uploads the required configuration on the flowspec device. Since this is asynchronous, the object must have a status of `PENDING` until this operation is completed.
1 parent e8b3b34 commit 11171aa

File tree

10 files changed

+626
-163
lines changed

10 files changed

+626
-163
lines changed

README.md

Lines changed: 22 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[![Documentation Status](https://readthedocs.org/projects/flowspy/badge/?version=latest)](https://readthedocs.org/projects/flowspy/?badge=latest)
22

3-
#Firewall on Demand#
3+
# Firewall on Demand
44

5-
##Description##
5+
## Description
66

77
Firewall on Demand applies via NETCONF, flow rules to a network
88
device. These rules are then propagated via e-bgp to peering routers.
@@ -29,84 +29,40 @@ flowspec capable routers. Of course FoD could apply rules directly
2929
(via NETCONF always) to a router and then ibgp would do the rest. In
3030
GRNET's case the flowspec capable device is an EX4200.
3131

32-
**Attention**: Make sure your FoD server has ssh access to your flowspec device.
32+
**Attention**: Make sure your FoD server has SSH access to your flowspec device.
3333

34-
##Installation Considerations##
34+
## Documentation
3535

36-
You can find the installation instructions for Debian Wheezy (64)
37-
with Django 1.4.x at [Flowspy documentation](http://flowspy.readthedocs.org).
38-
If upgrading from a previous version bear in mind the changes introduced in Django 1.4.
36+
You can find detailed documentation including installation / configuration
37+
examples at [Flowspy documentation](http://flowspy.readthedocs.org).
3938

39+
## Installation Considerations
4040

41-
##Rest Api##
42-
FoD provides a rest api. It uses token as authentication method.
41+
If you are upgrading from a previous version bear in mind the changes
42+
introduced in Django 1.4.
4343

44-
### Generating Tokens
45-
A user can generate a token for his account on "my profile" page from FoD's
46-
UI. Then by using this token in the header of the request he can list, retrieve,
47-
modify and create rules.
44+
## Rest Api
45+
FoD provides a rest api. It uses token as authentication method. For usage
46+
instructions & examples check the documentation.
4847

49-
### Example Usage
50-
Here are some examples:
48+
## Limitations
5149

52-
#### GET items
53-
- List all the rules your user has created (admin users can see all the rules)
50+
A user can belong to more than one `Peer` without any limitations.
51+
FoD UI polls the server to dynamically update the dashboard and the
52+
"Live Status" about the `Route`s they are aware of. In addition, the polling
53+
implementation fetches information for every `Peer` the user is associated
54+
with. Thus, if a user belongs to many `Peer`s too many AJAX calls will be sent
55+
to the backend which may result in a non responsive state. It is recommended to
56+
keep the peers associated with any user under 5.
5457

55-
curl -X GET https://fod.example.com/api/routes/ -H 'Authorization: Token <Your users token>'
5658

57-
- Retrieve a specific rule:
58-
59-
curl -X GET https://fod.example.com/api/routes/<rule_id>/ -H 'Authorization: Token <Your users token>'
60-
61-
- In order to create or modify a rule you have to use POST/PUT methods.
62-
63-
#### POST/PUT rules
64-
In order to update or create rules you can follow this example:
65-
66-
##### Foreign Keys
67-
In order to create/modify a rule you have to connect the rule with some foreign keys:
68-
69-
###### Ports, Fragmentypes, protocols, thenactions
70-
When creating a rule, one can specify:
71-
72-
- source port
73-
- destination port
74-
- port (if source = destination)
75-
76-
That can be done by getting the url of the desired port instance from `/api/ports/<port_id>/`
77-
78-
Same with Fragmentypes in `/api/fragmenttypes/<fragmenttype_id>/`, protocols in `/api/matchprotocol/<protocol_id>/` and then actions in `/api/thenactions/<action_id>/`.
79-
80-
Since we have the urls we want to connect with the rule we want to create, we can make a POST request like the following:
81-
82-
83-
curl -X POST -H 'Authorization: Token <Your users token>' -F "name=Example" -F "comments=Description" -F "source=0.0.0.0/0" -F "sourceport=https://fod.example.com/api/ports/7/" -F "destination=203.0.113.12" https://fod.example.com/api/routes/
84-
85-
And here is a PUT request example:
86-
87-
curl -X PUT -F "name=Example" -F "comments=Description" -F "source=0.0.0.0/0" -F "sourceport=https://fod.example.com/api/ports/7/" -F "destination=83.212.9.93" https://fod.example.com/api/routes/12/ -H 'Authorization: Token <Your users token>'
88-
89-
90-
##Limitations##
91-
92-
A user can belong to more than one peer, without any limitation. This fact may
93-
produce some limitations though, to FoD application. FoD uses polling for updating
94-
dashboard and let users know about other users' actions, who belong to the same
95-
peer. In order to fetch updates from all user's peers, FoD makes ajax calls for
96-
any one of them. It is recommended not to add more than 5 peers to any user,
97-
because it may cause malfunction to FoD application.
98-
99-
100-
##Contact##
101-
102-
You can find more about FoD or raise your issues at GRNET FoD
103-
repository: [GRNET repo](https://code.grnet.gr/fod) or [Github repo](https://github.com/grnet/flowspy).
59+
## Contact
10460

10561
You can contact us directly at dev{at}noc[dot]grnet(.)gr
10662

10763
## Copyright and license
10864

109-
Copyright © 2010-2014 Greek Research and Technology Network (GRNET S.A.)
65+
Copyright © 2010-2017 Greek Research and Technology Network (GRNET S.A.)
11066

11167
This program is free software: you can redistribute it and/or modify
11268
it under the terms of the GNU General Public License as published by

0 commit comments

Comments
 (0)