Update Device Initializer for Netbox 2.7
The device 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 devices.yml file as follows: - Make sure the rack face is spelled lowercase. See the diff of this commit for further information how this is meant.
This commit is contained in:
parent
7b914d31d6
commit
4a58676647
|
@ -1,9 +1,24 @@
|
||||||
|
## Possible Choices:
|
||||||
|
## face:
|
||||||
|
## - front
|
||||||
|
## - rear
|
||||||
|
## status:
|
||||||
|
## - offline
|
||||||
|
## - active
|
||||||
|
## - planned
|
||||||
|
## - staged
|
||||||
|
## - failed
|
||||||
|
## - inventory
|
||||||
|
## - decommissioning
|
||||||
|
##
|
||||||
|
## Examples:
|
||||||
|
|
||||||
# - name: server01
|
# - name: server01
|
||||||
# device_role: server
|
# device_role: server
|
||||||
# device_type: Other
|
# device_type: Other
|
||||||
# site: AMS 1
|
# site: AMS 1
|
||||||
# rack: rack-01
|
# rack: rack-01
|
||||||
# face: Front
|
# face: front
|
||||||
# position: 1
|
# position: 1
|
||||||
# custom_fields:
|
# custom_fields:
|
||||||
# text_field: Description
|
# text_field: Description
|
||||||
|
@ -12,7 +27,7 @@
|
||||||
# device_type: Other
|
# device_type: Other
|
||||||
# site: AMS 2
|
# site: AMS 2
|
||||||
# rack: rack-02
|
# rack: rack-02
|
||||||
# face: Front
|
# face: front
|
||||||
# position: 2
|
# position: 2
|
||||||
# custom_fields:
|
# custom_fields:
|
||||||
# text_field: Description
|
# text_field: Description
|
||||||
|
@ -21,7 +36,7 @@
|
||||||
# device_type: Other
|
# device_type: Other
|
||||||
# site: SING 1
|
# site: SING 1
|
||||||
# rack: rack-03
|
# rack: rack-03
|
||||||
# face: Front
|
# face: front
|
||||||
# position: 3
|
# position: 3
|
||||||
# custom_fields:
|
# custom_fields:
|
||||||
# text_field: Description
|
# text_field: Description
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from dcim.models import Site, Rack, DeviceRole, DeviceType, Device, Platform
|
from dcim.models import Site, Rack, DeviceRole, DeviceType, Device, Platform
|
||||||
from dcim.constants import RACK_FACE_CHOICES
|
|
||||||
from ipam.models import IPAddress
|
from ipam.models import IPAddress
|
||||||
from virtualization.models import Cluster
|
from virtualization.models import Cluster
|
||||||
from tenancy.models import Tenant
|
from tenancy.models import Tenant
|
||||||
|
@ -49,12 +48,6 @@ with file.open('r') as stream:
|
||||||
|
|
||||||
params[assoc] = model.objects.get(**query)
|
params[assoc] = model.objects.get(**query)
|
||||||
|
|
||||||
if 'face' in params:
|
|
||||||
for rack_face in RACK_FACE_CHOICES:
|
|
||||||
if params['face'] in rack_face:
|
|
||||||
params['face'] = rack_face[0]
|
|
||||||
break
|
|
||||||
|
|
||||||
device, created = Device.objects.get_or_create(**params)
|
device, created = Device.objects.get_or_create(**params)
|
||||||
|
|
||||||
if created:
|
if created:
|
||||||
|
|
Loading…
Reference in New Issue