netbox
netbox copied to clipboard
Bulk cable import does not validate interface types
NetBox version
v3.2.3
Python version
3.9
Steps to Reproduce
- create device role
dummy role - create site
demo site - create manufacturer
dummy manufacturer - create a device type
demo model, using thedummy manufacturer - add an interface template to the
demo modeldevice type:- name it
demo virtual if - set the type to
Virtual
- name it
- create two devices using the
demo model, thedummy roleand thedemo site- name the first one
demo1 - name the second one
demo2
- name the first one
- attempt to import the following cable CSV:
side_a_device,side_a_type,side_a_name,side_b_device,side_b_type,side_b_name demo1,dcim.interface,demo virtual if,demo2,dcim.interface,demo virtual if
Expected Behavior
Either of:
- The cable gets imported and displayed as usually
- The import fails with a meaningful error message like
Virtual interfaces cannot have a cable attached.
Observed Behavior
The following exception is thrown:
<class 'ValueError'>
'CableCSVForm' has no field named 'termination_a_id'.
Python version: 3.8.10
NetBox version: 3.2.3
This issue was already reported once as #6045, but was missing the concrete reproduction steps.
Additionally I should mention, that as soon as I change the interface type of demo1's demo virtual if interface to other the exception changes to 'CableCSVForm' has no field named 'termination_b_id'.. Following this up with changing the demo virtual if interface on demo2 to other as well leads to a properly imported cable.
Either of:
- The cable gets imported and displayed as usually
- The import fails with a meaningful error message like Virtual interfaces cannot have a cable attached.
Virtual interfaces cannot have a cable connected; the second item is correct. The error occurs because the interfaces fields' queryset is being filtered by type to exclude virtual interfaces in the current implementation.
As I didn't find it yet: where is described, why virtual interfaces cannot be cabled? From my point of view there is merit in having cables between virtual interfaces, for example to clearly document multiple network interfaces belonging to VMs, or to represent hypervisors nested in VMs.
Why not model the VM infrastructure with your prefixes and Virtualisation options in Netbox? Cables are a physical (Layer 1) part. VM's are at least application level code.
Why not model the VM infrastructure with your prefixes and Virtualisation options in Netbox?
VMs cannot be members of virtualization clusters. IP address management is totally separate from managing connections.
Cables are a physical (Layer 1) part.
If you talk about bare metal: yes. But for a virtual machine the "cable" is not made of copper, but it still plugs into a switch, be it a vSwitch in VMware, be it a Linux bridge for libvirt/KVM/Proxmox. But a VM's "cable" can also be directly attached to a hypervisor host's physical interface, by taking the entire control of the NIC away from the hypervisor and handing it to the VM. And lastly you can build entire network environments in software inside of a single host - take a typical virtualized lab environment for testing weird edge cases or non-typical routing.
It all boils down to: Allows netbox to model reality, or does it prescribe some concepts?
And taking a look at certain design decisions (like for example the possibility to attach a wifi ssid to an 100BASE-TX typed interface on the create screen) I interpret the intentions more as "encourages best practises, but allows to model reality"
@klaernie The cable model in Netbox is used to model physical cables only. This will not change.
@klaernie The cable model in Netbox is used to model physical cables only. This will not change.
Totally fair point. I'll be fine pretending my first virtualization layer exists physically and use the "other" interface type to make my connections able to be modelled.
The only point for opening this issue is to have this constraint clearly communicated to future users, so they don't have to spend an hour figuring it out.
I have to agree that virtual interfaces shouldn't be cabled.
For virtual systems, I could see adding a "virtual switch" system where interfaces are attached to virtual switches either on the host(s) they belong to or on the cluster itself. This might be something to consider as a FR. Perhaps open a discussion regarding this as a FR and see if you can gain some traction.
Holding off on this until #9102 has been completed
During import, it now looks like this is checked. However, the following exception is generated:
ValueError at /dcim/cables/import/
'CableCSVForm' has no field named 'termination'.
Request Method: POST
Request URL: http://127.0.0.1:8000/dcim/cables/import/
Django Version: 4.0.7
Exception Type: ValueError
Exception Value:
'CableCSVForm' has no field named 'termination'.
Exception Location: C:\Development\netbox\venv\lib\site-packages\django\forms\forms.py, line 400, in add_error
Python Executable: C:\Development\netbox\venv\Scripts\python.exe
Python Version: 3.10.4
Python Path:
['C:\\Development\\netbox\\netbox\\netbox',
'C:\\Program Files\\Python\\3.10\\python310.zip',
'C:\\Program Files\\Python\\3.10\\DLLs',
'C:\\Program Files\\Python\\3.10\\lib',
'C:\\Program Files\\Python\\3.10',
'C:\\Development\\netbox\\venv',
'C:\\Development\\netbox\\venv\\lib\\site-packages',
'c:\\development\\netbox\\netbox-routing',
'c:\\development\\netbox\\netbox-config-backup',
'C:\\Development\\netbox\\venv\\lib\\site-packages\\pydriller-2.1-py3.10.egg',
'C:\\Development\\netbox\\venv\\lib\\site-packages\\dulwich-0.20.35-py3.10-win-amd64.egg',
'C:\\Development\\netbox\\venv\\lib\\site-packages\\uuid-1.30-py3.10.egg',
'C:\\Development\\netbox\\venv\\lib\\site-packages\\lizard-1.17.9-py3.10.egg',
'C:\\Development\\netbox\\venv\\lib\\site-packages\\types_pytz-2021.3.6-py3.10.egg',
'C:\\Development\\netbox\\venv\\lib\\site-packages\\gitpython-3.1.27-py3.10.egg',
'C:\\Development\\netbox\\venv\\lib\\site-packages\\gitdb-4.0.9-py3.10.egg',
'C:\\Development\\netbox\\venv\\lib\\site-packages\\smmap-5.0.0-py3.10.egg',
'c:\\development\\netbox\\netbox-sync',
'c:\\development\\netbox\\netbox-secretstore']
Server time: Fri, 02 Sep 2022 17:30:30 +0000
Going to close this out and opena new issue.