File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 1
1
# - name: VLAN group 1
2
- # scope_type: " dcim.region"
2
+ # scope_type: dcim.region
3
3
# scope: Amsterdam
4
4
# slug: vlan-group-1
5
5
# - name: VLAN group 2
6
- # scope_type: " dcim.site"
6
+ # scope_type: dcim.site
7
7
# scope: AMS 1
8
8
# slug: vlan-group-2
9
9
# - name: VLAN group 3
10
- # scope_type: " dcim.location"
10
+ # scope_type: dcim.location
11
11
# scope: cage 101
12
12
# slug: vlan-group-3
13
13
# - name: VLAN group 4
14
- # scope_type: " dcim.rack"
14
+ # scope_type: dcim.rack
15
15
# scope: rack-01
16
16
# slug: vlan-group-4
17
17
# - name: VLAN group 5
18
- # scope_type: " virtualization.cluster"
18
+ # scope_type: virtualization.cluster
19
19
# scope: cluster1
20
20
# slug: vlan-group-5
21
21
# - name: VLAN group 6
22
- # scope_type: " virtualization.clustergroup"
22
+ # scope_type: virtualization.clustergroup
23
23
# scope: Group 1
24
24
# slug: vlan-group-6
Original file line number Diff line number Diff line change 21
21
# Get model from Contenttype
22
22
scope_type = params .pop ("scope_type" , None )
23
23
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" )
25
25
continue
26
26
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 ( )
28
28
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
+ )
30
33
continue
31
34
params ["scope_id" ] = ct .model_class ().objects .get (** query ).id
32
35
vlan_group , created = VLANGroup .objects .get_or_create (** params )
You can’t perform that action at this time.
0 commit comments