Skip to content

Commit f3403cd

Browse files
committed
Update VM Initializer for Netbox 2.7
The vm 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 virtual_machines.yml file as follows: - Make sure the status is spelled lowercase. See the diff of this commit for further information how this is meant.
1 parent 8d8b9a1 commit f3403cd

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

initializers/prefixes.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1+
## Possible Choices:
2+
## status:
3+
## - container
4+
## - active
5+
## - reserved
6+
## - deprecated
7+
##
8+
## Examples:
9+
110
# - description: prefix1
211
# prefix: 10.1.1.0/24
312
# site: AMS 1
4-
# status: Active
13+
# status: active
514
# tenant: tenant1
615
# vlan: vlan1
716
# - description: prefix2
817
# prefix: 10.1.2.0/24
918
# site: AMS 2
10-
# status: Active
19+
# status: active
1120
# tenant: tenant2
1221
# vlan: vlan2
1322
# is_pool: true
1423
# vrf: vrf2
1524
# - description: ipv6 prefix1
1625
# prefix: 2001:db8:a000:1::/64
1726
# site: AMS 2
18-
# status: Active
27+
# status: active
1928
# tenant: tenant2
2029
# vlan: vlan2

initializers/virtual_machines.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
## Possible Choices:
2+
## status:
3+
## - active
4+
## - offline
5+
## - staged
6+
##
7+
## Examples:
8+
19
# - cluster: cluster1
210
# comments: VM1
311
# disk: 200
412
# memory: 4096
513
# name: virtual machine 1
614
# platform: Platform 2
7-
# status: Active
15+
# status: active
816
# tenant: tenant1
917
# vcpus: 8
1018
# - cluster: cluster1
@@ -13,6 +21,6 @@
1321
# memory: 2048
1422
# name: virtual machine 2
1523
# platform: Platform 2
16-
# status: Active
24+
# status: active
1725
# tenant: tenant1
1826
# vcpus: 8

startup_scripts/220_prefixes.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from dcim.models import Site
22
from ipam.models import Prefix, VLAN, Role, VRF
3-
from ipam.constants import PREFIX_STATUS_CHOICES
43
from tenancy.models import Tenant, TenantGroup
54
from extras.models import CustomField, CustomFieldValue
65
from ruamel.yaml import YAML
@@ -38,12 +37,6 @@
3837

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

41-
if 'status' in params:
42-
for prefix_status in PREFIX_STATUS_CHOICES:
43-
if params['status'] in prefix_status:
44-
params['status'] = prefix_status[0]
45-
break
46-
4740
prefix, created = Prefix.objects.get_or_create(**params)
4841

4942
if created:

startup_scripts/230_virtual_machines.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from dcim.models import Site, Platform, DeviceRole
22
from virtualization.models import Cluster, VirtualMachine
3-
from virtualization.constants import VM_STATUS_CHOICES
43
from tenancy.models import Tenant
54
from extras.models import CustomField, CustomFieldValue
65
from ruamel.yaml import YAML
@@ -43,12 +42,6 @@
4342

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

46-
if 'status' in params:
47-
for vm_status in VM_STATUS_CHOICES:
48-
if params['status'] in vm_status:
49-
params['status'] = vm_status[0]
50-
break
51-
5245
virtual_machine, created = VirtualMachine.objects.get_or_create(**params)
5346

5447
if created:

0 commit comments

Comments
 (0)