#98 - Add optional ConfigContext to Custom Objects#602
Conversation
|
@claude /review Only report on issues of potential concern; we don't need commentary on anything that doesn't require further consideration. |
|
Claude finished @arthanson's task in 4m 12s —— View job PR Review — #98 Add optional ConfigContext to Custom Objects
Issues of Concern1.
|
|
claude feedback: 1 - Not valid. 2 - *_id concern not valid; added tenant + role dimension tests for coverage. 3 - Valid; docs note added then removed per your request. Enforcement stays at clean(). 4 - already addressed in docs. |
Fixes: #98
Adds a config_context_enabled checkbox to Custom Object Types. When enabled, instances of that type gain NetBox's local_context_data JSON field — a per-object data blob usable for downstream config generation (e.g. Ansible, per the issue).
Inherit config context
Config-context-enabled custom objects can now inherit the ConfigContexts that apply to NetBox objects they reference - the same site/tenant/role/etc. contexts a Device there would get — merged under their own local_context_data.
How: by field-naming convention, no configuration. If a type has a single object field named site, tenant, role, platform, location, device_type, or cluster pointing at the matching model, get_config_context() builds a proxy from those values and reuses NetBox's ConfigContextQuerySet.get_for_object() — so all of NetBox's matching, hierarchy (region/site-group/tenant-group/cluster derivation), weight ordering, and tag matching apply. local_context_data is merged last and always wins. A type with none of these fields stays local-only.
Notes: