bb-Ricardo / netbox-sync

Sync objects from VMware or redfish sources to NetBox
MIT License
290 stars 65 forks source link

Required custom field with default value #423

Open Azmodeszer opened 1 week ago

Azmodeszer commented 1 week ago

NetBox: v4.1.6 Sync: v1.7.0 vSphere: v8.0.3.00000

The sync is trying to create new VMs, but running into an error:

2024-11-12 06:03:57,949 - ERROR: NetBox returned: POST /api/virtualization/virtual-machines/ Bad Request
2024-11-12 06:03:57,949 - ERROR: NetBox returned body: {'__all__': ["Missing required custom field 'Icinga2_Monitoring_VM'."]}

And yes, this is a required field for VMs. However, it has a default value set, so I'm not sure why it's complaining about a missing field? Does the sync not work with default values?

I've set the field back to optional for now and the error disappears, but would of course prefer having it automatically set for VMs.

bb-Ricardo commented 2 days ago

Hi,

reading the documentation (https://netboxlabs.com/docs/netbox/en/stable/customization/custom-fields/) gives the impression the default value is only used in the UI. But when submitting data via API the field is required! If the VM has the attribute not assigned in vCenter then netbox-sync can't assign it.

Azmodeszer commented 2 days ago

Yeah, I suspected as much. That's too bad. Any functionality, existing or planned, that might allow the sync to have default values set for certain fields via the settings.ini?