# Generated by Django 2.1.7 on 2019-03-30 20:28

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Image',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False)),
                ('access_id', models.CharField(max_length=50)),
                ('name', models.CharField(max_length=50)),
                ('hostname', models.CharField(default='packone', max_length=50)),
                ('_remedy_script', models.TextField(default='', max_length=5120)),
                ('public', models.BooleanField(default=False)),
                ('enabled', models.BooleanField(default=True)),
                ('remark', models.CharField(blank=True, max_length=100, null=True)),
                ('modified_time', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='Instance',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(editable=False, null=True)),
                ('hostname', models.CharField(blank=True, max_length=50, null=True)),
                ('ipv4', models.GenericIPAddressField(blank=True, editable=False, null=True, protocol='IPv4')),
                ('ipv6', models.GenericIPAddressField(blank=True, editable=False, null=True, protocol='IPv6')),
                ('remedy_script_todo', models.TextField(default='', max_length=5120)),
                ('monitoring', models.BooleanField(default=False, editable=False)),
                ('remark', models.CharField(blank=True, max_length=2000, null=True)),
                ('created_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('status', models.PositiveIntegerField(choices=[(0, 'null'), (1, 'active'), (2, 'block'), (3, 'suspend'), (4, 'shutdown'), (5, 'poweroff'), (6, 'breakdown'), (7, 'pause'), (8, 'failure'), (9, 'host_lost'), (10, 'instance_lost'), (11, 'building')], default=11, editable=False)),
                ('deleting', models.BooleanField(default=False, editable=False)),
                ('image', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clouds.Image')),
            ],
        ),
        migrations.CreateModel(
            name='InstanceBlueprint',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('volume_capacity', models.IntegerField(default=0, validators=[django.core.validators.MinValueValidator(0)])),
                ('volume_mount_point', models.CharField(default='/data', max_length=100)),
                ('quantity', models.PositiveIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1)])),
                ('remedy_script', models.TextField(default='', max_length=5120)),
                ('public', models.BooleanField(default=False)),
                ('enabled', models.BooleanField(default=True)),
                ('remark', models.CharField(blank=True, max_length=100, null=True)),
                ('modified_time', models.DateTimeField(auto_now=True)),
                ('image', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='instance_blueprints', to='clouds.Image')),
            ],
            options={
                'verbose_name': 'blueprints',
            },
        ),
        migrations.CreateModel(
            name='InstanceOperation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('operation', models.CharField(choices=[('start', 'start'), ('reboot', 'reboot'), ('shutdown', 'shutdown'), ('poweroff', 'poweroff'), ('remedy', 'remedy')], default='start', max_length=50)),
                ('batch_uuid', models.UUIDField(editable=False, null=True)),
                ('script', models.TextField(blank=True, max_length=5120, null=True)),
                ('log', models.TextField(blank=True, max_length=51200, null=True)),
                ('created_time', models.DateTimeField(auto_now_add=True, null=True)),
                ('status', models.CharField(choices=[('success', 'success'), ('failed', 'failed'), ('running', 'running'), ('waiting', 'waiting')], default='running', editable=False, max_length=50)),
                ('completed_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='clouds.Instance')),
            ],
            options={
                'verbose_name': 'operations',
            },
        ),
        migrations.CreateModel(
            name='InstanceTemplate',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False)),
                ('access_id', models.CharField(max_length=50, unique=True)),
                ('name', models.CharField(max_length=50)),
                ('vcpu', models.PositiveIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1)])),
                ('mem', models.PositiveIntegerField(default=512, validators=[django.core.validators.MinValueValidator(256)])),
                ('remedy_script', models.TextField(blank=True, max_length=5120, null=True)),
                ('enabled', models.BooleanField(default=True)),
                ('remark', models.CharField(blank=True, max_length=100, null=True)),
                ('modified_time', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='Location',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False)),
                ('name', models.CharField(max_length=50, unique=True)),
                ('platform', models.CharField(max_length=50)),
                ('_platform_credential', models.TextField(blank=True, max_length=5120, null=True)),
                ('_instance_credential', models.TextField(blank=True, max_length=2048, null=True)),
                ('public', models.BooleanField(default=False)),
                ('enabled', models.BooleanField(default=True)),
                ('remark', models.CharField(blank=True, max_length=100, null=True)),
                ('modified_time', models.DateTimeField(auto_now=True)),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Mount',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('dev', models.CharField(editable=False, max_length=100, null=True)),
                ('point', models.CharField(default='/data', max_length=200)),
                ('created_time', models.DateTimeField(auto_now_add=True, null=True)),
                ('completed_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('deleting', models.BooleanField(default=False, editable=False)),
                ('instance', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clouds.Instance')),
            ],
            options={
                'default_permissions': ('add', 'delete', 'view'),
            },
        ),
        migrations.CreateModel(
            name='Volume',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(editable=False, null=True)),
                ('capacity', models.IntegerField()),
                ('remark', models.CharField(blank=True, max_length=2000, null=True)),
                ('created_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('status', models.PositiveIntegerField(choices=[(0, 'null'), (1, 'available'), (2, 'mounted'), (3, 'building')], default=3, editable=False)),
                ('deleting', models.BooleanField(default=False, editable=False)),
                ('location', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clouds.Location')),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.AddField(
            model_name='mount',
            name='volume',
            field=models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='clouds.Volume'),
        ),
        migrations.AddField(
            model_name='instancetemplate',
            name='location',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clouds.Location'),
        ),
        migrations.AddField(
            model_name='instanceblueprint',
            name='location',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clouds.Location'),
        ),
        migrations.AddField(
            model_name='instanceblueprint',
            name='owner',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='instanceblueprint',
            name='template',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clouds.InstanceTemplate'),
        ),
        migrations.AddField(
            model_name='instance',
            name='location',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clouds.Location'),
        ),
        migrations.AddField(
            model_name='instance',
            name='owner',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='instance',
            name='template',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clouds.InstanceTemplate'),
        ),
        migrations.AddField(
            model_name='image',
            name='location',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clouds.Location'),
        ),
        migrations.AddField(
            model_name='image',
            name='owner',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='image',
            name='parent',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='clouds.Image'),
        ),
        migrations.AlterUniqueTogether(
            name='mount',
            unique_together={('instance', 'point')},
        ),
        migrations.AlterUniqueTogether(
            name='instancetemplate',
            unique_together={('location', 'name')},
        ),
        migrations.AlterUniqueTogether(
            name='image',
            unique_together={('location', 'name')},
        ),
    ]
