Skip to content

VMware: QueryNetworkHint("") raises NotFound, so no CDP/LLDP data is read (sync_host_cables and CDP descriptions do nothing) #580

Closed

Description

@tfoks

Description

With sync_host_cables: True no cables are created, and no attempt to create one shows up in the log, even at DEBUG2. The host interface descriptions also never get the (conn: <switch> - <port>) suffix, although the ESXi hosts do see CDP neighbors.

Cause

In module/sources/vmware/connection.py (add_host) the network hints are queried like this:

try:
    for hint in obj.configManager.networkSystem.QueryNetworkHint(""):
        pnic_hints[hint.device] = hint
except Exception:
    pass

QueryNetworkHint takes an optional list of device names. Passing "" makes vCenter look up a NIC with an empty name, and it raises vim.fault.NotFound for every host. The bare except Exception: pass hides the error, so pnic_hints is always empty. That means:

Direct pyVmomi calls against the same host:

Call Result
QueryNetworkHint("") vim.fault.NotFound
QueryNetworkHint() 8 hints, 2 with CDP neighbor data
QueryNetworkHint([]) 8 hints, 2 with CDP neighbor data
QueryNetworkHint(["vmnic0"]) 1 hint

Fix

-            for hint in obj.configManager.networkSystem.QueryNetworkHint(""):
+            for hint in obj.configManager.networkSystem.QueryNetworkHint():
                 pnic_hints[hint.device] = hint
-        except Exception:
-            pass
+        except Exception as e:
+            log.debug(f"Unable to query network hints (CDP/LLDP) of host '{name}': {e}")

With this change, the next run created the expected cables:

INFO: Created new cable object: vmnic5 (esxi01) <> Ethernet1/23 (switch-a)
INFO: Created new cable object: vmnic7 (esxi01) <> Ethernet1/23 (switch-b)

and the CDP neighbors show up in the pNIC descriptions again.

The existing tests in tests/test_vmware_host_cables.py did not catch this. They feed in made-up hint objects and never exercise the QueryNetworkHint call itself.

Environment

  • netbox-sync: v1.9.0 (also present on main)
  • vCenter: 8.0.3 (build 25600417)
  • NetBox: 4.7.2
  • pyvmomi: 9.1.1.0
  • Python: 3.13.5
  • Links: standard vSwitch, CDP in listen mode, Cisco switches

Activity

  1. semx commented on Oct 8, 2026

    @semx
    Collaborator

    Confirmed and merged as #581; it will be in 1.9.1. The "" dates back to #350 and I brought it back in #565 after checking against vcsim only, which ignores the argument. A test that answers the call like vCenter does is in #587 so this does not come back a third time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions