From 7bc84e8458f139992be1cfaf0b1ca77c2181473c Mon Sep 17 00:00:00 2001 From: Gregory Storme Date: Fri, 14 Aug 2020 12:35:05 +0200 Subject: [PATCH] strip whitespace from platform name --- run.py | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/run.py b/run.py index 23601b2..0787af8 100644 --- a/run.py +++ b/run.py @@ -708,23 +708,41 @@ def get_objects(self, vc_obj_type): results["platforms"].append(nbt.platform( name=platform, )) - results["virtual_machines"].append(nbt.virtual_machine( - name=truncate(obj_name, max_len=64), - cluster=cluster, - status=int( - 1 if obj.runtime.powerState == "poweredOn" else 0 - ), - role="Server", - platform=platform, - memory=obj.config.hardware.memoryMB, - disk=int(sum([ - comp.capacityInKB for comp in - obj.config.hardware.device - if isinstance(comp, vim.vm.device.VirtualDisk) - ]) / 1024 / 1024), # Kilobytes to Gigabytes - vcpus=obj.config.hardware.numCPU, - tags=self.tags - )) + results["virtual_machines"].append(nbt.virtual_machine( + name=truncate(obj_name, max_len=64), + cluster=cluster, + status=int( + 1 if obj.runtime.powerState == "poweredOn" else 0 + ), + role="Server", + platform=platform.strip(), + memory=obj.config.hardware.memoryMB, + disk=int(sum([ + comp.capacityInKB for comp in + obj.config.hardware.device + if isinstance(comp, vim.vm.device.VirtualDisk) + ]) / 1024 / 1024), # Kilobytes to Gigabytes + vcpus=obj.config.hardware.numCPU, + tags=self.tags + )) + else: + results["virtual_machines"].append(nbt.virtual_machine( + name=truncate(obj_name, max_len=64), + cluster=cluster, + status=int( + 1 if obj.runtime.powerState == "poweredOn" else 0 + ), + role="Server", + platform=platform, + memory=obj.config.hardware.memoryMB, + disk=int(sum([ + comp.capacityInKB for comp in + obj.config.hardware.device + if isinstance(comp, vim.vm.device.VirtualDisk) + ]) / 1024 / 1024), # Kilobytes to Gigabytes + vcpus=obj.config.hardware.numCPU, + tags=self.tags + )) # If VMware Tools is not detected then we cannot reliably # collect interfaces and IP addresses if platform: