From 00e8bc7ca3748ac7e45d3813b15e38082b92bbfa Mon Sep 17 00:00:00 2001 From: Benjamin Collet Date: Sun, 30 May 2021 08:59:20 +0200 Subject: [PATCH] Fix issue with unamed devices --- exporter.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/exporter.py b/exporter.py index f209e29..3d2817e 100755 --- a/exporter.py +++ b/exporter.py @@ -66,11 +66,12 @@ def ptr(nb, args): if address.assigned_object.device.id in device_cluster: address.assigned_object.device.name = device_cluster[address.assigned_object.device.id] - if address.assigned_object.device.id in device_primary and address.id == device_primary[address.assigned_object.device.id]: - records[ptr] = [{"type":"PTR","rr":address.assigned_object.device.name}] - else: - iname = re.sub(r'[^a-z0-9]', '-',address.assigned_object.name) - records[ptr] = [{"type":"PTR","rr":".".join((iname,address.assigned_object.device.name))}] + if address.assigned_object.device.name is not None: + if address.assigned_object.device.id in device_primary and address.id == device_primary[address.assigned_object.device.id]: + records[ptr] = [{"type":"PTR","rr":address.assigned_object.device.name}] + else: + iname = re.sub(r'[^a-z0-9]', '-',address.assigned_object.name) + records[ptr] = [{"type":"PTR","rr":".".join((iname,address.assigned_object.device.name))}] elif address.assigned_object_type == 'virtualization.vminterface': if address.assigned_object.virtual_machine.id in vm_primary and address.id == vm_primary[address.assigned_object.virtual_machine.id]: