Skip to content
Snippets Groups Projects
Commit 7ebc1adc authored by Fernando K's avatar Fernando K
Browse files

Allow missing stuff from netbox

parent 06c9368e
No related branches found
No related tags found
No related merge requests found
......@@ -98,18 +98,15 @@ def tag_from_netbox(netbox_tag):
def vm_from_netbox(netbox_vm):
role_id = None
if netbox_vm.get('role'):
role_id = netbox_vm['role']['id']
return VirtualMachine(
id=netbox_vm['id'],
vmid=netbox_vm['custom_fields']['vmid'],
name=netbox_vm['name'],
status=netbox_vm['status']['value'],
# FIXME: some of these are tricky
node_name=netbox_vm['device']['name'],
cluster_name=netbox_vm['cluster']['name'],
role_id=role_id,
node_name=netbox_vm['device']['name'] if netbox_vm['device'] else None,
cluster_name=netbox_vm['cluster']['name'] if netbox_vm['device'] else None,
role_id=netbox_vm['role']['id'] if netbox_vm['role'] else None,
vcpus=netbox_vm['vcpus'],
maxmem=netbox_vm['memory'],
tags=[tag['name'] for tag in netbox_vm['tags']],
......@@ -124,7 +121,7 @@ def interface_from_netbox(netbox_interface):
name=netbox_interface['name'],
vm_name=netbox_interface['virtual_machine']['name'],
mac_address=netbox_interface['mac_address'].upper(),
vlan_id=netbox_interface['untagged_vlan']['vid'],
vlan_id=netbox_interface['untagged_vlan']['vid'] if netbox_interface['untagged_vlan'] else None,
).to_dict()
......
......@@ -2,7 +2,7 @@ from setuptools import find_packages, setup
setup(
name='netbox-proxmox-sync',
version='2.0.5',
version='2.0.6',
description='Import Proxmox cluster info into NetBox.',
install_requires=['pynetbox', 'proxmoxer'],
include_package_data=True,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment