Skip to content

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

@rodvand

Description

@rodvand

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.

# Validate site for cluster & device
if self.cluster and self.site and self.cluster.site != self.site:
raise ValidationError({
'cluster': f'The selected cluster ({self.cluster} is not assigned to this site ({self.site}).'
})
elif self.cluster:
self.site = self.cluster.site
if self.device and self.device.site != self.site:
raise ValidationError({
'device': f'The selected device ({self.device} is not assigned to this site ({self.site}).'
})

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions