Merge pull request #393 from MajesticFalcon/vm_init_bug

Bugfix - Allow primary device IP without virtual machine initialization
This commit is contained in:
Christian Mäder 2021-01-20 08:54:13 +01:00 committed by GitHub
commit 21bd7f426c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -31,13 +31,14 @@ def link_primary_ip(assets, asset_model):
devices = load_yaml('/opt/netbox/initializers/devices.yml') devices = load_yaml('/opt/netbox/initializers/devices.yml')
virtual_machines = load_yaml('/opt/netbox/initializers/virtual_machines.yml') virtual_machines = load_yaml('/opt/netbox/initializers/virtual_machines.yml')
if devices is None and virtual_machines is None:
sys.exit()
optional_assocs = { optional_assocs = {
'primary_ip4': (IPAddress, 'address'), 'primary_ip4': (IPAddress, 'address'),
'primary_ip6': (IPAddress, 'address') 'primary_ip6': (IPAddress, 'address')
} }
if devices is None and virtual_machines is None:
sys.exit()
if devices is not None:
link_primary_ip(devices, Device) link_primary_ip(devices, Device)
if virtual_machines is not None:
link_primary_ip(virtual_machines, VirtualMachine) link_primary_ip(virtual_machines, VirtualMachine)