Skip to content

Feature Request: Add VMware guest hostname custom field sync - #536

Merged
semx merged 1 commit into
bb-Ricardo:developmentfrom
muratbulat:feature/vmware-guest-hostname-custom-field
Sep 9, 2026
Merged

semx merged 1 commit into
bb-Ricardo:developmentfrom
muratbulat:feature/vmware-guest-hostname-custom-field

Conversation

@muratbulat

@muratbulat muratbulat commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds optional support for syncing the hostname reported by VMware Tools (guest.hostName) to a NetBox Virtual Machine custom field.

The vCenter VM name and the hostname configured inside the guest operating system are not always the same. This can happen after VM renames, cloning operations, or manual hostname changes inside the guest OS.

Keeping both values in NetBox makes these differences easier to identify.

Configuration

A new optional VMware source setting is added:

vm_guest_hostname_custom_field = vmware_guest_hostname

When configured, netbox-sync reads the hostname reported by VMware Tools and writes it to the selected NetBox VM custom field.

The NetBox VM name continues to use the vCenter inventory name and is not changed by this feature.

Example:

vCenter VM Name:       APPPRD01
VMware Guest Hostname: APPPRD02

or:

vCenter VM Name:       APPPRD01
VMware Guest Hostname: appprd01.domain.local

Custom field behavior

If the configured custom field does not already exist, netbox-sync creates it automatically as a Text custom field for Virtual Machine objects.

An existing custom field can also be used.

The hostname is stored as reported by VMware Tools without changing the case or removing the domain name.

VMware Tools unavailable

If VMware Tools is not installed, not running, or does not currently report a hostname, synchronization continues normally.

In this case, the custom field is not updated and the previous value in NetBox is preserved.

This avoids clearing a previously known hostname because of a temporary VMware Tools issue.

Performance

The hostname is read from the existing vim.VirtualMachine object using guest.hostName.

No additional per-VM vCenter API requests are required.

Backward compatibility

The feature is disabled by default.

Existing configurations are not affected unless vm_guest_hostname_custom_field is explicitly configured.

There are no mandatory configuration or NetBox schema changes.

Tested with

Successfully tested with:

  • VMware vCenter Server 7.0 Update 3w and 8.0 Update 3k
  • NetBox Community 4.6.9
image image

The guest hostname was successfully retrieved from VMware Tools and synchronized to the configured NetBox VM custom field.

13 tests were also added for the new functionality and all are passing:

Ran 13 tests
OK

Documentation

The following were also updated:

  • VMware source documentation
  • settings-example.ini
  • Tests for VMware guest hostname synchronization

…om field

vCenter VM names and the hostname reported by VMware Tools from inside
the guest OS can drift apart (renames, manual OS changes, bad clones).
Setting vm_guest_hostname_custom_field lets a vCenter source sync
guest.hostName into a configurable NetBox custom field, without
touching the VM's name, so admins can compare both on one record.
@muratbulat
muratbulat changed the base branch from main to development August 30, 2026 01:47
@muratbulat
muratbulat requested a review from bb-Ricardo as a code owner August 30, 2026 01:47
@semx
semx merged commit 864969e into bb-Ricardo:development Sep 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants