1
# -*- coding: utf-8 -*-
2
from __future__ import unicode_literals
4
from django.db import (
9
# Previous DI file types.
17
def remove_di_bootresourcefiles(apps, schema_editor):
18
BootResourceFile = apps.get_model("maasserver", "BootResourceFile")
19
for resource_file in BootResourceFile.objects.filter(
20
filetype__in=DI_FILE_TYPES):
21
# Delete the largefile and content before deleting the resource file
22
# so the post commit hooks are not called in the migration.
24
largefile = resource_file.largefile
25
except LargeFile.DoesNotExist:
27
if largefile is not None:
28
if largefile.content is not None:
29
largefile.content.unlink()
31
resource_file.delete()
34
class Migration(migrations.Migration):
37
('maasserver', '0043_dhcpsnippet'),
41
migrations.RunPython(remove_di_bootresourcefiles),
42
migrations.AlterField(
43
model_name='bootresourcefile',
45
field=models.CharField(max_length=20, default='root-tgz', choices=[('root-tgz', 'Root Image (tar.gz)'), ('root-dd', 'Root Compressed DD (dd -> tar.gz)'), ('root-image.gz', 'Compressed Root Image'), ('boot-kernel', 'Linux ISCSI Kernel'), ('boot-initrd', 'Initial ISCSI Ramdisk'), ('boot-dtb', 'ISCSI Device Tree Blob')], editable=False),