diff --git a/initializers/vlan_groups.yml b/initializers/vlan_groups.yml index a40fd0a..facd34f 100644 --- a/initializers/vlan_groups.yml +++ b/initializers/vlan_groups.yml @@ -1,24 +1,24 @@ # - name: VLAN group 1 -# scope_type: "dcim.region" +# scope_type: dcim.region # scope: Amsterdam # slug: vlan-group-1 # - name: VLAN group 2 -# scope_type: "dcim.site" +# scope_type: dcim.site # scope: AMS 1 # slug: vlan-group-2 # - name: VLAN group 3 -# scope_type: "dcim.location" +# scope_type: dcim.location # scope: cage 101 # slug: vlan-group-3 # - name: VLAN group 4 -# scope_type: "dcim.rack" +# scope_type: dcim.rack # scope: rack-01 # slug: vlan-group-4 # - name: VLAN group 5 -# scope_type: "virtualization.cluster" +# scope_type: virtualization.cluster # scope: cluster1 # slug: vlan-group-5 # - name: VLAN group 6 -# scope_type: "virtualization.clustergroup" +# scope_type: virtualization.clustergroup # scope: Group 1 # slug: vlan-group-6 diff --git a/startup_scripts/200_vlan_groups.py b/startup_scripts/200_vlan_groups.py index 6dda214..eb61023 100644 --- a/startup_scripts/200_vlan_groups.py +++ b/startup_scripts/200_vlan_groups.py @@ -21,12 +21,15 @@ for params in vlan_groups: # Get model from Contenttype scope_type = params.pop("scope_type", None) if not scope_type: - print("scope_type is missing from VLAN Group") + print(f"VLAN Group '{params['name']}': scope_type is missing from VLAN Group") continue app_label, model = str(scope_type).split(".") - ct = ContentType.objects.get(app_label=app_label, model=model) + ct = ContentType.objects.filter(app_label=app_label, model=model).first() if not ct: - print(f"ContentType for app_label = '{app_label}' and model = '{model}' not found") + print( + f"VLAN Group '{params['name']}': ContentType for " + + "app_label = '{app_label}' and model = '{model}' not found" + ) continue params["scope_id"] = ct.model_class().objects.get(**query).id vlan_group, created = VLANGroup.objects.get_or_create(**params)