Revision 06ffd11f

b/snf-cyclades-app/synnefo/db/migrations/0081_auto__del_floatingip__del_field_networkinterface_ipv6__del_field_netwo.py
1
# -*- coding: 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

  
8
class Migration(SchemaMigration):
9

  
10
    def forwards(self, orm):
11
        # Deleting model 'FloatingIP'
12
        db.delete_table('db_floatingip')
13

  
14
        # Deleting field 'NetworkInterface.ipv6'
15
        db.delete_column('db_networkinterface', 'ipv6')
16

  
17
        # Deleting field 'NetworkInterface.ipv4'
18
        db.delete_column('db_networkinterface', 'ipv4')
19

  
20

  
21
    def backwards(self, orm):
22
        # Adding model 'FloatingIP'
23
        db.create_table('db_floatingip', (
24
            ('machine', self.gf('django.db.models.fields.related.ForeignKey')(related_name='floating_ips', null=True, to=orm['db.VirtualMachine'])),
25
            ('ipv4', self.gf('django.db.models.fields.IPAddressField')(max_length=15, unique=True, db_index=True)),
26
            ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
27
            ('deleted', self.gf('django.db.models.fields.BooleanField')(default=False)),
28
            ('serial', self.gf('django.db.models.fields.related.ForeignKey')(related_name='floating_ips', null=True, on_delete=models.SET_NULL, to=orm['db.QuotaHolderSerial'])),
29
            ('userid', self.gf('django.db.models.fields.CharField')(max_length=128, db_index=True)),
30
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
31
            ('network', self.gf('django.db.models.fields.related.ForeignKey')(related_name='floating_ips', to=orm['db.Network'])),
32
        ))
33
        db.send_create_signal('db', ['FloatingIP'])
34

  
35
        # Adding field 'NetworkInterface.ipv6'
36
        db.add_column('db_networkinterface', 'ipv6',
37
                      self.gf('django.db.models.fields.CharField')(max_length=100, null=True),
38
                      keep_default=False)
39

  
40
        # Adding field 'NetworkInterface.ipv4'
41
        db.add_column('db_networkinterface', 'ipv4',
42
                      self.gf('django.db.models.fields.CharField')(max_length=15, null=True),
43
                      keep_default=False)
44

  
45

  
46
    models = {
47
        'db.backend': {
48
            'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'},
49
            'clustername': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}),
50
            'ctotal': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
51
            'dfree': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
52
            'disk_templates': ('synnefo.db.fields.SeparatedValuesField', [], {'null': 'True'}),
53
            'drained': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
54
            'dtotal': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
55
            'hash': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
56
            'hypervisor': ('django.db.models.fields.CharField', [], {'default': "'kvm'", 'max_length': '32'}),
57
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
58
            'index': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'unique': 'True'}),
59
            'mfree': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
60
            'mtotal': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
61
            'offline': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
62
            'password_hash': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
63
            'pinst_cnt': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
64
            'port': ('django.db.models.fields.PositiveIntegerField', [], {'default': '5080'}),
65
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
66
            'username': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'})
67
        },
68
        'db.backendnetwork': {
69
            'Meta': {'unique_together': "(('network', 'backend'),)", 'object_name': 'BackendNetwork'},
70
            'backend': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'networks'", 'on_delete': 'models.PROTECT', 'to': "orm['db.Backend']"}),
71
            'backendjobid': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
72
            'backendjobstatus': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
73
            'backendlogmsg': ('django.db.models.fields.TextField', [], {'null': 'True'}),
74
            'backendopcode': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
75
            'backendtime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(1, 1, 1, 0, 0)'}),
76
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
77
            'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
78
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
79
            'mac_prefix': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
80
            'network': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'backend_networks'", 'to': "orm['db.Network']"}),
81
            'operstate': ('django.db.models.fields.CharField', [], {'default': "'PENDING'", 'max_length': '30'}),
82
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
83
        },
84
        'db.bridgepooltable': {
85
            'Meta': {'object_name': 'BridgePoolTable'},
86
            'available_map': ('django.db.models.fields.TextField', [], {'default': "''"}),
87
            'base': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
88
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
89
            'offset': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
90
            'reserved_map': ('django.db.models.fields.TextField', [], {'default': "''"}),
91
            'size': ('django.db.models.fields.IntegerField', [], {})
92
        },
93
        'db.flavor': {
94
            'Meta': {'unique_together': "(('cpu', 'ram', 'disk', 'disk_template'),)", 'object_name': 'Flavor'},
95
            'cpu': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
96
            'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
97
            'disk': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
98
            'disk_template': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
99
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
100
            'ram': ('django.db.models.fields.IntegerField', [], {'default': '0'})
101
        },
102
        'db.ipaddress': {
103
            'Meta': {'unique_together': "(('network', 'address'),)", 'object_name': 'IPAddress'},
104
            'address': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
105
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
106
            'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
107
            'floating_ip': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
108
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
109
            'network': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ips'", 'to': "orm['db.Network']"}),
110
            'nic': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ips'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['db.NetworkInterface']"}),
111
            'serial': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ips'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['db.QuotaHolderSerial']"}),
112
            'subnet': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ips'", 'to': "orm['db.Subnet']"}),
113
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
114
            'userid': ('django.db.models.fields.CharField', [], {'max_length': '128', 'db_index': 'True'})
115
        },
116
        'db.ippooltable': {
117
            'Meta': {'object_name': 'IPPoolTable'},
118
            'available_map': ('django.db.models.fields.TextField', [], {'default': "''"}),
119
            'base': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
120
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
121
            'offset': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
122
            'reserved_map': ('django.db.models.fields.TextField', [], {'default': "''"}),
123
            'size': ('django.db.models.fields.IntegerField', [], {}),
124
            'subnet': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ip_pools'", 'null': 'True', 'to': "orm['db.Subnet']"})
125
        },
126
        'db.macprefixpooltable': {
127
            'Meta': {'object_name': 'MacPrefixPoolTable'},
128
            'available_map': ('django.db.models.fields.TextField', [], {'default': "''"}),
129
            'base': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
130
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
131
            'offset': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
132
            'reserved_map': ('django.db.models.fields.TextField', [], {'default': "''"}),
133
            'size': ('django.db.models.fields.IntegerField', [], {})
134
        },
135
        'db.network': {
136
            'Meta': {'object_name': 'Network'},
137
            'action': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '32', 'null': 'True'}),
138
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
139
            'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
140
            'drained': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
141
            'external_router': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
142
            'flavor': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
143
            'floating_ip_pool': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
144
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
145
            'link': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
146
            'mac_prefix': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
147
            'machines': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['db.VirtualMachine']", 'through': "orm['db.NetworkInterface']", 'symmetrical': 'False'}),
148
            'mode': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True'}),
149
            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
150
            'public': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
151
            'serial': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'network'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['db.QuotaHolderSerial']"}),
152
            'state': ('django.db.models.fields.CharField', [], {'default': "'PENDING'", 'max_length': '32'}),
153
            'tags': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
154
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
155
            'userid': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'db_index': 'True'})
156
        },
157
        'db.networkinterface': {
158
            'Meta': {'object_name': 'NetworkInterface'},
159
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
160
            'device_owner': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
161
            'dirty': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
162
            'firewall_profile': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
163
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
164
            'index': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
165
            'mac': ('django.db.models.fields.CharField', [], {'max_length': '32', 'unique': 'True', 'null': 'True'}),
166
            'machine': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nics'", 'to': "orm['db.VirtualMachine']"}),
167
            'name': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
168
            'network': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nics'", 'to': "orm['db.Network']"}),
169
            'security_groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['db.SecurityGroup']", 'null': 'True', 'symmetrical': 'False'}),
170
            'state': ('django.db.models.fields.CharField', [], {'default': "'ACTIVE'", 'max_length': '32'}),
171
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
172
            'userid': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'db_index': 'True'})
173
        },
174
        'db.quotaholderserial': {
175
            'Meta': {'ordering': "['serial']", 'object_name': 'QuotaHolderSerial'},
176
            'accept': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
177
            'pending': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}),
178
            'resolved': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
179
            'serial': ('django.db.models.fields.BigIntegerField', [], {'primary_key': 'True', 'db_index': 'True'})
180
        },
181
        'db.securitygroup': {
182
            'Meta': {'object_name': 'SecurityGroup'},
183
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
184
            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
185
        },
186
        'db.subnet': {
187
            'Meta': {'object_name': 'Subnet'},
188
            'cidr': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
189
            'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
190
            'dhcp': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
191
            'dns_nameservers': ('synnefo.db.fields.SeparatedValuesField', [], {'null': 'True'}),
192
            'gateway': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
193
            'host_routes': ('synnefo.db.fields.SeparatedValuesField', [], {'null': 'True'}),
194
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
195
            'ipversion': ('django.db.models.fields.IntegerField', [], {'default': '4'}),
196
            'name': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
197
            'network': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'subnets'", 'to': "orm['db.Network']"})
198
        },
199
        'db.virtualmachine': {
200
            'Meta': {'object_name': 'VirtualMachine'},
201
            'action': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '30', 'null': 'True'}),
202
            'backend': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'virtual_machines'", 'null': 'True', 'on_delete': 'models.PROTECT', 'to': "orm['db.Backend']"}),
203
            'backend_hash': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
204
            'backendjobid': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
205
            'backendjobstatus': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
206
            'backendlogmsg': ('django.db.models.fields.TextField', [], {'null': 'True'}),
207
            'backendopcode': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
208
            'backendtime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(1, 1, 1, 0, 0)'}),
209
            'buildpercentage': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
210
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
211
            'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
212
            'flavor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['db.Flavor']", 'on_delete': 'models.PROTECT'}),
213
            'hostid': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
214
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
215
            'imageid': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
216
            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
217
            'operstate': ('django.db.models.fields.CharField', [], {'default': "'BUILD'", 'max_length': '30'}),
218
            'serial': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'virtual_machine'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['db.QuotaHolderSerial']"}),
219
            'suspended': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
220
            'task': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
221
            'task_job_id': ('django.db.models.fields.BigIntegerField', [], {'null': 'True'}),
222
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
223
            'userid': ('django.db.models.fields.CharField', [], {'max_length': '100', 'db_index': 'True'})
224
        },
225
        'db.virtualmachinediagnostic': {
226
            'Meta': {'ordering': "['-created']", 'object_name': 'VirtualMachineDiagnostic'},
227
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
228
            'details': ('django.db.models.fields.TextField', [], {'null': 'True'}),
229
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
230
            'level': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
231
            'machine': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'diagnostics'", 'to': "orm['db.VirtualMachine']"}),
232
            'message': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
233
            'source': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
234
            'source_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True'})
235
        },
236
        'db.virtualmachinemetadata': {
237
            'Meta': {'unique_together': "(('meta_key', 'vm'),)", 'object_name': 'VirtualMachineMetadata'},
238
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
239
            'meta_key': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
240
            'meta_value': ('django.db.models.fields.CharField', [], {'max_length': '500'}),
241
            'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"})
242
        }
243
    }
244

  
245
    complete_apps = ['db']
b/snf-cyclades-app/synnefo/db/models.py
727 727
    updated = models.DateTimeField(auto_now=True)
728 728
    index = models.IntegerField(null=True)
729 729
    mac = models.CharField(max_length=32, null=True, unique=True)
730
    ipv4 = models.CharField(max_length=15, null=True)
731
    ipv6 = models.CharField(max_length=100, null=True)
732 730
    firewall_profile = models.CharField(choices=FIREWALL_PROFILES,
733 731
                                        max_length=30, null=True)
734 732
    security_groups = models.ManyToManyField("SecurityGroup", null=True)
......
750 748
    name = models.CharField('group name', max_length=128)
751 749

  
752 750

  
753
class FloatingIP(models.Model):
754
    userid = models.CharField("UUID of the owner", max_length=128,
755
                              null=False, db_index=True)
756
    ipv4 = models.IPAddressField(null=False, unique=True, db_index=True)
757
    network = models.ForeignKey(Network, related_name="floating_ips",
758
                                null=False, on_delete=models.CASCADE)
759
    machine = models.ForeignKey(VirtualMachine, related_name="floating_ips",
760
                                null=True, on_delete=models.SET_NULL)
761
    created = models.DateTimeField(auto_now_add=True)
762
    deleted = models.BooleanField(default=False, null=False)
763
    serial = models.ForeignKey(QuotaHolderSerial,
764
                               related_name="floating_ips", null=True,
765
                               on_delete=models.SET_NULL)
766

  
767
    def __unicode__(self):
768
        return "<FIP: %s@%s>" % (self.ipv4, self.network.id)
769

  
770
    def in_use(self):
771
        if self.machine is None:
772
            return False
773
        else:
774
            return (not self.machine.deleted)
775

  
776

  
777 751
class PoolTable(models.Model):
778 752
    available_map = models.TextField(default="", null=False)
779 753
    reserved_map = models.TextField(default="", null=False)

Also available in: Unified diff