Repository: nautobot/nautobot

Issue:
Increase VLAN `name`'s `max_length` to 255
Platforms such as Junos allow for VLAN names up to 255 characters long (https://www.juniper.net/documentation/us/en/software/junos/multicast-l2/topics/ref/statement/vlans-bridging-qfx-series.html#vlans-statement__d38584e1038). We should support this.


Discussion:

Resolving patch:
diff --git a/nautobot/extras/migrations/0054_scheduledjob_kwargs_request_user_change.py b/nautobot/extras/migrations/0054_scheduledjob_kwargs_request_user_change.py
new file mode 100644
--- /dev/null
+++ b/nautobot/extras/migrations/0054_scheduledjob_kwargs_request_user_change.py
@@ -0,0 +1,35 @@
+from django.db import migrations
+
+
+def rename_scheduled_job_kwargs_request_user(apps, schema_editor):
+    """
+    Rename ScheduledJob.kwargs["request"]["user"] to ScheduledJob.kwargs["request"]["_user_pk"]
+    to support https://github.com/nautobot/nautobot/pull/3105 and prevent an AttributeError exception
+    when the scheduled job runs.
+    """
+    ScheduledJob = apps.get_model("extras", "ScheduledJob")
+    for sj in ScheduledJob.objects.all():
+        if "request" in sj.kwargs:
+            sj.kwargs["request"].setdefault("_user_pk", sj.kwargs["request"].pop("user", None))
+            sj.save()
+
+
+def reverse_rename_scheduled_job_kwargs_request_user(apps, schema_editor):
+    ScheduledJob = apps.get_model("extras", "ScheduledJob")
+    for sj in ScheduledJob.objects.all():
+        if "request" in sj.kwargs:
+            sj.kwargs["request"].setdefault("user", sj.kwargs["request"].pop("_user_pk", None))
+            sj.save()
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("extras", "0053_relationship_required_on"),
+    ]
+
+    operations = [
+        migrations.RunPython(
+            rename_scheduled_job_kwargs_request_user, reverse_code=reverse_rename_scheduled_job_kwargs_request_user
+        ),
+    ]
diff --git a/nautobot/ipam/migrations/0009_alter_vlan_name.py b/nautobot/ipam/migrations/0009_alter_vlan_name.py
new file mode 100755
--- /dev/null
+++ b/nautobot/ipam/migrations/0009_alter_vlan_name.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.2.16 on 2023-01-26 19:03
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("ipam", "0008_prefix_vlan_vlangroup_location"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="vlan",
+            name="name",
+            field=models.CharField(db_index=True, max_length=255),
+        ),
+    ]
diff --git a/nautobot/ipam/models.py b/nautobot/ipam/models.py
--- a/nautobot/ipam/models.py
+++ b/nautobot/ipam/models.py
@@ -1168,7 +1168,7 @@ class VLAN(PrimaryModel, StatusModel):
     vid = models.PositiveSmallIntegerField(
         verbose_name="ID", validators=[MinValueValidator(1), MaxValueValidator(4094)]
     )
-    name = models.CharField(max_length=64, db_index=True)
+    name = models.CharField(max_length=255, db_index=True)
     tenant = models.ForeignKey(
         to="tenancy.Tenant",
         on_delete=models.PROTECT,


Test patch:
diff --git a/nautobot/ipam/tests/test_api.py b/nautobot/ipam/tests/test_api.py
--- a/nautobot/ipam/tests/test_api.py
+++ b/nautobot/ipam/tests/test_api.py
@@ -546,7 +546,7 @@ def setUpTestData(cls):
         cls.create_data = [
             {
                 "vid": 4,
-                "name": "VLAN 4",
+                "name": "VLAN 4 with a name much longer than 64 characters to verify that we increased the limit",
                 "group": vlan_groups[0].pk,
                 "status": "active",
                 "site": vlan_groups[0].site.pk,
diff --git a/nautobot/ipam/tests/test_views.py b/nautobot/ipam/tests/test_views.py
--- a/nautobot/ipam/tests/test_views.py
+++ b/nautobot/ipam/tests/test_views.py
@@ -356,7 +356,7 @@ def setUpTestData(cls):
             "site": vlangroups[1].site.pk,
             "group": vlangroups[1].pk,
             "vid": 999,
-            "name": "VLAN999",
+            "name": "VLAN999 with an unwieldy long name since we increased the limit to more than 64 characters",
             "tenant": None,
             "status": status_reserved.pk,
             "role": roles[1].pk,