Skip to content

Commit 74a0e2c

Browse files
committed
Update Interfaces Initializer for Netbox 2.7
The interface database model has changed in Netbox 2.7. Therefore the initializer code, that was used before, broke. As a user, you will need to update your dcim_interfaces.yml file as follows: - Make sure the type is a value out of the possible choices. See the diff of this commit for further information how this is meant.
1 parent f3403cd commit 74a0e2c

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

initializers/dcim_interfaces.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
## Possible Choices:
2+
## type:
3+
## - virtual
4+
## - lag
5+
## - 1000base-t
6+
## - ... and many more. See for yourself:
7+
## https://github.com/netbox-community/netbox/blob/295d4f0394b431351c0cb2c3ecc791df68c6c2fb/netbox/dcim/choices.py#L510
8+
##
9+
## Examples:
10+
111
# - device: server01
212
# enabled: true
3-
# type: Virtual
13+
# type: virtual
414
# name: to-server02
515
# - device: server02
616
# enabled: true
7-
# type: Virtual
17+
# type: virtual
818
# name: to-server01

startup_scripts/250_dcim_interfaces.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dcim.models import Interface, Device
2-
from dcim.constants import IFACE_TYPE_CHOICES
32
from extras.models import CustomField, CustomFieldValue
43
from ruamel.yaml import YAML
54

@@ -28,16 +27,6 @@
2827

2928
params[assoc] = model.objects.get(**query)
3029

31-
if 'type' in params:
32-
for outer_list in IFACE_TYPE_CHOICES:
33-
for type_choices in outer_list[1]:
34-
if params['type'] in type_choices:
35-
params['type'] = type_choices[0]
36-
break
37-
else:
38-
continue
39-
break
40-
4130
interface, created = Interface.objects.get_or_create(**params)
4231

4332
if created:

0 commit comments

Comments
 (0)