mirror of
https://github.com/bb-Ricardo/netbox-sync.git
synced 2026-05-21 17:48:25 -05:00
adds new config option "match_host_by_serial"
also enhanced debug out put to return found serials on DEBUG2 refs: #52
This commit is contained in:
@@ -67,6 +67,7 @@ class VMWareHandler:
|
||||
"netbox_vm_device_role": "Server",
|
||||
"permitted_subnets": None,
|
||||
"collect_hardware_asset_tag": True,
|
||||
"match_host_by_serial": True,
|
||||
"cluster_site_relation": None,
|
||||
"host_site_relation": None,
|
||||
"vm_tenant_relation": None,
|
||||
@@ -968,7 +969,8 @@ class VMWareHandler:
|
||||
# look for devices with same serial or asset tag
|
||||
if object_type == NBDevice:
|
||||
|
||||
if device_vm_object is None and object_data.get("serial") is not None:
|
||||
if device_vm_object is None and object_data.get("serial") is not None and \
|
||||
bool(self.match_host_by_serial) is True:
|
||||
log.debug2(f"No match found. Trying to find {object_type.name} based on serial number")
|
||||
|
||||
device_vm_object = self.inventory.get_by_data(object_type, data={"serial": object_data.get("serial")})
|
||||
@@ -1487,8 +1489,10 @@ class VMWareHandler:
|
||||
|
||||
for serial_num_key in ["SerialNumberTag", "ServiceTag", "EnclosureSerialNumberTag"]:
|
||||
if serial_num_key in identifier_dict.keys():
|
||||
serial = get_string_or_none(identifier_dict.get(serial_num_key))
|
||||
break
|
||||
log.debug2(f"Found {serial_num_key}: {get_string_or_none(identifier_dict.get(serial_num_key))}")
|
||||
if serial is None:
|
||||
serial = get_string_or_none(identifier_dict.get(serial_num_key))
|
||||
|
||||
|
||||
# add asset tag if desired and present
|
||||
asset_tag = None
|
||||
|
||||
@@ -170,6 +170,10 @@ permitted_subnets = 172.16.0.0/12, 10.0.0.0/8, 192.168.0.0/16, fd00::/8
|
||||
# value: defines the desired NetBox platform name
|
||||
#vm_platform_relation = centos-7.* = centos7, microsoft-windows-server-2016.* = Windows2016
|
||||
|
||||
# Try to find existing host based on serial number. This can cause issues with blade centers if VMWare does not
|
||||
# report the blades serial number properly.
|
||||
#match_host_by_serial = True
|
||||
|
||||
# Attempt to collect asset tags from vCenter hosts
|
||||
#collect_hardware_asset_tag = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user