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.
This commit is contained in:
parent
8d8b9a157e
commit
f3403cd0f5
@ -1,13 +1,22 @@
|
|||||||
|
## Possible Choices:
|
||||||
|
## status:
|
||||||
|
## - container
|
||||||
|
## - active
|
||||||
|
## - reserved
|
||||||
|
## - deprecated
|
||||||
|
##
|
||||||
|
## Examples:
|
||||||
|
|
||||||
# - description: prefix1
|
# - description: prefix1
|
||||||
# prefix: 10.1.1.0/24
|
# prefix: 10.1.1.0/24
|
||||||
# site: AMS 1
|
# site: AMS 1
|
||||||
# status: Active
|
# status: active
|
||||||
# tenant: tenant1
|
# tenant: tenant1
|
||||||
# vlan: vlan1
|
# vlan: vlan1
|
||||||
# - description: prefix2
|
# - description: prefix2
|
||||||
# prefix: 10.1.2.0/24
|
# prefix: 10.1.2.0/24
|
||||||
# site: AMS 2
|
# site: AMS 2
|
||||||
# status: Active
|
# status: active
|
||||||
# tenant: tenant2
|
# tenant: tenant2
|
||||||
# vlan: vlan2
|
# vlan: vlan2
|
||||||
# is_pool: true
|
# is_pool: true
|
||||||
@ -15,6 +24,6 @@
|
|||||||
# - description: ipv6 prefix1
|
# - description: ipv6 prefix1
|
||||||
# prefix: 2001:db8:a000:1::/64
|
# prefix: 2001:db8:a000:1::/64
|
||||||
# site: AMS 2
|
# site: AMS 2
|
||||||
# status: Active
|
# status: active
|
||||||
# tenant: tenant2
|
# tenant: tenant2
|
||||||
# vlan: vlan2
|
# vlan: vlan2
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
|
## Possible Choices:
|
||||||
|
## status:
|
||||||
|
## - active
|
||||||
|
## - offline
|
||||||
|
## - staged
|
||||||
|
##
|
||||||
|
## Examples:
|
||||||
|
|
||||||
# - cluster: cluster1
|
# - cluster: cluster1
|
||||||
# comments: VM1
|
# comments: VM1
|
||||||
# disk: 200
|
# disk: 200
|
||||||
# memory: 4096
|
# memory: 4096
|
||||||
# name: virtual machine 1
|
# name: virtual machine 1
|
||||||
# platform: Platform 2
|
# platform: Platform 2
|
||||||
# status: Active
|
# status: active
|
||||||
# tenant: tenant1
|
# tenant: tenant1
|
||||||
# vcpus: 8
|
# vcpus: 8
|
||||||
# - cluster: cluster1
|
# - cluster: cluster1
|
||||||
@ -13,6 +21,6 @@
|
|||||||
# memory: 2048
|
# memory: 2048
|
||||||
# name: virtual machine 2
|
# name: virtual machine 2
|
||||||
# platform: Platform 2
|
# platform: Platform 2
|
||||||
# status: Active
|
# status: active
|
||||||
# tenant: tenant1
|
# tenant: tenant1
|
||||||
# vcpus: 8
|
# vcpus: 8
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from dcim.models import Site
|
from dcim.models import Site
|
||||||
from ipam.models import Prefix, VLAN, Role, VRF
|
from ipam.models import Prefix, VLAN, Role, VRF
|
||||||
from ipam.constants import PREFIX_STATUS_CHOICES
|
|
||||||
from tenancy.models import Tenant, TenantGroup
|
from tenancy.models import Tenant, TenantGroup
|
||||||
from extras.models import CustomField, CustomFieldValue
|
from extras.models import CustomField, CustomFieldValue
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
@ -38,12 +37,6 @@ with file.open('r') as stream:
|
|||||||
|
|
||||||
params[assoc] = model.objects.get(**query)
|
params[assoc] = model.objects.get(**query)
|
||||||
|
|
||||||
if 'status' in params:
|
|
||||||
for prefix_status in PREFIX_STATUS_CHOICES:
|
|
||||||
if params['status'] in prefix_status:
|
|
||||||
params['status'] = prefix_status[0]
|
|
||||||
break
|
|
||||||
|
|
||||||
prefix, created = Prefix.objects.get_or_create(**params)
|
prefix, created = Prefix.objects.get_or_create(**params)
|
||||||
|
|
||||||
if created:
|
if created:
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from dcim.models import Site, Platform, DeviceRole
|
from dcim.models import Site, Platform, DeviceRole
|
||||||
from virtualization.models import Cluster, VirtualMachine
|
from virtualization.models import Cluster, VirtualMachine
|
||||||
from virtualization.constants import VM_STATUS_CHOICES
|
|
||||||
from tenancy.models import Tenant
|
from tenancy.models import Tenant
|
||||||
from extras.models import CustomField, CustomFieldValue
|
from extras.models import CustomField, CustomFieldValue
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
@ -43,12 +42,6 @@ with file.open('r') as stream:
|
|||||||
|
|
||||||
params[assoc] = model.objects.get(**query)
|
params[assoc] = model.objects.get(**query)
|
||||||
|
|
||||||
if 'status' in params:
|
|
||||||
for vm_status in VM_STATUS_CHOICES:
|
|
||||||
if params['status'] in vm_status:
|
|
||||||
params['status'] = vm_status[0]
|
|
||||||
break
|
|
||||||
|
|
||||||
virtual_machine, created = VirtualMachine.objects.get_or_create(**params)
|
virtual_machine, created = VirtualMachine.objects.get_or_create(**params)
|
||||||
|
|
||||||
if created:
|
if created:
|
||||||
|
Loading…
Reference in New Issue
Block a user