-
Notifications
You must be signed in to change notification settings - Fork 190
update always updates if custom_fields are set #748
Copy link
Copy link
Open
Labels
app: pynetboxstatus: revisions neededThis issue requires additional information to be actionableThis issue requires additional information to be actionabletype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
pynetbox version
v7.6.1
NetBox version
v4.5.2
Python version
3.12
Steps to Reproduce
import os
import sys
import random
import string
import pynetbox
def randomword(length):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(length))
def test():
NETBOX_URL = os.getenv("NETBOX_URL")
NETBOX_TOKEN = os.getenv("NETBOX_TOKEN")
# Connect to NetBox
nb = pynetbox.api(
NETBOX_URL,
token=NETBOX_TOKEN,
threading=True,
)
print("Connected to NetBox version:", nb.version)
cf = nb.extras.custom_fields.get(name="testfield")
if cf is None:
cfi = {}
cfi["name"] = "testfield"
cfi["object_types"] = ["dcim.site"]
cfi["type"] = "text"
cf_id = nb.extras.custom_fields.create(cfi)
print(cf_id)
site = nb.dcim.sites.get(name="testsite")
if site is None:
site = nb.dcim.sites.create({
"name": "testsite",
"slug": "testsite",
"custom_fields": {
"testfield": "test"
}
})
site = nb.dcim.sites.get(name="testsite")
rnd = randomword(10)
update = site.update({
"name": "testsite",
"slug": "testsite",
"custom_fields": {
"testfield": rnd
}
})
print(f"update with {rnd} result {update}")
update = site.update({
"name": "testsite",
"slug": "testsite",
"custom_fields": {
"testfield": rnd
}
})
print(f"update with {rnd} result {update}")
update = site.update({
"name": "testsite",
"slug": "testsite",
})
print(f"update without custom_fields result {update}")
def main() -> int:
test()
return 0
if __name__ == '__main__':
sys.exit(main())
Expected Behavior
Connected to NetBox version: 4.5
update with jsuequztwf result True
update with jsuequztwf result False
update without custom_fields result False
Observed Behavior
Connected to NetBox version: 4.5
update with jsuequztwf result True
update with jsuequztwf result True
update without custom_fields result False
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
app: pynetboxstatus: revisions neededThis issue requires additional information to be actionableThis issue requires additional information to be actionabletype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application