# Generated by Django 2.1.7 on 2019-04-02 02:21

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 = [
        ('clouds', '0004_auto_20190402_0217'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Cluster',
            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)),
                ('current_step', models.PositiveIntegerField(default=0, validators=[django.core.validators.MinValueValidator(0)])),
                ('remedy_script_todo', models.TextField(blank=True, default='', max_length=5120)),
                ('public', models.BooleanField(default=False)),
                ('remark', models.CharField(blank=True, max_length=2000, null=True)),
                ('created_time', models.DateTimeField(auto_now_add=True)),
                ('built_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)),
            ],
        ),
        migrations.CreateModel(
            name='ClusterOperation',
            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)),
                ('operation', models.CharField(choices=[('start', 'start'), ('reboot', 'reboot'), ('shutdown', 'shutdown'), ('poweroff', 'poweroff'), ('remedy', 'remedy')], default='start', max_length=50)),
                ('created_time', models.DateTimeField(auto_now_add=True)),
                ('status', models.CharField(choices=[('success', 'success'), ('failed', 'failed'), ('running', 'running'), ('waiting', 'waiting')], default='running', editable=False, max_length=50)),
                ('started_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('completed_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='engines.Cluster')),
            ],
            options={
                'verbose_name': 'operations',
            },
        ),
        migrations.CreateModel(
            name='Component',
            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)),
                ('type', models.CharField(choices=[('master', 'master'), ('slave', 'slave'), ('client', 'client')], max_length=50)),
                ('endpoint', models.CharField(max_length=200)),
                ('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)),
                ('images', models.ManyToManyField(to='clouds.Image')),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Engine',
            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)),
                ('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)),
                ('components', models.ManyToManyField(to='engines.Component')),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Scale',
            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)),
                ('auto', models.BooleanField(default=False)),
                ('hosts', models.TextField(blank=True, max_length=5120, null=True)),
                ('remedy_script', models.TextField(blank=True, max_length=5120, 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)),
            ],
        ),
        migrations.CreateModel(
            name='ScaleBlueprint',
            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)),
                ('remedy_script', models.TextField(blank=True, max_length=5120, 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)),
                ('instance_blueprints', models.ManyToManyField(to='clouds.InstanceBlueprint')),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'blueprint',
            },
        ),
        migrations.AddField(
            model_name='scale',
            name='init_blueprint',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='initialized_scales', to='engines.ScaleBlueprint'),
        ),
        migrations.AddField(
            model_name='scale',
            name='owner',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='scale',
            name='step_blueprint',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='steped_scales', to='engines.ScaleBlueprint'),
        ),
        migrations.AddField(
            model_name='cluster',
            name='engines',
            field=models.ManyToManyField(to='engines.Engine'),
        ),
        migrations.AddField(
            model_name='cluster',
            name='instances',
            field=models.ManyToManyField(to='clouds.Instance'),
        ),
        migrations.AddField(
            model_name='cluster',
            name='owner',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='cluster',
            name='scale',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='engines.Scale'),
        ),
        migrations.AlterUniqueTogether(
            name='scaleblueprint',
            unique_together={('name', 'owner')},
        ),
        migrations.AlterUniqueTogether(
            name='engine',
            unique_together={('name', 'owner')},
        ),
        migrations.AlterUniqueTogether(
            name='component',
            unique_together={('name', 'owner')},
        ),
        migrations.AlterUniqueTogether(
            name='cluster',
            unique_together={('name', 'owner')},
        ),
    ]
