Skip to content

Commit f637de8

Browse files
committed
Improved error logging
1 parent 3673196 commit f637de8

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

initializers/vlan_groups.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# - name: VLAN group 1
2-
# scope_type: "dcim.region"
2+
# scope_type: dcim.region
33
# scope: Amsterdam
44
# slug: vlan-group-1
55
# - name: VLAN group 2
6-
# scope_type: "dcim.site"
6+
# scope_type: dcim.site
77
# scope: AMS 1
88
# slug: vlan-group-2
99
# - name: VLAN group 3
10-
# scope_type: "dcim.location"
10+
# scope_type: dcim.location
1111
# scope: cage 101
1212
# slug: vlan-group-3
1313
# - name: VLAN group 4
14-
# scope_type: "dcim.rack"
14+
# scope_type: dcim.rack
1515
# scope: rack-01
1616
# slug: vlan-group-4
1717
# - name: VLAN group 5
18-
# scope_type: "virtualization.cluster"
18+
# scope_type: virtualization.cluster
1919
# scope: cluster1
2020
# slug: vlan-group-5
2121
# - name: VLAN group 6
22-
# scope_type: "virtualization.clustergroup"
22+
# scope_type: virtualization.clustergroup
2323
# scope: Group 1
2424
# slug: vlan-group-6

startup_scripts/200_vlan_groups.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
# Get model from Contenttype
2222
scope_type = params.pop("scope_type", None)
2323
if not scope_type:
24-
print("scope_type is missing from VLAN Group")
24+
print(f"VLAN Group '{params['name']}': scope_type is missing from VLAN Group")
2525
continue
2626
app_label, model = str(scope_type).split(".")
27-
ct = ContentType.objects.get(app_label=app_label, model=model)
27+
ct = ContentType.objects.filter(app_label=app_label, model=model).first()
2828
if not ct:
29-
print(f"ContentType for app_label = '{app_label}' and model = '{model}' not found")
29+
print(
30+
f"VLAN Group '{params['name']}': ContentType for "
31+
+ "app_label = '{app_label}' and model = '{model}' not found"
32+
)
3033
continue
3134
params["scope_id"] = ct.model_class().objects.get(**query).id
3235
vlan_group, created = VLANGroup.objects.get_or_create(**params)

0 commit comments

Comments
 (0)