-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce IPAM Namespaces #3378
Conversation
@jathanism Can you describe the why we deviated from the original design? As far as I can tell this moves the validation into Python as opposed to schema/DB. Is this long-term desirable? What were the limitation with the original?
Is this, could this not be, done behind the scenes from the API interfaces? Where we get schema performant validation but simplified APIs for integrators? Is that the plan and this just a compromise for the prototype? |
Could you add a class diagram similar to #3337 (comment) and #3245 (comment)? I'm having a hard time telling from the text description alone how this implementation differs from those and what the implications are. |
Context, descriptions and some Mermaid diagrams have been provided in the issue: #3337 (comment) |
This is the output from:
The boxes for |
#3395 |
1968fa4
to
5dbd1c9
Compare
Latest changes:Got UI/API working with bare minimum effort to keep things flowing. Namespace
General
RouteDistinguisher
VRF
Prefix
IPAddress
Generic
Not Done
|
5dbd1c9
to
fccb6c5
Compare
@@ -44,6 +46,19 @@ | |||
) | |||
|
|||
|
|||
class NamespaceFilterSet(NautobotFilterSet): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs LocatableModelFilterSetMixin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes:
- I think there was unanimous agreement that there shouldn't be a VRF property on IPAddress so I've updated places that might have caused issues in testing in UI (instead of commenting out), there might be some utility in a helper method to get the parent prefix's vrf
@@ -1714,7 +1714,8 @@ class InterfaceView(generic.ObjectView): | |||
def get_extra_context(self, request, instance): | |||
# Get assigned IP addresses | |||
ipaddress_table = InterfaceIPAddressTable( | |||
data=instance.ip_addresses.restrict(request.user, "view").select_related("vrf", "tenant"), | |||
# data=instance.ip_addresses.restrict(request.user, "view").select_related("vrf", "tenant"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VRF relationship moves to Interface so this becomes unnecessary.
@@ -1828,7 +1828,7 @@ def get_extra_context(self, request, instance): | |||
"device_type", | |||
) | |||
ipaddress = instance.ip_addresses.select_related( | |||
"vrf", | |||
# "vrf", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VRF is either a property of Prefix or Interface, not needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes:
- I think there was unanimous agreement that there shouldn't be a VRF property on IPAddress so I've updated places that might have caused issues in testing in UI (instead of commenting out), there might be some utility in a helper method to get the parent prefix's vrf
Oh yeah, for sure, I stopped at the places that were causing utter breakage in other views. I didn't actually complete the necessary work for IPAddress.
nautobot/ipam/signals.py
Outdated
def ipam_object_saved(sender, instance, raw=False, **kwargs): | ||
""" | ||
Forcibly call `full_clean()` when a new IPAM object is manually saved to prevent creation of | ||
invalid objects. | ||
""" | ||
if raw: | ||
return | ||
instance.full_clean() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to create some noise, as it's causing a bunch of tests to blow up everywhere. See: https://github.com/nautobot/nautobot/pull/3378/files#diff-00a7372c809230ca828aa70f90352848b6654faadb78e4762a8f55ee6c59ce4fR584-R585
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct. This is there for now to force model validation in lieu of having formsets for m2m intermediate relationships for the prototype. I don't think it's worth creating the formset code right now if we're just going to rip it out and replace it for the v2 UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disabled it for Prefix
and VRF
.
nautobot/ipam/models.py
Outdated
|
||
|
||
@extras_features( | ||
"custom_fields", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 Silly git
I was reviewing the test changes in the prototype and the changes being made in #2403 and I still have some thoughts around the VRF-Prefix M2M:
Also, Prefix-VRF was non-M2M before and this never came up before as a limitation, but it was a uniqueness constraint and it would create a unique object because it was implied to be a different network and on the off-chance you did want them to be the same you would have to manage the duplicates manually between these prefixes. Though there's probably a single sentence that unravels my train of thought here... |
- Signal to forcefully call `full_clean()` on assignment of device(s) to VRF or prefix(es) to VRF Modify Interface IPAddress assignment to m2m - Did not yet remove `assigned_object` or any of that jazz from IPAddress - Committed signals (forgot in a previous commit) Remove `IPAddress.vrf` - Clarify unique constraints for VRFDeviceAssignment, - add m2m signal for VRF <-> PRefix Refactor to flatten migrations and implement VMInterface <-> IPAddress m2m Linting Default Namespace will always be created with name "Global" for use in default FK value for RouteDistinguisher, VRF, and Prefix.
- Also make Black happy. Yay!
Namespace - Went with default "Global" namespace for foreign keys FOR NOW just to keep things moving General - Had to remove `vrf` from `select_related` for `Prefix`, `IPAddress` in about 7,000 places VRF - VRF edit includes namespace/devices, prefixes limited by namespace - VRF detail includes devices/prefixes - Filter by namespace now possible Prefix - `Prefix.objects.annotate_tree` now filters on namespace not VRF - Edit view includes namespace - List view groups by namepace - Filter by namespace now possible - `Prefix.get_duplicates()` changed to a noop (returns `queryset.none()`) - Available prefixes now filtered by namespace instead of VRF IPAddress - WIP: Not filtering on VRF, but also not updated for Prefix parenting yet Generic - Had to patch `ObjectEditView` to catch `ValidationError` for `PrefixEditView` because of the `unique_together` constraint ValidationError/IntegrityError not being caught the form validation due to `network` and `prefix_length` fields being excluded from validation due to no t being included in the form fields.
- Fixed lingering issues where `vrf` was still in `select_related` in some cases - Refactored signal handlers to use @receiver decorator - Added `VRFDeviceAssignmentTable` for use in displaying devices assigned to a VRF in RouteDistinguisher detail view. - Added a custom detail view template for RouteDistinguisher
Based on today's demo review... - Namespace - Added `description` field - Added `location` foreign key - Added `@extras_features` - Added assigned VRFs, Prefixes to detail view - RouteDistinguisher - Removed entirely - Revered back to `VRF.rd` field - VRF - Restored `rd` field - Added `namespace` to bulk edit - Added assigned Devices, Prefixes to detail view - VRFDeviceAssignment - Added `rd` field - Added `name` field - If either `rd` or `name` are not set on assignment, they are inherited from the VRF - Added a new `vrf_device_associated` signal handler for `m2m_changed.post_add` to hack m2m validation until a formset is put into place for Device/VRF edit views - Prefix - Added `namespace` to bulk edit - Added assigned VRFs to detail view
- Also improved UI error display slightly.
…utobot/nautobot into u/jathanism-namespace-data-migrations
nautobot/core/tests/test_graphql.py
Outdated
@@ -228,6 +228,7 @@ def test_extend_schema_null_field_choices(self): | |||
self.assertIsInstance(getattr(schema, "resolve_mode"), types.FunctionType) | |||
|
|||
|
|||
@skip("Something really funky is broken here. Setup fails due to content types not existing...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix before merging?
…rations IPAM Namespace Data Migrations
…337-ipam-namespace
- Prefix is now using default natural key fields. - IPAddress tests will need to be revisited after broadcast/prefix_length fields have been removed
…nautobot/nautobot into prototype/jathanism-3337-ipam-namespace
…nautobot/nautobot into prototype/jathanism-3337-ipam-namespace
Co-authored-by: Bryan Culver <bryan.culver@networktocode.com> Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com> Co-authored-by: Gary Snider <gary.snider@networktocode.com>
Closes: #3337, #3429, #3681
What's Changed
This is the very rough around the edges prototype of IPAM Namespaces. It is not yet complete.
It has drifted somewhat from what was discussed in the design chats and what is scoped on #3337, due to the experimentation in the data design during prototyping.
The gist
Changes that drifted related to VRF/RD
Caveats
TODO