adds host_platform_relation #408

This commit is contained in:
ricardo.bartels@telekom.de
2024-09-14 00:23:07 +02:00
parent 7cf4d6bebe
commit 9b1aeb8bed
3 changed files with 9 additions and 4 deletions

View File

@@ -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="""\

View File

@@ -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

View File

@@ -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