Increase the Maximum Length of VirtualMachine Names #23023
BackgroundWe are planning to use NetBox to maintain and manage our virtual machine inventory. While importing our existing virtual machines, we found that NetBox currently limits the Virtual Machine The ProblemThis is a problem for our environment because our VM naming convention encodes several pieces of information in a single name, including:
With this convention, 64 characters are generally not enough to represent the full VM name. Our Naming ConventionExamplesRequestSince we would like to keep the original VM names in NetBox rather than truncate them during synchronization, I would like to ask whether the NetBox developers would consider increasing the maximum length of the Virtual Machine For example, would increasing the limit to 128 characters be considered? Thanks! |
Replies: 2 comments 2 replies
|
At the moment this does not appear to be configurable through a NetBox setting.
name = models.CharField(
verbose_name=_('name'),
max_length=64,
db_collation="natural_sort"
)so changing only the PostgreSQL column would not be a complete/supported solution — the application model and validation would still expect a maximum of 64 characters. If preserving the exact external VM name is required today, I would avoid maintaining a local patch to the NetBox model. A safer approach would be:
That has another advantage: the metadata becomes independently searchable/filterable through the UI and API instead of needing to parse the VM name. If the requirement really is specifically: then I think the clean solution would be an upstream NetBox schema/model change (with the corresponding migration and validation changes), rather than modifying the database manually. So currently: there isn't a configuration option to change it to 128; a custom field is probably the least invasive workaround unless the field length is changed upstream. |
|
NetBox enforces a limit of 64 characters for device and VM names in accordance with both the maximum length of a Linux hostname and with RFC 1035 section 2.3.4, which enforces a maximum of 63 characters per DNS label.
I wouldn't presume to tell you how to run your network, but I would strongly suggest reconsidering this approach. You've encoded far too much variable and extraneous data in the name of an individual VM. Consider:
The great thing about documenting VMs in NetBox is that you can easily document each of these attributes as independently mutable fields on the primary object, requiring only a brief unique name to identify the VM itself. IP addresses don't need to manually recorded, for instance: They can be referred from the IP addresses actually assigned to the VM's interface(s). And if you want to retain a reference to the original name, you have the option of creating a custom field to record it. |
At the moment this does not appear to be configurable through a NetBox setting.
VirtualMachine.nameis currently defined directly in the Django model with:so changing only the PostgreSQL column would not be a complete/supported solution — the application model and validation would still expect a maximum of 64 characters.
If preserving the exact external VM name is required today, I would avoid maintaining a local patch to the NetBox model.
A safer approach would be:
namefield;source_nameororiginal_nameco…