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.
This commit is contained in:
parent
f3403cd0f5
commit
74a0e2cf6e
@ -1,8 +1,18 @@
|
|||||||
|
## Possible Choices:
|
||||||
|
## type:
|
||||||
|
## - virtual
|
||||||
|
## - lag
|
||||||
|
## - 1000base-t
|
||||||
|
## - ... and many more. See for yourself:
|
||||||
|
## https://github.com/netbox-community/netbox/blob/295d4f0394b431351c0cb2c3ecc791df68c6c2fb/netbox/dcim/choices.py#L510
|
||||||
|
##
|
||||||
|
## Examples:
|
||||||
|
|
||||||
# - device: server01
|
# - device: server01
|
||||||
# enabled: true
|
# enabled: true
|
||||||
# type: Virtual
|
# type: virtual
|
||||||
# name: to-server02
|
# name: to-server02
|
||||||
# - device: server02
|
# - device: server02
|
||||||
# enabled: true
|
# enabled: true
|
||||||
# type: Virtual
|
# type: virtual
|
||||||
# name: to-server01
|
# name: to-server01
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from dcim.models import Interface, Device
|
from dcim.models import Interface, Device
|
||||||
from dcim.constants import IFACE_TYPE_CHOICES
|
|
||||||
from extras.models import CustomField, CustomFieldValue
|
from extras.models import CustomField, CustomFieldValue
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
|
|
||||||
@ -28,16 +27,6 @@ with file.open('r') as stream:
|
|||||||
|
|
||||||
params[assoc] = model.objects.get(**query)
|
params[assoc] = model.objects.get(**query)
|
||||||
|
|
||||||
if 'type' in params:
|
|
||||||
for outer_list in IFACE_TYPE_CHOICES:
|
|
||||||
for type_choices in outer_list[1]:
|
|
||||||
if params['type'] in type_choices:
|
|
||||||
params['type'] = type_choices[0]
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
break
|
|
||||||
|
|
||||||
interface, created = Interface.objects.get_or_create(**params)
|
interface, created = Interface.objects.get_or_create(**params)
|
||||||
|
|
||||||
if created:
|
if created:
|
||||||
|
Loading…
Reference in New Issue
Block a user