From dfe937d54e58bb694ab072fd4e30b4124f357683 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Thu, 3 Nov 2022 14:56:38 +0100 Subject: [PATCH 1/4] fix: TypeError: Object of type Record is not JSON serializable --- netbox_agent/virtualmachine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox_agent/virtualmachine.py b/netbox_agent/virtualmachine.py index db2cdb0..3d8dd47 100644 --- a/netbox_agent/virtualmachine.py +++ b/netbox_agent/virtualmachine.py @@ -96,8 +96,8 @@ class VirtualMachine(object): vm = nb.virtualization.virtual_machines.create( name=hostname, cluster=cluster.id, - platform=self.device_platform, - device_platform=self.device_platform, + platform=self.device_platform.id, + device_platform=self.device_platform.id, vcpus=vcpus, memory=memory, tenant=tenant.id if tenant else None, -- 2.47.0 From d286fde999f7f8a00191ad462271cee8557621cb Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Thu, 3 Nov 2022 14:57:30 +0100 Subject: [PATCH 2/4] chore: Remove unused API parameter: device_platform --- netbox_agent/virtualmachine.py | 1 - 1 file changed, 1 deletion(-) diff --git a/netbox_agent/virtualmachine.py b/netbox_agent/virtualmachine.py index 3d8dd47..03a5008 100644 --- a/netbox_agent/virtualmachine.py +++ b/netbox_agent/virtualmachine.py @@ -97,7 +97,6 @@ class VirtualMachine(object): name=hostname, cluster=cluster.id, platform=self.device_platform.id, - device_platform=self.device_platform.id, vcpus=vcpus, memory=memory, tenant=tenant.id if tenant else None, -- 2.47.0 From 4bd4b6bb9473550526f172075624c3a7a110ab45 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Thu, 3 Nov 2022 16:48:04 +0100 Subject: [PATCH 3/4] fix: disk is also virtual if `product` is None Example on QEMU/KVM: ```json {'logicalname': '/dev/vda', 'product': None, 'serial': None, 'version': None, 'size': 10737418240, 'description': 'Virtual I/O device', 'type': 'Virtual I/O device'} ``` --- netbox_agent/inventory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox_agent/inventory.py b/netbox_agent/inventory.py index e19608a..164ecf0 100644 --- a/netbox_agent/inventory.py +++ b/netbox_agent/inventory.py @@ -309,7 +309,7 @@ class Inventory(): description = disk.get('description') size = disk.get('size') product = disk.get('product') - if logicalname in raid_devices or disk_type is None: + if logicalname in raid_devices or disk_type is None or product is None: return True non_raid_disks = [ 'MR9361-8i', -- 2.47.0 From 5d0f0bf2fae2b0a11f5d2b478b822392acf04401 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Thu, 3 Nov 2022 16:50:25 +0100 Subject: [PATCH 4/4] chore: Fix typo --- netbox_agent/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox_agent/server.py b/netbox_agent/server.py index bdc1407..c755a71 100644 --- a/netbox_agent/server.py +++ b/netbox_agent/server.py @@ -62,7 +62,7 @@ class ServerBase(): def get_netbox_datacenter(self): dc = self.get_datacenter() if dc is None: - logging.error("Specificing a datacenter (Site) is mandatory in Netbox") + logging.error("Specifying a datacenter (Site) is mandatory in Netbox") sys.exit(1) nb_dc = nb.dcim.sites.get( -- 2.47.0