-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed as not planned
Closed as not planned
Copy link
Labels
severity: lowDoes not significantly disrupt application functionality, or a workaround is availableDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
Deployment Type
Self-hosted
NetBox Version
v4.0.5, v4.0.9
Python Version
3.10
Steps to Reproduce
- Create site
- Create vlan at site, don't set 802.1Q Mode (leave it unset)
- Create device at site
- Create interface on device
- Try adding the vlan to the interface using the netbox api with the following options
- dict containing dict
{'untagged_vlan':{vid, name, site}}values from vlan - dict containing dict
{'untagged_vlan':{id}}, value from vlan - dict contaning value
{'untagged_vlan': id}value from vlan
- dict containing dict
Test script using pynetbox
pip install logruru pynetbox
loguru because I like the colours
import pynetbox
import requests
from loguru import logger
netbox_url = "https://demo.netbox.dev"
token = "I assume my token will be deleted so add your own :)"
headers = {
'Authorization': f'Token {token}',
'Content-Type': 'application/json',
'Accept': 'application/json',
}
device_id = 129
iface_id = 1776
vlan_id = 21
nb = pynetbox.api(netbox_url, token=token)
device = nb.dcim.devices.get(id=device_id)
logger.debug(dict(device))
iface = nb.dcim.interfaces.get(id=iface_id)
logger.debug(dict(iface))
vlan = nb.ipam.vlans.get(id=vlan_id)
logger.debug(dict(vlan))
## Pynetbox tests
try:
logger.error("pynetbox: API doc required vid and name")
logger.info(f"loaded: {iface.untagged_vlan}")
iface.untagged_vlan = {"vid": vlan.vid, "name": vlan.name, "site": vlan.site.id}
logger.info(f"local: {iface.untagged_vlan}")
iface.save()
iface = nb.dcim.interfaces.get(id=iface_id)
logger.info(f"reloaded: {iface.untagged_vlan}")
except Exception as e:
logger.critical(e)
try:
logger.error("pynetbox: vlan id")
iface.untagged_vlan = {"id": vlan.id}
logger.info(f"local: {iface.untagged_vlan}")
iface.save()
iface = nb.dcim.interfaces.get(id=iface_id)
logger.info(f"reloaded: {iface.untagged_vlan}")
except Exception as e:
logger.critical(e)
try:
logger.error("pynetbox: vlan object")
iface.untagged_vlan = vlan
logger.info(f"local: {iface.untagged_vlan}")
iface.save()
iface = nb.dcim.interfaces.get(id=iface_id)
logger.info(f"reloaded: {iface.untagged_vlan}")
except Exception as e:
logger.critical(e)
Expected Behavior
The api call would return a error message telling me I can't add a untagged_vlan with first setting a 802.1Q Mode.
Observed Behavior
The api works successfully and the interface object is returned unchanged.
Metadata
Metadata
Assignees
Labels
severity: lowDoes not significantly disrupt application functionality, or a workaround is availableDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application