1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# Generated by Django 2.2 on 2020-02-18 15:36
from django.db import migrations, models
def set_resource_id(apps, schema_editor):
for cls in ["HardwareConfig", "NetworkConfig", "SnapshotConfig"]:
model = apps.get_model('api', cls)
for m in model.objects.all():
m.resource_id = m.host.labid
m.save()
class Migration(migrations.Migration):
dependencies = [
('api', '0010_auto_20191219_2004'),
# ('resource_inventory', '0013_auto_20200218_1536')
]
operations = [
migrations.AddField(
model_name='hosthardwarerelation',
name='resource_id',
field=models.CharField(default='default_id', max_length=200),
),
migrations.AddField(
model_name='hostnetworkrelation',
name='resource_id',
field=models.CharField(default='default_id', max_length=200),
),
migrations.AddField(
model_name='snapshotconfig',
name='resource_id',
field=models.CharField(default='default_id', max_length=200),
),
migrations.RunPython(set_resource_id),
migrations.RemoveField(
model_name='hosthardwarerelation',
name='host',
),
migrations.RemoveField(
model_name='hostnetworkrelation',
name='host',
),
migrations.RemoveField(
model_name='snapshotconfig',
name='host',
),
migrations.RemoveField(
model_name='opnfvapiconfig',
name='roles',
),
]
|