Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / db / migrations / 0029_remove_user.py @ 9290cfab

History | View | Annotate | Download (10 kB)

1
# encoding: utf-8
2
import datetime
3
from south.db import db
4
from south.v2 import DataMigration
5
from django.db import models
6

    
7
class Migration(DataMigration):
8

    
9
    def forwards(self, orm):
10
        for image in orm.Image.objects.all():
11
            image.userid = str(image.owner.id) if image.owner else ''
12
            image.save()
13
        
14
        for vm in orm.VirtualMachine.objects.all():
15
            vm.userid = str(vm.owner.id) if vm.owner else ''
16
            vm.save()
17
        
18
        for network in orm.Network.objects.all():
19
            network.userid = str(network.owner.id) if network.owner else ''
20
            network.save()
21
    
22
    def backwards(self, orm):
23
        raise RuntimeError("Cannot reverse this migration.")
24

    
25
    models = {
26
        'db.flavor': {
27
            'Meta': {'unique_together': "(('cpu', 'ram', 'disk'),)", 'object_name': 'Flavor'},
28
            'cpu': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
29
            'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
30
            'disk': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
31
            'disk_template': ('django.db.models.fields.CharField', [], {'default': "'drbd'", 'max_length': '32'}),
32
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
33
            'ram': ('django.db.models.fields.IntegerField', [], {'default': '0'})
34
        },
35
        'db.image': {
36
            'Meta': {'object_name': 'Image'},
37
            'backend_id': ('django.db.models.fields.CharField', [], {'default': "'debian_base'", 'max_length': '50'}),
38
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
39
            'format': ('django.db.models.fields.CharField', [], {'default': "'dump'", 'max_length': '30'}),
40
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
41
            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
42
            'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['db.SynnefoUser']", 'null': 'True', 'blank': 'True'}),
43
            'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
44
            'sourcevm': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['db.VirtualMachine']", 'null': 'True'}),
45
            'state': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
46
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
47
            'userid': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '100'})
48
        },
49
        'db.imagemetadata': {
50
            'Meta': {'unique_together': "(('meta_key', 'image'),)", 'object_name': 'ImageMetadata'},
51
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
52
            'image': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.Image']"}),
53
            'meta_key': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
54
            'meta_value': ('django.db.models.fields.CharField', [], {'max_length': '500'})
55
        },
56
        'db.network': {
57
            'Meta': {'object_name': 'Network'},
58
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
59
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
60
            'link': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['db.NetworkLink']"}),
61
            'machines': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['db.VirtualMachine']", 'through': "orm['db.NetworkInterface']", 'symmetrical': 'False'}),
62
            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
63
            'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['db.SynnefoUser']", 'null': 'True'}),
64
            'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
65
            'state': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
66
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
67
            'userid': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '100'})
68
        },
69
        'db.networkinterface': {
70
            'Meta': {'object_name': 'NetworkInterface'},
71
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
72
            'firewall_profile': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
73
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
74
            'index': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
75
            'ipv4': ('django.db.models.fields.CharField', [], {'max_length': '15', 'null': 'True'}),
76
            'ipv6': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'}),
77
            'mac': ('django.db.models.fields.CharField', [], {'max_length': '17', 'null': 'True'}),
78
            'machine': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nics'", 'to': "orm['db.VirtualMachine']"}),
79
            'network': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nics'", 'to': "orm['db.Network']"}),
80
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
81
        },
82
        'db.networklink': {
83
            'Meta': {'object_name': 'NetworkLink'},
84
            'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
85
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
86
            'index': ('django.db.models.fields.IntegerField', [], {}),
87
            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
88
            'network': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'null': 'True', 'to': "orm['db.Network']"})
89
        },
90
        'db.synnefouser': {
91
            'Meta': {'object_name': 'SynnefoUser'},
92
            'auth_token': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
93
            'auth_token_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
94
            'auth_token_expires': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
95
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
96
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
97
            'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}),
98
            'realname': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}),
99
            'state': ('django.db.models.fields.CharField', [], {'default': "'ACTIVE'", 'max_length': '30'}),
100
            'tmp_auth_token': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
101
            'tmp_auth_token_expires': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
102
            'type': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
103
            'uniq': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
104
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
105
        },
106
        'db.virtualmachine': {
107
            'Meta': {'object_name': 'VirtualMachine'},
108
            'action': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
109
            'backendjobid': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
110
            'backendjobstatus': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
111
            'backendlogmsg': ('django.db.models.fields.TextField', [], {'null': 'True'}),
112
            'backendopcode': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
113
            'buildpercentage': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
114
            'charged': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 1, 23, 14, 49, 47, 844276)'}),
115
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
116
            'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
117
            'flavor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['db.Flavor']"}),
118
            'hostid': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
119
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
120
            'imageid': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
121
            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
122
            'operstate': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
123
            'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['db.SynnefoUser']"}),
124
            'suspended': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
125
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
126
            'userid': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '100'})
127
        },
128
        'db.virtualmachinemetadata': {
129
            'Meta': {'unique_together': "(('meta_key', 'vm'),)", 'object_name': 'VirtualMachineMetadata'},
130
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
131
            'meta_key': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
132
            'meta_value': ('django.db.models.fields.CharField', [], {'max_length': '500'}),
133
            'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"})
134
        }
135
    }
136

    
137
    complete_apps = ['db']