Implications of adding a Device entry for each Virtual Machine

89 views
Skip to first unread message

Brian Cococcia

unread,
Jan 22, 2020, 1:11:59 PM1/22/20
to NetBox
Hi All,

First off, I apologize in advance if this question has been asked & answered.  I did not locate a discussion related to the following question I have regarding adding Device entries for Virtual Machines.

- Running Netbox 2.6.5

The NetBox instance we have contains Devices and Virtual Machines in their respective sections.  To accommodate a request from users to reduce querying complexity and show all systems using a single API call (Device or VM), the suggestion was made to create a Device entry for each Virtual Machine and continue to create minimal Virtual Machine records.  The question I have is whether maintaining a Device entry for each Virtual Machine and having a Virtual Machine entry will introduce unexpected consequences with current or future releases. 

It is understood that maintaining duplicate entries will add some complication to for administrators and "NetBox does not support pinning a specific VM within a cluster to a particular host device".  Let me know if additional information is required to appropriately address the question.

Sincerely,
Brian

Brian Candler

unread,
Jan 22, 2020, 1:33:04 PM1/22/20
to NetBox
> The question I have is whether maintaining a Device entry for each Virtual Machine and having a Virtual Machine entry will introduce unexpected consequences with current or future releases. 

I'd say that it's a bad idea for several reasons.  One is that you'd have to duplicate all the interfaces, and have duplicate IP addresses.  Another is that there are different id spaces: i.e. /dcim/devices/123/ and /virtualization/virtualmachines/123/ are different things, and that is going to lead to confusion.

You *could* just about get away with ignoring VMs entirely, and modelling VMs as unracked "devices".  In fact, this is what we had to do in the early days of Netbox, before there was VM support.  it was pretty ugly.

In an ideal world, I think a Device and a VM would be two variations of the same common base object, but that's not how Netbox is designed.  They are distinct objects, although they repeat many fields (e.g. role, platform), and they share Interfaces as a child object.

Is there another way to address your concerns?  Devices and VMs are searchable via the same interface.  Is there some sort of unified view which would be better for your use case?  If you want "a single API call" could you just write a small API of your own which does two queries behind the scenes?

> "NetBox does not support pinning a specific VM within a cluster to a particular host device"

What that means is:
- every VM is associated with a "cluster"
- a cluster consists of zero or more devices (*)
- however you can't specify that the VM is running on *one particular device*, only on the cluster

(You could however make multiple clusters, each consisting of one device.  This makes sense when you have immobile VMs, tied to the local storage on a particular server)

(*) A cluster with zero devices makes sense for a virtual cluster, e.g. nested virtualization, or for clusters in the cloud where you have no visibility of the underlying devices.

Brian Cococcia

unread,
Jan 22, 2020, 2:33:46 PM1/22/20
to NetBox
Thank you for the response.  Very helpful.  We are still working out how to move forward, but it sounds like duplicating entries is technically possible provided there are no information (interface/IP) conflicts between the Device entry for the Virtual Machine and the Virtual Machine entry.  Though, given the provided feedback, it is not recommended.

Is there some sort of unified view which would be better for your use case?  If you want "a single API call" could you just write a small API of your own which does two queries behind the scenes?

This is a good suggestion, thank you.  Adding a layer in front of the NetBox API may be a better way to handle the data extractions into a single call.
Reply all
Reply to author
Forward
0 new messages