diff --git a/module/sources/vmware/config.py b/module/sources/vmware/config.py index 7d0465d..3d6d97e 100644 --- a/module/sources/vmware/config.py +++ b/module/sources/vmware/config.py @@ -147,15 +147,16 @@ class VMWareConfig(ConfigBase): config_example="Cluster_NYC.* = Customer A"), ConfigOption("host_tenant_relation", str, config_example="esxi300.* = Infrastructure"), ConfigOption("vm_tenant_relation", str, config_example="grafana.* = Infrastructure"), - ConfigOption("vm_platform_relation", + ConfigOption("host_platform_relation", str, description="""\ This option defines custom platforms if the VMWare created platforms are not suitable. Pretty much a mapping of VMWare platform name to your own platform name. This is done with a comma separated key = value list. - key: defines a VMWare returned platform name + key: defines a VMWare returned platform name as regex value: defines the desired NetBox platform name""", - config_example="centos-7.* = centos7, microsoft-windows-server-2016.* = Windows2016"), + config_example="VMware ESXi 7.0.3 = VMware ESXi 7.0 Update 3o"), + ConfigOption("vm_platform_relation", str, config_example="centos-7.* = centos7, microsoft-windows-server-2016.* = Windows2016"), ConfigOption("host_role_relation", str, description="""\ diff --git a/module/sources/vmware/connection.py b/module/sources/vmware/connection.py index e16106c..35c377d 100644 --- a/module/sources/vmware/connection.py +++ b/module/sources/vmware/connection.py @@ -1607,7 +1607,10 @@ class VMWareHandler(SourceBase): model = get_string_or_none(grab(obj, "summary.hardware.model")) product_name = get_string_or_none(grab(obj, "summary.config.product.name")) product_version = get_string_or_none(grab(obj, "summary.config.product.version")) + + # collect platform platform = f"{product_name} {product_version}" + platform = self.get_object_relation(platform, "host_platform_relation", fallback=platform) # if the device vendor/model cannot be retrieved (due to problem on the host), # set a dummy value so the host still gets synced diff --git a/settings-example.ini b/settings-example.ini index a26062c..8b32a22 100644 --- a/settings-example.ini +++ b/settings-example.ini @@ -207,8 +207,9 @@ password = super-secret ; This option defines custom platforms if the VMWare created platforms are not suitable. ; Pretty much a mapping of VMWare platform name to your own platform name. ; This is done with a comma separated key = value list. -; key: defines a VMWare returned platform name +; key: defines a VMWare returned platform name as regex ; value: defines the desired NetBox platform name +;host_platform_relation = VMware ESXi 7.0.3 = VMware ESXi 7.0 Update 3o ;vm_platform_relation = centos-7.* = centos7, microsoft-windows-server-2016.* = Windows2016 ; Define the NetBox device role used for hosts. The default is