Revision a3af8464

b/.gitignore
1
settings.py
2
*.pyc
b/flowspec/migrations/0001_initial.py
1
# encoding: utf-8
2
import datetime
3
from south.db import db
4
from south.v2 import SchemaMigration
5
from django.db import models
6

  
7
class Migration(SchemaMigration):
8
    
9
    def forwards(self, orm):
10
        
11
        # Adding model 'MatchAddress'
12
        db.create_table(u'match_address', (
13
            ('destination', self.gf('django.db.models.fields.CharField')(max_length=255)),
14
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
15
        ))
16
        db.send_create_signal('flowspec', ['MatchAddress'])
17

  
18
        # Adding model 'MatchPort'
19
        db.create_table(u'match_port', (
20
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
21
            ('port', self.gf('django.db.models.fields.CharField')(max_length=24)),
22
        ))
23
        db.send_create_signal('flowspec', ['MatchPort'])
24

  
25
        # Adding model 'MatchDscp'
26
        db.create_table(u'match_dscp', (
27
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
28
            ('dscp', self.gf('django.db.models.fields.CharField')(max_length=24)),
29
        ))
30
        db.send_create_signal('flowspec', ['MatchDscp'])
31

  
32
        # Adding model 'MatchFragmentType'
33
        db.create_table(u'match_fragment_type', (
34
            ('fragmenttype', self.gf('django.db.models.fields.CharField')(max_length=20)),
35
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
36
        ))
37
        db.send_create_signal('flowspec', ['MatchFragmentType'])
38

  
39
        # Adding model 'MatchIcmpCode'
40
        db.create_table(u'match_icmp_code', (
41
            ('icmp_code', self.gf('django.db.models.fields.CharField')(max_length=64)),
42
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
43
        ))
44
        db.send_create_signal('flowspec', ['MatchIcmpCode'])
45

  
46
        # Adding model 'MatchIcmpType'
47
        db.create_table(u'match_icmp_type', (
48
            ('icmp_type', self.gf('django.db.models.fields.CharField')(max_length=64)),
49
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
50
        ))
51
        db.send_create_signal('flowspec', ['MatchIcmpType'])
52

  
53
        # Adding model 'MatchPacketLength'
54
        db.create_table(u'match_packet_length', (
55
            ('packet_length', self.gf('django.db.models.fields.IntegerField')()),
56
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
57
        ))
58
        db.send_create_signal('flowspec', ['MatchPacketLength'])
59

  
60
        # Adding model 'MatchProtocol'
61
        db.create_table(u'match_protocol', (
62
            ('protocol', self.gf('django.db.models.fields.CharField')(max_length=64)),
63
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
64
        ))
65
        db.send_create_signal('flowspec', ['MatchProtocol'])
66

  
67
        # Adding model 'MatchTcpFlag'
68
        db.create_table(u'match_tcp_flag', (
69
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
70
            ('tcp_flag', self.gf('django.db.models.fields.CharField')(max_length=255)),
71
        ))
72
        db.send_create_signal('flowspec', ['MatchTcpFlag'])
73

  
74
        # Adding model 'ThenAction'
75
        db.create_table(u'then_action', (
76
            ('action', self.gf('django.db.models.fields.CharField')(max_length=60)),
77
            ('action_value', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)),
78
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
79
        ))
80
        db.send_create_signal('flowspec', ['ThenAction'])
81

  
82
        # Adding model 'ThenStatement'
83
        db.create_table(u'then', (
84
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
85
        ))
86
        db.send_create_signal('flowspec', ['ThenStatement'])
87

  
88
        # Adding M2M table for field thenaction on 'ThenStatement'
89
        db.create_table(u'then_thenaction', (
90
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
91
            ('thenstatement', models.ForeignKey(orm['flowspec.thenstatement'], null=False)),
92
            ('thenaction', models.ForeignKey(orm['flowspec.thenaction'], null=False))
93
        ))
94
        db.create_unique(u'then_thenaction', ['thenstatement_id', 'thenaction_id'])
95

  
96
        # Adding model 'MatchStatement'
97
        db.create_table(u'match', (
98
            ('matchfragmenttype', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['flowspec.MatchFragmentType'], null=True, blank=True)),
99
            ('matchprotocol', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['flowspec.MatchProtocol'], null=True, blank=True)),
100
            ('matchicmptype', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['flowspec.MatchIcmpType'], null=True, blank=True)),
101
            ('matchSourcePort', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='matchSourcePort', null=True, to=orm['flowspec.MatchPort'])),
102
            ('matchicmpcode', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['flowspec.MatchIcmpCode'], null=True, blank=True)),
103
            ('matchTcpFlag', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['flowspec.MatchTcpFlag'], null=True, blank=True)),
104
            ('matchDestination', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='matchDestination', null=True, to=orm['flowspec.MatchAddress'])),
105
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
106
            ('matchpacketlength', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['flowspec.MatchPacketLength'], null=True, blank=True)),
107
        ))
108
        db.send_create_signal('flowspec', ['MatchStatement'])
109

  
110
        # Adding M2M table for field matchDestinationPort on 'MatchStatement'
111
        db.create_table(u'match_matchDestinationPort', (
112
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
113
            ('matchstatement', models.ForeignKey(orm['flowspec.matchstatement'], null=False)),
114
            ('matchport', models.ForeignKey(orm['flowspec.matchport'], null=False))
115
        ))
116
        db.create_unique(u'match_matchDestinationPort', ['matchstatement_id', 'matchport_id'])
117

  
118
        # Adding M2M table for field matchSource on 'MatchStatement'
119
        db.create_table(u'match_matchSource', (
120
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
121
            ('matchstatement', models.ForeignKey(orm['flowspec.matchstatement'], null=False)),
122
            ('matchaddress', models.ForeignKey(orm['flowspec.matchaddress'], null=False))
123
        ))
124
        db.create_unique(u'match_matchSource', ['matchstatement_id', 'matchaddress_id'])
125

  
126
        # Adding M2M table for field matchdscp on 'MatchStatement'
127
        db.create_table(u'match_matchdscp', (
128
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
129
            ('matchstatement', models.ForeignKey(orm['flowspec.matchstatement'], null=False)),
130
            ('matchdscp', models.ForeignKey(orm['flowspec.matchdscp'], null=False))
131
        ))
132
        db.create_unique(u'match_matchdscp', ['matchstatement_id', 'matchdscp_id'])
133

  
134
        # Adding M2M table for field matchport on 'MatchStatement'
135
        db.create_table(u'match_matchport', (
136
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
137
            ('matchstatement', models.ForeignKey(orm['flowspec.matchstatement'], null=False)),
138
            ('matchport', models.ForeignKey(orm['flowspec.matchport'], null=False))
139
        ))
140
        db.create_unique(u'match_matchport', ['matchstatement_id', 'matchport_id'])
141

  
142
        # Adding model 'Route'
143
        db.create_table(u'route', (
144
            ('then', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['flowspec.ThenStatement'])),
145
            ('last_updated', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
146
            ('name', self.gf('django.db.models.fields.CharField')(max_length=128)),
147
            ('expires', self.gf('django.db.models.fields.DateTimeField')()),
148
            ('applier', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
149
            ('filed', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
150
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
151
            ('match', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['flowspec.MatchStatement'])),
152
        ))
153
        db.send_create_signal('flowspec', ['Route'])
154
    
155
    
156
    def backwards(self, orm):
157
        
158
        # Deleting model 'MatchAddress'
159
        db.delete_table(u'match_address')
160

  
161
        # Deleting model 'MatchPort'
162
        db.delete_table(u'match_port')
163

  
164
        # Deleting model 'MatchDscp'
165
        db.delete_table(u'match_dscp')
166

  
167
        # Deleting model 'MatchFragmentType'
168
        db.delete_table(u'match_fragment_type')
169

  
170
        # Deleting model 'MatchIcmpCode'
171
        db.delete_table(u'match_icmp_code')
172

  
173
        # Deleting model 'MatchIcmpType'
174
        db.delete_table(u'match_icmp_type')
175

  
176
        # Deleting model 'MatchPacketLength'
177
        db.delete_table(u'match_packet_length')
178

  
179
        # Deleting model 'MatchProtocol'
180
        db.delete_table(u'match_protocol')
181

  
182
        # Deleting model 'MatchTcpFlag'
183
        db.delete_table(u'match_tcp_flag')
184

  
185
        # Deleting model 'ThenAction'
186
        db.delete_table(u'then_action')
187

  
188
        # Deleting model 'ThenStatement'
189
        db.delete_table(u'then')
190

  
191
        # Removing M2M table for field thenaction on 'ThenStatement'
192
        db.delete_table('then_thenaction')
193

  
194
        # Deleting model 'MatchStatement'
195
        db.delete_table(u'match')
196

  
197
        # Removing M2M table for field matchDestinationPort on 'MatchStatement'
198
        db.delete_table('match_matchDestinationPort')
199

  
200
        # Removing M2M table for field matchSource on 'MatchStatement'
201
        db.delete_table('match_matchSource')
202

  
203
        # Removing M2M table for field matchdscp on 'MatchStatement'
204
        db.delete_table('match_matchdscp')
205

  
206
        # Removing M2M table for field matchport on 'MatchStatement'
207
        db.delete_table('match_matchport')
208

  
209
        # Deleting model 'Route'
210
        db.delete_table(u'route')
211
    
212
    
213
    models = {
214
        'auth.group': {
215
            'Meta': {'object_name': 'Group'},
216
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
217
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
218
            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
219
        },
220
        'auth.permission': {
221
            'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
222
            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
223
            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
224
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
225
            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
226
        },
227
        'auth.user': {
228
            'Meta': {'object_name': 'User'},
229
            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
230
            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
231
            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
232
            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
233
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
234
            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
235
            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
236
            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
237
            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
238
            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
239
            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
240
            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
241
            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
242
        },
243
        'contenttypes.contenttype': {
244
            'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
245
            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
246
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
247
            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
248
            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
249
        },
250
        'flowspec.matchaddress': {
251
            'Meta': {'object_name': 'MatchAddress', 'db_table': "u'match_address'"},
252
            'destination': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
253
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
254
        },
255
        'flowspec.matchdscp': {
256
            'Meta': {'object_name': 'MatchDscp', 'db_table': "u'match_dscp'"},
257
            'dscp': ('django.db.models.fields.CharField', [], {'max_length': '24'}),
258
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
259
        },
260
        'flowspec.matchfragmenttype': {
261
            'Meta': {'object_name': 'MatchFragmentType', 'db_table': "u'match_fragment_type'"},
262
            'fragmenttype': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
263
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
264
        },
265
        'flowspec.matchicmpcode': {
266
            'Meta': {'object_name': 'MatchIcmpCode', 'db_table': "u'match_icmp_code'"},
267
            'icmp_code': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
268
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
269
        },
270
        'flowspec.matchicmptype': {
271
            'Meta': {'object_name': 'MatchIcmpType', 'db_table': "u'match_icmp_type'"},
272
            'icmp_type': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
273
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
274
        },
275
        'flowspec.matchpacketlength': {
276
            'Meta': {'object_name': 'MatchPacketLength', 'db_table': "u'match_packet_length'"},
277
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
278
            'packet_length': ('django.db.models.fields.IntegerField', [], {})
279
        },
280
        'flowspec.matchport': {
281
            'Meta': {'object_name': 'MatchPort', 'db_table': "u'match_port'"},
282
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
283
            'port': ('django.db.models.fields.CharField', [], {'max_length': '24'})
284
        },
285
        'flowspec.matchprotocol': {
286
            'Meta': {'object_name': 'MatchProtocol', 'db_table': "u'match_protocol'"},
287
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
288
            'protocol': ('django.db.models.fields.CharField', [], {'max_length': '64'})
289
        },
290
        'flowspec.matchstatement': {
291
            'Meta': {'object_name': 'MatchStatement', 'db_table': "u'match'"},
292
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
293
            'matchDestination': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'matchDestination'", 'null': 'True', 'to': "orm['flowspec.MatchAddress']"}),
294
            'matchDestinationPort': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchDestinationPort'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']"}),
295
            'matchSource': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchSource'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchAddress']"}),
296
            'matchSourcePort': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'matchSourcePort'", 'null': 'True', 'to': "orm['flowspec.MatchPort']"}),
297
            'matchTcpFlag': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['flowspec.MatchTcpFlag']", 'null': 'True', 'blank': 'True'}),
298
            'matchdscp': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['flowspec.MatchDscp']", 'null': 'True', 'blank': 'True'}),
299
            'matchfragmenttype': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['flowspec.MatchFragmentType']", 'null': 'True', 'blank': 'True'}),
300
            'matchicmpcode': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['flowspec.MatchIcmpCode']", 'null': 'True', 'blank': 'True'}),
301
            'matchicmptype': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['flowspec.MatchIcmpType']", 'null': 'True', 'blank': 'True'}),
302
            'matchpacketlength': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['flowspec.MatchPacketLength']", 'null': 'True', 'blank': 'True'}),
303
            'matchport': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']", 'null': 'True', 'blank': 'True'}),
304
            'matchprotocol': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['flowspec.MatchProtocol']", 'null': 'True', 'blank': 'True'})
305
        },
306
        'flowspec.matchtcpflag': {
307
            'Meta': {'object_name': 'MatchTcpFlag', 'db_table': "u'match_tcp_flag'"},
308
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
309
            'tcp_flag': ('django.db.models.fields.CharField', [], {'max_length': '255'})
310
        },
311
        'flowspec.route': {
312
            'Meta': {'object_name': 'Route', 'db_table': "u'route'"},
313
            'applier': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
314
            'expires': ('django.db.models.fields.DateTimeField', [], {}),
315
            'filed': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
316
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
317
            'last_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
318
            'match': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['flowspec.MatchStatement']"}),
319
            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
320
            'then': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['flowspec.ThenStatement']"})
321
        },
322
        'flowspec.thenaction': {
323
            'Meta': {'object_name': 'ThenAction', 'db_table': "u'then_action'"},
324
            'action': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
325
            'action_value': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
326
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
327
        },
328
        'flowspec.thenstatement': {
329
            'Meta': {'object_name': 'ThenStatement', 'db_table': "u'then'"},
330
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
331
            'thenaction': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['flowspec.ThenAction']", 'null': 'True', 'blank': 'True'})
332
        }
333
    }
334
    
335
    complete_apps = ['flowspec']
b/flowspec/models.py
1
from django.db import models
2
from django.contrib.auth.models import User
3

  
4
FRAGMENT_CODES = (
5
    ("dont-fragment", "Don't fragment"),
6
    ("first-fragment", "First fragment"),
7
    ("is-fragment", "Is fragment"),
8
    ("last-fragment", "Last fragment"),
9
    ("not-a-fragment", "Not a fragment")
10
)
11

  
12
THEN_CHOICES = (
13
    ("accept", "Accept"),
14
    ("discard", "Discard"),
15
    ("community", "Community"),
16
    ("next-term", "Next term"),
17
    ("routing-instance", "Routing Instance"),
18
    ("rate-limit", "Rate limit"),
19
    ("sample", "Sample")                
20
)
21

  
22

  
23
    
24
class MatchAddress(models.Model):
25
    destination = models.CharField(max_length=255)
26
    class Meta:
27
        db_table = u'match_address'
28

  
29
class MatchPort(models.Model):
30
    port = models.CharField(max_length=24)
31
    class Meta:
32
        db_table = u'match_port'    
33

  
34
class MatchDscp(models.Model):
35
    dscp = models.CharField(max_length=24)
36
    class Meta:
37
        db_table = u'match_dscp'
38

  
39
class MatchFragmentType(models.Model):
40
    fragmenttype = models.CharField(max_length=20, choices=FRAGMENT_CODES)
41
    class Meta:
42
        db_table = u'match_fragment_type'
43
    
44
class MatchIcmpCode(models.Model):
45
    icmp_code = models.CharField(max_length=64)
46
    class Meta:
47
        db_table = u'match_icmp_code'    
48

  
49
class MatchIcmpType(models.Model):
50
    icmp_type = models.CharField(max_length=64)
51
    class Meta:
52
        db_table = u'match_icmp_type'    
53

  
54
class MatchPacketLength(models.Model):
55
    packet_length = models.IntegerField()
56
    class Meta:
57
        db_table = u'match_packet_length'    
58

  
59
class MatchProtocol(models.Model):
60
    protocol = models.CharField(max_length=64)
61
    class Meta:
62
        db_table = u'match_protocol'    
63

  
64
class MatchTcpFlag(models.Model):
65
    tcp_flag = models.CharField(max_length=255)
66
    class Meta:
67
        db_table = u'match_tcp_flag'    
68
    
69
class ThenAction(models.Model):
70
    action = models.CharField(max_length=60, choices=THEN_CHOICES)
71
    action_value = models.CharField(max_length=255, blank=True, null=True)
72
    class Meta:
73
        db_table = u'then_action'
74

  
75
class ThenStatement(models.Model):
76
    thenaction = models.ManyToManyField(ThenAction, blank=True, null=True)
77
    class Meta:
78
        db_table = u'then'    
79

  
80
class MatchStatement(models.Model):
81
    matchDestination = models.ForeignKey(MatchAddress, blank=True, null=True, related_name="matchDestination")
82
    matchDestinationPort = models.ManyToManyField(MatchPort, blank=True, null=True, related_name="matchDestinationPort")
83
    matchdscp = models.ManyToManyField(MatchDscp, blank=True, null=True)
84
    matchfragmenttype = models.ForeignKey(MatchFragmentType, blank=True, null=True)
85
    matchicmpcode = models.ForeignKey(MatchIcmpCode, blank=True, null=True)
86
    matchicmptype = models.ForeignKey(MatchIcmpType, blank=True, null=True)
87
    matchpacketlength = models.ForeignKey(MatchPacketLength, blank=True, null=True)
88
    matchport = models.ManyToManyField(MatchPort, blank=True, null=True)
89
    matchprotocol = models.ForeignKey(MatchProtocol, blank=True, null=True)
90
    matchSource = models.ManyToManyField(MatchAddress, blank=True, null=True, related_name="matchSource")
91
    matchSourcePort = models.ForeignKey(MatchPort, blank=True, null=True, related_name="matchSourcePort")
92
    matchTcpFlag = models.ForeignKey(MatchTcpFlag, blank=True, null=True)
93
    class Meta:
94
        db_table = u'match'
95

  
96
class Route(models.Model):
97
    name = models.CharField(max_length=128)
98
    applier = models.ForeignKey(User)
99
    match = models.ForeignKey(MatchStatement)
100
    then = models.ForeignKey(ThenStatement)
101
    filed = models.DateTimeField(auto_now_add=True)
102
    last_updated = models.DateTimeField(auto_now=True)
103
    expires = models.DateTimeField()
104
    class Meta:
105
        db_table = u'route'
b/flowspec/tests.py
1
"""
2
This file demonstrates two different styles of tests (one doctest and one
3
unittest). These will both pass when you run "manage.py test".
4

  
5
Replace these with more appropriate tests for your application.
6
"""
7

  
8
from django.test import TestCase
9

  
10
class SimpleTest(TestCase):
11
    def test_basic_addition(self):
12
        """
13
        Tests that 1 + 1 always equals 2.
14
        """
15
        self.failUnlessEqual(1 + 1, 2)
16

  
17
__test__ = {"doctest": """
18
Another way to test that 1 + 1 is equal to 2.
19

  
20
>>> 1 + 1 == 2
21
True
22
"""}
23

  
b/flowspec/views.py
1
# Create your views here.
b/manage.py
1
#!/usr/bin/python
2
from django.core.management import execute_manager
3
try:
4
    import settings # Assumed to be in the same directory.
5
except ImportError:
6
    import sys
7
    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
8
    sys.exit(1)
9

  
10
if __name__ == "__main__":
11
    execute_manager(settings)
b/settings.py.dist
1
# Django settings for flowspy project.
2

  
3
DEBUG = True
4
TEMPLATE_DEBUG = DEBUG
5

  
6
ADMINS = (
7
    # ('Your Name', 'your_email@domain.com'),
8
)
9

  
10
MANAGERS = ADMINS
11

  
12
DATABASES = {
13
    'default': {
14
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
15
        'NAME': 'flowspec',                      # Or path to database file if using sqlite3.
16
        'USER': '',                      # Not used with sqlite3.
17
        'PASSWORD': '',                  # Not used with sqlite3.
18
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
19
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
20
    }
21
}
22

  
23
# Local time zone for this installation. Choices can be found here:
24
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
25
# although not all choices may be available on all operating systems.
26
# On Unix systems, a value of None will cause Django to use the same
27
# timezone as the operating system.
28
# If running in a Windows environment this must be set to the same as your
29
# system time zone.
30
TIME_ZONE = 'America/Chicago'
31

  
32
# Language code for this installation. All choices can be found here:
33
# http://www.i18nguy.com/unicode/language-identifiers.html
34
LANGUAGE_CODE = 'en-us'
35

  
36
SITE_ID = 1
37

  
38
# If you set this to False, Django will make some optimizations so as not
39
# to load the internationalization machinery.
40
USE_I18N = True
41

  
42
# If you set this to False, Django will not format dates, numbers and
43
# calendars according to the current locale
44
USE_L10N = True
45

  
46
# Absolute path to the directory that holds media.
47
# Example: "/home/media/media.lawrence.com/"
48
MEDIA_ROOT = ''
49

  
50
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
51
# trailing slash if there is a path component (optional in other cases).
52
# Examples: "http://media.lawrence.com", "http://example.com/media/"
53
MEDIA_URL = ''
54

  
55
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
56
# trailing slash.
57
# Examples: "http://foo.com/media/", "/media/".
58
ADMIN_MEDIA_PREFIX = '/media/'
59

  
60
# Make this unique, and don't share it with anybody.
61
SECRET_KEY = 'fju0e4zu-thi7qf@93voi5eeot21@a*e54)%89xe-7iorqcimk'
62

  
63
# List of callables that know how to import templates from various sources.
64
TEMPLATE_LOADERS = (
65
    'django.template.loaders.filesystem.Loader',
66
    'django.template.loaders.app_directories.Loader',
67
#     'django.template.loaders.eggs.Loader',
68
)
69

  
70
MIDDLEWARE_CLASSES = (
71
    'django.middleware.common.CommonMiddleware',
72
    'django.contrib.sessions.middleware.SessionMiddleware',
73
    'django.middleware.csrf.CsrfViewMiddleware',
74
    'django.contrib.auth.middleware.AuthenticationMiddleware',
75
    'django.contrib.messages.middleware.MessageMiddleware',
76
)
77

  
78
ROOT_URLCONF = 'flowspy.urls'
79

  
80
TEMPLATE_DIRS = (
81
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
82
    # Always use forward slashes, even on Windows.
83
    # Don't forget to use absolute paths, not relative paths.
84
)
85

  
86
INSTALLED_APPS = (
87
    'django.contrib.auth',
88
    'django.contrib.contenttypes',
89
    'django.contrib.sessions',
90
    'django.contrib.sites',
91
    'django.contrib.messages',
92
    'flowspec',
93
    'south',
94
    # Uncomment the next line to enable the admin:
95
    # 'django.contrib.admin',
96
    # Uncomment the next line to enable admin documentation:
97
    # 'django.contrib.admindocs',
98
)
b/urls.py
1
from django.conf.urls.defaults import *
2

  
3
# Uncomment the next two lines to enable the admin:
4
# from django.contrib import admin
5
# admin.autodiscover()
6

  
7
urlpatterns = patterns('',
8
    # Example:
9
    # (r'^flowspy/', include('flowspy.foo.urls')),
10

  
11
    # Uncomment the admin/doc line below to enable admin documentation:
12
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
13

  
14
    # Uncomment the next line to enable the admin:
15
    # (r'^admin/', include(admin.site.urls)),
16
)

Also available in: Unified diff