Commit 95577dc2 authored by Leonidas Poulopoulos's avatar Leonidas Poulopoulos

Add fragment type model

 * Add fragment type in models
 * Add reconciliation checks for fragment type
 * Generate south migrations
 * Minor fixes in additional checks for m2m fields
parent 7a1b3371
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'FragmentType'
db.create_table('flowspec_fragmenttype', (
('fragmenttype', self.gf('django.db.models.fields.CharField')(max_length=20, null=True, blank=True)),
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
))
db.send_create_signal('flowspec', ['FragmentType'])
def backwards(self, orm):
# Deleting model 'FragmentType'
db.delete_table('flowspec_fragmenttype')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
},
'contenttypes.contenttype': {
'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'flowspec.fragmenttype': {
'Meta': {'object_name': 'FragmentType'},
'fragmenttype': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'flowspec.matchdscp': {
'Meta': {'object_name': 'MatchDscp', 'db_table': "u'match_dscp'"},
'dscp': ('django.db.models.fields.CharField', [], {'max_length': '24'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'flowspec.matchport': {
'Meta': {'object_name': 'MatchPort', 'db_table': "u'match_port'"},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'port': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '24'})
},
'flowspec.matchprotocol': {
'Meta': {'object_name': 'MatchProtocol', 'db_table': "u'match_protocol'"},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'protocol': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '24'})
},
'flowspec.route': {
'Meta': {'object_name': 'Route', 'db_table': "u'route'"},
'applier': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
'comments': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'destination': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'destinationport': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchDestinationPort'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']"}),
'dscp': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['flowspec.MatchDscp']", 'null': 'True', 'blank': 'True'}),
'expires': ('django.db.models.fields.DateField', [], {'default': 'datetime.date(2013, 4, 8)'}),
'filed': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'fragmenttype': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}),
'icmpcode': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
'icmptype': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.SlugField', [], {'max_length': '128', 'db_index': 'True'}),
'packetlength': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'port': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchPort'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']"}),
'protocol': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['flowspec.MatchProtocol']", 'null': 'True', 'blank': 'True'}),
'response': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
'source': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'sourceport': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchSourcePort'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']"}),
'status': ('django.db.models.fields.CharField', [], {'default': "'PENDING'", 'max_length': '20', 'null': 'True', 'blank': 'True'}),
'tcpflag': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
'then': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['flowspec.ThenAction']", 'symmetrical': 'False'})
},
'flowspec.thenaction': {
'Meta': {'unique_together': "(('action', 'action_value'),)", 'object_name': 'ThenAction', 'db_table': "u'then_action'"},
'action': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'action_value': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
}
}
complete_apps = ['flowspec']
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Changing field 'FragmentType.fragmenttype'
db.alter_column('flowspec_fragmenttype', 'fragmenttype', self.gf('django.db.models.fields.CharField')(max_length=20))
def backwards(self, orm):
# Changing field 'FragmentType.fragmenttype'
db.alter_column('flowspec_fragmenttype', 'fragmenttype', self.gf('django.db.models.fields.CharField')(max_length=20, null=True, blank=True))
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
},
'contenttypes.contenttype': {
'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'flowspec.fragmenttype': {
'Meta': {'object_name': 'FragmentType'},
'fragmenttype': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'flowspec.matchdscp': {
'Meta': {'object_name': 'MatchDscp', 'db_table': "u'match_dscp'"},
'dscp': ('django.db.models.fields.CharField', [], {'max_length': '24'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'flowspec.matchport': {
'Meta': {'object_name': 'MatchPort', 'db_table': "u'match_port'"},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'port': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '24'})
},
'flowspec.matchprotocol': {
'Meta': {'object_name': 'MatchProtocol', 'db_table': "u'match_protocol'"},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'protocol': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '24'})
},
'flowspec.route': {
'Meta': {'object_name': 'Route', 'db_table': "u'route'"},
'applier': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
'comments': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'destination': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'destinationport': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchDestinationPort'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']"}),
'dscp': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['flowspec.MatchDscp']", 'null': 'True', 'blank': 'True'}),
'expires': ('django.db.models.fields.DateField', [], {'default': 'datetime.date(2013, 4, 8)'}),
'filed': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'fragmenttype': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}),
'icmpcode': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
'icmptype': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.SlugField', [], {'max_length': '128', 'db_index': 'True'}),
'packetlength': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'port': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchPort'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']"}),
'protocol': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['flowspec.MatchProtocol']", 'null': 'True', 'blank': 'True'}),
'response': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
'source': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'sourceport': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchSourcePort'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']"}),
'status': ('django.db.models.fields.CharField', [], {'default': "'PENDING'", 'max_length': '20', 'null': 'True', 'blank': 'True'}),
'tcpflag': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
'then': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['flowspec.ThenAction']", 'symmetrical': 'False'})
},
'flowspec.thenaction': {
'Meta': {'unique_together': "(('action', 'action_value'),)", 'object_name': 'ThenAction', 'db_table': "u'then_action'"},
'action': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'action_value': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
}
}
complete_apps = ['flowspec']
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Deleting field 'Route.fragmenttype'
db.delete_column(u'route', 'fragmenttype')
# Adding M2M table for field fragmenttype on 'Route'
db.create_table(u'route_fragmenttype', (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('route', models.ForeignKey(orm['flowspec.route'], null=False)),
('fragmenttype', models.ForeignKey(orm['flowspec.fragmenttype'], null=False))
))
db.create_unique(u'route_fragmenttype', ['route_id', 'fragmenttype_id'])
def backwards(self, orm):
# Adding field 'Route.fragmenttype'
db.add_column(u'route', 'fragmenttype', self.gf('django.db.models.fields.CharField')(max_length=20, null=True, blank=True), keep_default=False)
# Removing M2M table for field fragmenttype on 'Route'
db.delete_table('route_fragmenttype')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
},
'contenttypes.contenttype': {
'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'flowspec.fragmenttype': {
'Meta': {'object_name': 'FragmentType'},
'fragmenttype': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'flowspec.matchdscp': {
'Meta': {'object_name': 'MatchDscp', 'db_table': "u'match_dscp'"},
'dscp': ('django.db.models.fields.CharField', [], {'max_length': '24'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'flowspec.matchport': {
'Meta': {'object_name': 'MatchPort', 'db_table': "u'match_port'"},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'port': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '24'})
},
'flowspec.matchprotocol': {
'Meta': {'object_name': 'MatchProtocol', 'db_table': "u'match_protocol'"},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'protocol': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '24'})
},
'flowspec.route': {
'Meta': {'object_name': 'Route', 'db_table': "u'route'"},
'applier': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
'comments': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'destination': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'destinationport': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchDestinationPort'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']"}),
'dscp': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['flowspec.MatchDscp']", 'null': 'True', 'blank': 'True'}),
'expires': ('django.db.models.fields.DateField', [], {'default': 'datetime.date(2013, 4, 8)'}),
'filed': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'fragmenttype': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['flowspec.FragmentType']", 'null': 'True', 'blank': 'True'}),
'icmpcode': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
'icmptype': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.SlugField', [], {'max_length': '128', 'db_index': 'True'}),
'packetlength': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'port': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchPort'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']"}),
'protocol': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['flowspec.MatchProtocol']", 'null': 'True', 'blank': 'True'}),
'response': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
'source': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'sourceport': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'matchSourcePort'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['flowspec.MatchPort']"}),
'status': ('django.db.models.fields.CharField', [], {'default': "'PENDING'", 'max_length': '20', 'null': 'True', 'blank': 'True'}),
'tcpflag': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
'then': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['flowspec.ThenAction']", 'symmetrical': 'False'})
},
'flowspec.thenaction': {
'Meta': {'unique_together': "(('action', 'action_value'),)", 'object_name': 'ThenAction', 'db_table': "u'then_action'"},
'action': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'action_value': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
}
}
complete_apps = ['flowspec']
......@@ -111,7 +111,13 @@ class MatchProtocol(models.Model):
class Meta:
db_table = u'match_protocol'
class FragmentType(models.Model):
fragmenttype = models.CharField(max_length=20, choices=FRAGMENT_CODES, verbose_name="Fragment Type")
def __unicode__(self):
return "%s" %(self.fragmenttype)
class ThenAction(models.Model):
action = models.CharField(max_length=60, choices=THEN_CHOICES, verbose_name="Action")
action_value = models.CharField(max_length=255, blank=True, null=True, verbose_name="Action Value")
......@@ -132,7 +138,7 @@ class Route(models.Model):
destinationport = models.ManyToManyField(MatchPort, blank=True, null=True, related_name="matchDestinationPort", verbose_name=_("Destination Port"))
port = models.ManyToManyField(MatchPort, blank=True, null=True, related_name="matchPort", verbose_name=_("Port"))
dscp = models.ManyToManyField(MatchDscp, blank=True, null=True, verbose_name="DSCP")
fragmenttype = models.CharField(max_length=20, choices=FRAGMENT_CODES, blank=True, null=True, verbose_name="Fragment Type")
fragmenttype = models.ManyToManyField(FragmentType, blank=True, null=True, verbose_name="Fragment Type")
icmpcode = models.CharField(max_length=32, blank=True, null=True, verbose_name="ICMP Code")
icmptype = models.CharField(max_length=32, blank=True, null=True, verbose_name="ICMP Type")
packetlength = models.IntegerField(blank=True, null=True, verbose_name="Packet Length")
......@@ -251,10 +257,14 @@ class Route(models.Model):
logger.info('Source fields do not match')
except:
pass
try:
assert(self.fragmenttype)
assert(devicematch['fragment'][0])
if self.fragmenttype == devicematch['fragment'][0]:
assert(self.fragmenttype.all())
assert(devicematch['fragment'])
devitems = devicematch['fragment']
dbitems = ["%s"%i for i in self.fragmenttype.all()]
intersect = list(set(devitems).intersection(set(dbitems)))
if ((len(intersect) == len(dbitems)) and (len(intersect) == len(devitems))):
found = found and True
logger.info('Found a matching fragment type')
else:
......@@ -262,6 +272,79 @@ class Route(models.Model):
logger.info('Fragment type fields do not match')
except:
pass
try:
assert(self.port.all())
assert(devicematch['port'])
devitems = devicematch['port']
dbitems = ["%s"%i for i in self.port.all()]
intersect = list(set(devitems).intersection(set(dbitems)))
if ((len(intersect) == len(dbitems)) and (len(intersect) == len(devitems))):
found = found and True
logger.info('Found a matching port type')
else:
found = False
logger.info('Port type fields do not match')
except:
pass
try:
assert(self.protocol.all())
assert(devicematch['protocol'])
devitems = devicematch['protocol']
dbitems = ["%s"%i for i in self.protocol.all()]
intersect = list(set(devitems).intersection(set(dbitems)))
if ((len(intersect) == len(dbitems)) and (len(intersect) == len(devitems))):
found = found and True
logger.info('Found a matching protocol type')
else:
found = False
logger.info('Protocol type fields do not match')
except:
pass
try:
assert(self.destinationport.all())
assert(devicematch['destination-port'])
devitems = devicematch['destination-port']
dbitems = ["%s"%i for i in self.destinationport.all()]
intersect = list(set(devitems).intersection(set(dbitems)))
if ((len(intersect) == len(dbitems)) and (len(intersect) == len(devitems))):
found = found and True
logger.info('Found a matching destination port type')
else:
found = False
logger.info('Destination port type fields do not match')
except:
pass
try:
assert(self.sourceport.all())
assert(devicematch['source-port'])
devitems = devicematch['source-port']
dbitems = ["%s"%i for i in self.sourceport.all()]
intersect = list(set(devitems).intersection(set(dbitems)))
if ((len(intersect) == len(dbitems)) and (len(intersect) == len(devitems))):
found = found and True
logger.info('Found a matching source port type')
else:
found = False
logger.info('Source port type fields do not match')
except:
pass
# try:
# assert(self.fragmenttype)
# assert(devicematch['fragment'][0])
# if self.fragmenttype == devicematch['fragment'][0]:
# found = found and True
# logger.info('Found a matching fragment type')
# else:
# found = False
# logger.info('Fragment type fields do not match')
# except:
# pass
try:
assert(self.icmpcode)
assert(devicematch['icmp-code'][0])
......@@ -310,8 +393,10 @@ class Route(models.Model):
ret = ''
if self.destination:
ret = '%s Dst Addr:<strong>%s</strong> <br/>' %(ret, self.destination)
if self.fragmenttype:
ret = "%s Fragment Type:<strong>%s</strong><br/>" %(ret, self.fragmenttype)
if self.fragmenttype.all():
ret = ret + "Fragment Types:<strong>%s</strong> <br/>" %(','.join(["%s"%i for i in self.fragmenttype.all()]))
# for fragment in self.fragmenttype.all():
# ret = ret + "Fragment Types:<strong>%s</strong> <br/>" %(fragment)
if self.icmpcode:
ret = "%s ICMP code:<strong>%s</strong><br/>" %(ret, self.icmpcode)
if self.icmptype:
......@@ -322,18 +407,22 @@ class Route(models.Model):
ret = "%s Src Addr:<strong>%s</strong> <br/>" %(ret, self.source)
if self.tcpflag:
ret = "%s TCP flag:<strong>%s</strong><br/>" %(ret, self.tcpflag)
if self.port:
for port in self.port.all():
ret = ret + "Port:<strong>%s</strong> <br/>" %(port)
if self.protocol:
for protocol in self.protocol.all():
ret = ret + "Protocol:<strong>%s</strong> <br/>" %(protocol)
if self.destinationport:
for port in self.destinationport.all():
ret = ret + "Dst Port:<strong>%s</strong> <br/>" %(port)
if self.sourceport:
for port in self.sourceport.all():
ret = ret +"Src Port:<strong>%s</strong> <br/>" %(port)
if self.port.all():
ret = ret + "Ports:<strong>%s</strong> <br/>" %(','.join(["%s"%i for i in self.port.all()]))
# for port in self.port.all():
# ret = ret + "Port:<strong>%s</strong> <br/>" %(port)
if self.protocol.all():
ret = ret + "Protocols:<strong>%s</strong> <br/>" %(','.join(["%s"%i for i in self.protocol.all()]))
# for protocol in self.protocol.all():
# ret = ret + "Protocol:<strong>%s</strong> <br/>" %(protocol)
if self.destinationport.all():
ret = ret + "DstPorts:<strong>%s</strong> <br/>" %(','.join(["%s"%i for i in self.destinationport.all()]))
# for port in self.destinationport.all():
# ret = ret + "Dst Port:<strong>%s</strong> <br/>" %(port)
if self.sourceport.all():
ret = ret + "SrcPorts:<strong>%s</strong> <br/>" %(','.join(["%s"%i for i in self.sourceport.all()]))
# for port in self.sourceport.all():
# ret = ret +"Src Port:<strong>%s</strong> <br/>" %(port)
if self.dscp:
for dscp in self.dscp.all():
ret = ret + "%s Port:<strong>%s</strong> <br/>" %(ret, dscp)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment