# Generated by Django 2.1.7 on 2019-04-15 01:19

import clouds.base.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('clouds', '0024_instance_remedy_script_todo'),
    ]

    operations = [
        migrations.CreateModel(
            name='Group',
            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)),
                ('remedy_script_todo', models.TextField(blank=True, default='', max_length=51200)),
                ('remark', models.CharField(blank=True, max_length=100, 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)),
                ('deleting', models.BooleanField(default=False, editable=False)),
                ('instances', models.ManyToManyField(blank=True, editable=False, to='clouds.Instance')),
                ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['pk'],
            },
            bases=(models.Model, clouds.base.models.M2MOperatableMixin),
        ),
        migrations.CreateModel(
            name='GroupOperation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('batch_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)),
                ('script', models.TextField(blank=True, max_length=5120, null=True)),
                ('created_time', models.DateTimeField(auto_now_add=True)),
                ('started_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('completed_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('status', models.CharField(choices=[('success', 'success'), ('failed', 'failed'), ('running', 'running'), ('waiting', 'waiting')], default='running', editable=False, max_length=50)),
                ('tidied', models.BooleanField(default=False, editable=False)),
                ('manual', models.BooleanField(default=True, editable=False)),
                ('serial', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='clouds.GroupOperation')),
                ('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='clouds.Group')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.RemoveField(
            model_name='instanceoperation',
            name='target',
        ),
    ]
