Skip to content

Commit

Permalink
Update VLAN Initializer for Netbox 2.7
Browse files Browse the repository at this point in the history
The VLAN 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 vlans.yml file as follows:

- Make sure the status is spelled lowercase.

See the diff of this commit for further information how this is meant.
  • Loading branch information
cimnine committed Jan 20, 2020
1 parent 4a58676 commit 8d8b9a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 10 additions & 2 deletions initializers/vlans.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
## Possible Choices:
## status:
## - active
## - reserved
## - deprecated
##
## Examples:

# - name: vlan1
# site: AMS 1
# status: Active
# status: active
# vid: 5
# role: Main Management
# description: VLAN 5 for MGMT
# - group: VLAN group 2
# name: vlan2
# site: AMS 1
# status: Active
# status: active
# vid: 1300
7 changes: 0 additions & 7 deletions startup_scripts/210_vlans.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from dcim.models import Site
from ipam.models import VLAN, VLANGroup, Role
from ipam.constants import VLAN_STATUS_CHOICES
from tenancy.models import Tenant, TenantGroup
from extras.models import CustomField, CustomFieldValue
from ruamel.yaml import YAML
Expand Down Expand Up @@ -35,12 +34,6 @@

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

if 'status' in params:
for vlan_status in VLAN_STATUS_CHOICES:
if params['status'] in vlan_status:
params['status'] = vlan_status[0]
break

vlan, created = VLAN.objects.get_or_create(**params)

if created:
Expand Down

0 comments on commit 8d8b9a1

Please sign in to comment.