Revision 6a03d89f

b/snf-cyclades-app/synnefo/db/migrations/0090_auto__chg_field_ipaddress_subnet__chg_field_ipaddress_network__chg_fie.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

  
12
        # Changing field 'IPAddress.subnet'
13
        db.alter_column('db_ipaddress', 'subnet_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.PROTECT, to=orm['db.Subnet']))
14

  
15
        # Changing field 'IPAddress.network'
16
        db.alter_column('db_ipaddress', 'network_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.PROTECT, to=orm['db.Network']))
17

  
18
        # Changing field 'NetworkInterface.network'
19
        db.alter_column('db_networkinterface', 'network_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.PROTECT, to=orm['db.Network']))
20

  
21
        # Changing field 'NetworkInterface.machine'
22
        db.alter_column('db_networkinterface', 'machine_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, on_delete=models.PROTECT, to=orm['db.VirtualMachine']))
23

  
24
        # Changing field 'IPPoolTable.subnet'
25
        db.alter_column('db_ippooltable', 'subnet_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, on_delete=models.PROTECT, to=orm['db.Subnet']))
26

  
27
        # Changing field 'Subnet.network'
28
        db.alter_column('db_subnet', 'network_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.PROTECT, to=orm['db.Network']))
29

  
30
        # Changing field 'BackendNetwork.network'
31
        db.alter_column('db_backendnetwork', 'network_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.PROTECT, to=orm['db.Network']))
32

  
33
    def backwards(self, orm):
34

  
35
        # Changing field 'IPAddress.subnet'
36
        db.alter_column('db_ipaddress', 'subnet_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['db.Subnet']))
37

  
38
        # Changing field 'IPAddress.network'
39
        db.alter_column('db_ipaddress', 'network_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['db.Network']))
40

  
41
        # Changing field 'NetworkInterface.network'
42
        db.alter_column('db_networkinterface', 'network_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['db.Network']))
43

  
44
        # Changing field 'NetworkInterface.machine'
45
        db.alter_column('db_networkinterface', 'machine_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['db.VirtualMachine']))
46

  
47
        # Changing field 'IPPoolTable.subnet'
48
        db.alter_column('db_ippooltable', 'subnet_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['db.Subnet']))
49

  
50
        # Changing field 'Subnet.network'
51
        db.alter_column('db_subnet', 'network_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['db.Network']))
52

  
53
        # Changing field 'BackendNetwork.network'
54
        db.alter_column('db_backendnetwork', 'network_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['db.Network']))
55

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

  
264
    complete_apps = ['db']
b/snf-cyclades-app/synnefo/db/models.py
607 607
    SUBNET_NAME_LENGTH = 128
608 608

  
609 609
    network = models.ForeignKey('Network', null=False, db_index=True,
610
                                related_name="subnets")
610
                                related_name="subnets",
611
                                on_delete=models.PROTECT)
611 612
    name = models.CharField('Subnet Name', max_length=SUBNET_NAME_LENGTH,
612 613
                            null=True, default="")
613 614
    ipversion = models.IntegerField('IP Version', default=4, null=False)
......
664 665
    }
665 666

  
666 667
    network = models.ForeignKey(Network, related_name='backend_networks',
667
                                on_delete=models.CASCADE)
668
                                on_delete=models.PROTECT)
668 669
    backend = models.ForeignKey(Backend, related_name='networks',
669 670
                                on_delete=models.PROTECT)
670 671
    created = models.DateTimeField(auto_now_add=True)
......
708 709

  
709 710
class IPAddress(models.Model):
710 711
    subnet = models.ForeignKey("Subnet", related_name="ips", null=False,
711
                               on_delete=models.CASCADE)
712
                               on_delete=models.PROTECT)
712 713
    network = models.ForeignKey(Network, related_name="ips", null=False,
713
                                on_delete=models.CASCADE)
714
                                on_delete=models.PROTECT)
714 715
    nic = models.ForeignKey("NetworkInterface", related_name="ips", null=True,
715 716
                            on_delete=models.SET_NULL)
716 717
    userid = models.CharField("UUID of the owner", max_length=128, null=False,
......
800 801
                              max_length=NETWORK_IFACE_NAME_LENGTH,
801 802
                              null=False, db_index=True)
802 803
    machine = models.ForeignKey(VirtualMachine, related_name='nics',
803
                                on_delete=models.CASCADE, null=True)
804
                                on_delete=models.PROTECT, null=True)
804 805
    network = models.ForeignKey(Network, related_name='nics',
805
                                on_delete=models.CASCADE)
806
                                on_delete=models.PROTECT)
806 807
    created = models.DateTimeField(auto_now_add=True)
807 808
    updated = models.DateTimeField(auto_now=True)
808 809
    index = models.IntegerField(null=True)
......
890 891
    manager = pools.IPPool
891 892

  
892 893
    subnet = models.ForeignKey('Subnet', related_name="ip_pools",
894
                               on_delete=models.PROTECT,
893 895
                               db_index=True, null=True)
894 896

  
895 897
    def __unicode__(self):

Also available in: Unified diff