# Generated by Django 5.1.7 on 2025-04-15 08:50

import django.core.validators
import django.db.models.deletion
import taggit.managers
import utilities.json
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
        ("extras", "0123_journalentry_kind_default"),
        ("ipam", "0076_natural_ordering"),
        ("netbox_load_balancing", "0001_initial"),
        ("tenancy", "0017_natural_ordering"),
    ]

    operations = [
        migrations.AlterField(
            model_name="lbserviceassignment",
            name="assigned_object_type",
            field=models.ForeignKey(
                limit_choices_to=models.Q(
                    models.Q(
                        ("app_label", "netbox_load_balancing"), ("model", "virtualip")
                    ),
                    models.Q(("app_label", "dcim"), ("model", "device")),
                    models.Q(("app_label", "dcim"), ("model", "virtualdevicecontext")),
                ),
                on_delete=django.db.models.deletion.CASCADE,
                to="contenttypes.contenttype",
            ),
        ),
        migrations.AlterField(
            model_name="poolassignment",
            name="assigned_object_type",
            field=models.ForeignKey(
                limit_choices_to=models.Q(
                    models.Q(
                        ("app_label", "netbox_load_balancing"), ("model", "lbservice")
                    )
                ),
                on_delete=django.db.models.deletion.CASCADE,
                to="contenttypes.contenttype",
            ),
        ),
        migrations.CreateModel(
            name="VirtualIPPool",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("last_updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "custom_field_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=utilities.json.CustomFieldJSONEncoder,
                    ),
                ),
                ("description", models.CharField(blank=True, max_length=200)),
                ("comments", models.TextField(blank=True)),
                ("name", models.CharField()),
                ("disabled", models.BooleanField(default=False)),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
                (
                    "tenant",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="%(class)s_related",
                        to="tenancy.tenant",
                    ),
                ),
            ],
            options={
                "verbose_name": "Virtual IP Pool",
                "verbose_name_plural": "Virtual IP Pools",
            },
        ),
        migrations.CreateModel(
            name="VirtualIP",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("last_updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "custom_field_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=utilities.json.CustomFieldJSONEncoder,
                    ),
                ),
                ("description", models.CharField(blank=True, max_length=200)),
                ("comments", models.TextField(blank=True)),
                ("name", models.CharField(max_length=255)),
                (
                    "dns_name",
                    models.CharField(
                        blank=True,
                        max_length=255,
                        validators=[
                            django.core.validators.RegexValidator(
                                code="invalid",
                                message="Only alphanumeric characters, asterisks, hyphens, periods, and underscores are allowed in DNS names",
                                regex="^([0-9A-Za-z_-]+|\\*)(\\.[0-9A-Za-z_-]+)*\\.?$",
                            )
                        ],
                    ),
                ),
                ("disabled", models.BooleanField(default=False)),
                ("route_health_injection", models.BooleanField(default=False)),
                (
                    "address",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="%(class)s_related",
                        to="ipam.ipaddress",
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
                (
                    "virtual_pool",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="%(class)s_related",
                        to="netbox_load_balancing.virtualippool",
                    ),
                ),
            ],
            options={
                "verbose_name": "Virtual IP",
                "verbose_name_plural": "Virtual IPs",
            },
        ),
        migrations.CreateModel(
            name="VirtualIPPoolAssignment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("last_updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "custom_field_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=utilities.json.CustomFieldJSONEncoder,
                    ),
                ),
                ("assigned_object_id", models.PositiveBigIntegerField()),
                ("disabled", models.BooleanField(default=False)),
                (
                    "weight",
                    models.PositiveIntegerField(
                        default=1,
                        validators=[
                            django.core.validators.MinValueValidator(1),
                            django.core.validators.MaxValueValidator(32767),
                        ],
                    ),
                ),
                (
                    "assigned_object_type",
                    models.ForeignKey(
                        limit_choices_to=models.Q(
                            models.Q(("app_label", "ipam"), ("model", "iprange")),
                            models.Q(("app_label", "ipam"), ("model", "prefix")),
                            models.Q(("app_label", "ipam"), ("model", "vlan")),
                        ),
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
                (
                    "virtual_pool",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="%(class)s_related",
                        to="netbox_load_balancing.virtualippool",
                    ),
                ),
            ],
            options={
                "verbose_name": "Virtual Pool Assignment",
                "verbose_name_plural": "Virtual Pool Assignments",
                "indexes": [
                    models.Index(
                        fields=["assigned_object_type", "assigned_object_id"],
                        name="netbox_load_assigne_2a5727_idx",
                    )
                ],
                "constraints": [
                    models.UniqueConstraint(
                        fields=(
                            "assigned_object_type",
                            "assigned_object_id",
                            "virtual_pool",
                        ),
                        name="netbox_load_balancing_virtualippoolassignment_unique_virtual_pool",
                    )
                ],
            },
        ),
    ]
