Unable to pin a virtual machine to device in cluster due to difference in site #7071

Closed
opened 2025-12-29 19:48:33 +01:00 by adam · 1 comment
Owner

Originally created by @rodvand on GitHub (Oct 4, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.3.4

Python version

3.8

Steps to Reproduce

  1. Create sites DC1 and DC2
  2. Create a cluster named Stretched (type doesn't matter). Do not assign it to a Site.
  3. Create two devices, device_dc1, device_dc2 and assign them to site DC1 and DC2
  4. Add device_dc1, device_dc2 to your cluster Stretched.
  5. Create a virtual machine vm_dc1
  6. Assign it to the cluster Stretched, and try to pin it to device_dc1

Expected Behavior

To be allowed to pin the virtual machine to a specific device in the cluster.

Observed Behavior

You get an error message saying "The selected device (device_in_ds1 is not assigned to this site (None).". To get it to work I have to assign the cluster to the site DC1, but I can't do that either because the cluster contains devices not in DC1. If all devices in the cluster is the same Site, and the Cluster is assigned a Site the functionality works as expected.

I thought about raising this as an FR, but I think the fact that I can create a cluster and have devices in multiple sites assigned to the cluster I should also be able to pin a virtual machine to these devices.

I believe the logic for this is in the below code, but I'm not quite sure what should change. 53f5f46037/netbox/virtualization/models.py (L349-L359)

Originally created by @rodvand on GitHub (Oct 4, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.3.4 ### Python version 3.8 ### Steps to Reproduce 1. Create sites DC1 and DC2 2. Create a cluster named Stretched (type doesn't matter). Do not assign it to a Site. 3. Create two devices, device_dc1, device_dc2 and assign them to site DC1 and DC2 4. Add device_dc1, device_dc2 to your cluster Stretched. 5. Create a virtual machine vm_dc1 6. Assign it to the cluster Stretched, and try to pin it to device_dc1 ### Expected Behavior To be allowed to pin the virtual machine to a specific device in the cluster. ### Observed Behavior You get an error message saying "The selected device (device_in_ds1 is not assigned to this site (None).". To get it to work I have to assign the cluster to the site DC1, but I can't do that either because the cluster contains devices not in DC1. If all devices in the cluster is the same Site, and the Cluster is assigned a Site the functionality works as expected. I thought about raising this as an FR, but I think the fact that I can create a cluster and have devices in multiple sites assigned to the cluster I should also be able to pin a virtual machine to these devices. I believe the logic for this is in the below code, but I'm not quite sure what should change. https://github.com/netbox-community/netbox/blob/53f5f4603735980c18c1890217b6e9e442f8fe19/netbox/virtualization/models.py#L349-L359
adam added the type: bugstatus: accepted labels 2025-12-29 19:48:33 +01:00
adam closed this issue 2025-12-29 19:48:34 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 4, 2022):

I think it makes sense to just relax the device validation logic if the cluster is not assigned to a site.

@jeremystretch commented on GitHub (Oct 4, 2022): I think it makes sense to just relax the device validation logic if the cluster is not assigned to a site.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7071