-
Notifications
You must be signed in to change notification settings - Fork 12
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
NetBox 3.X #110
NetBox 3.X #110
Conversation
9cfa893
to
003426e
Compare
Was it necessary to move so much code around as part of this feature? I don't really know where to begin reviewing this when diff-wise it basically looks like an entirely new implementation of the app. |
Also, does this just add 3.0 support or does it also drop support for all older NetBox versions? I can't really tell with the scope of the diffs here. |
Yes, the implementation is different, supports multiple NetBox 3.0, 3.1 and 3.2 now, going to add support up to 3.6. Will prepare better developer documentation before making it ready for review. |
Dropped support for Nautobot 1.x and NetBox 2.x, updated the description accordingly. |
Just a quick note that changelog imports was a user-requested feature in the past. How difficult would it be to re-add? |
I don't have any testing data for it, so it's really difficult to estimate. Depends on the level of correctness, if it's just about importing JSON change object without change, then it should be quite easy to implement. When the importer should convert fields in JSON based on the content type, some issues can arise. |
from typing import Any | ||
from typing import Iterable | ||
from typing import List | ||
from typing import Mapping | ||
from typing import MutableMapping | ||
from typing import Tuple | ||
from typing import Type | ||
from typing import Union | ||
from uuid import NAMESPACE_DNS | ||
from uuid import UUID | ||
from uuid import uuid5 |
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.
nit: wouldn't the more usual black/isort/ruff convention be to group these, a la:
from typing import Any | |
from typing import Iterable | |
from typing import List | |
from typing import Mapping | |
from typing import MutableMapping | |
from typing import Tuple | |
from typing import Type | |
from typing import Union | |
from uuid import NAMESPACE_DNS | |
from uuid import UUID | |
from uuid import uuid5 | |
from typing import ( | |
Any, | |
Iterable, | |
List, | |
Mapping, | |
MutableMapping, | |
Tuple, | |
Type, | |
Union, | |
) | |
from uuid import NAMESPACE_DNS, UUID, uuid5 |
Same question/comment throughout.
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 way passes through all CI checks and produces better git diffs.
def set_instance_defaults(self, **defaults: Any) -> None: | ||
"""Set default values for a Nautobot instance constructor.""" | ||
self.constructor_kwargs = defaults |
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.
Would it make sense for this to be set at __init__
time, or does it need to be a separate setter like this?
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.
The structure of wrappers is created on the fly. Some parts can be set in the constructors, however it's possible, that the wrapper will already exists, before configuring it.
Overall feedback from notes:
|
- Content Types Back Mapping: -------------------------------------------------- | ||
Back mapping deviations from Nautobot content type to the source content type | ||
extras.role => Ambiguous | ||
users.user => auth.user |
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.
why is this in this list if not "Ambiguous"?
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 list contain all deviations, mapping to the different content type is considered a deviation.
|
||
## Content Types Back Mapping | ||
|
||
This section shows back mapping deviations from Nautobot content types to NetBox content types. Only those content types that differ between NetBox and Nautobot are shown. |
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.
what is the action task for the user with this info?
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.
No action is necessary from the user, just summarizing deviations to be aware of that.
_name (DATA) => _name (PrivateProperty) | ||
label (DATA) => label (CharField) | ||
description (DATA) => description (CharField) | ||
module (DATA) => module (NotFound) |
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.
what does it mean? is this information lost?
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.
Yes, NotFound
fields are skipped as described above.
docs/user/summary.md
Outdated
- `(ReadOnlyProperty')` marks fields that are read-only properties in Nautobot and can't be imported. | ||
- `(PrivateProperty)` marks fields that are prefixed with an underscore `_` and are considered private properties. Those fields are not imported. | ||
- `(NotFound)` indicates the field is not found in Nautobot and can't be imported. | ||
- `(DoNotImportLastUpdated)` are fields that are not imported as they are automatically updated by Nautobot. |
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.
the word seems only for "LastUpdated" not for any field updated by Nautobot
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.
Updated the documentation to address this.
docs/user/summary.md
Outdated
- `=>` as a separator. | ||
- Nautobot field name. | ||
- Field type in parentheses with the following special cases: | ||
- `SKIPPED` means the field is intentionally skipped by the importer. |
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.
why? could this be changed by the user?
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.
Updated the importer to display disable reason, instead of SKIPPED for each disabled field.
|
||
The NetBox specific component is further segmented into sections, located in the `nautobot_netbox_importer/diffsync` directory: | ||
|
||
- `adapters/nautobot.py`: Inherits `NautobotAdapter` from the generic `NautobotAdapter` and implements pieces necessary for SSoT job. |
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.
why do we need a generic NautobotAdapter to create yet another NautobotAdapter? what is this abstraction providing?
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.
The first one is DiffSync only related implementation. The other one is adding SSoT related things, but it's not probably necessary.
The reason to create the second one was to make the file structure the same way as is in other SSoT apps / integrations.
docs/dev/generator.md
Outdated
|
||
The initial step involves creating a `SourceAdapter()`. It accepts an argument, `get_source_data`, which is `Callable` that returns `Iterable` of the source data items. Each source data item is encapsulated in `SourceRecord(content_type: ContentTypeStr, data: Dict)` instances. `SourceAdapter` constructor also passes any additional arguments to its ancestor, the `DiffSync` class. | ||
|
||
The data undergoes two cycles: the first to establish the structure and the second to import the actual data. |
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.
could you provide a structure with these two cycles and the sub steps involved?
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.
Steps are described in this document, updated this doc to mention that.
General Questions:
|
I'd suggest more targeted questions & answers, because if nothing changed between versions it can be a noop (AFAIK the way this refactor works is that it's data-type check instead of version check alleviates many of those concerns). So:
Link to places where we are already handling these changes instead of speaking in hypotheticals. I'd also like to see two other pieces of information:
|
- Refactored input reading
Still WIP
Questions are addressed in |
Questions are addressed in |
## What has to be done to support a major NetBox version? | ||
|
||
A new major version of the `nautobot-netbox-importer` package should be released to address updated deviations between NetBox and Nautobot models, independent of the previous major version. | ||
|
||
## What has to be done to support a major Nautobot version? | ||
|
||
Similar to the previous question, a new independent release of the `nautobot-netbox-importer` package should be released. |
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.
ok, so every time a new major version for Nautobot or NetBox is released, a new major version of this app has to be released to match it. I guess this will be documented in a versions matrix or similar
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.
Seems to be the best option for me. Optionally it would be possible to support multiple major NetBox releases at once. Depends on the release cadence, and the decision which major release matrix should be supported. This can be reconsidered in the future.
Updated compatibility matrix to cover the current status.
|
||
Similar to the previous question, a new independent release of the `nautobot-netbox-importer` package should be released. | ||
|
||
## What has to be done to support a Nautobot App? |
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.
are we planning to add out-of-the-box support to some Nautobot Apps? or it's only for customization?
if so, what happens when there is a new major release on a Nautobot App?
I understand that the NetBox plugin ecosystem could be also covered by this plugin with similar type of customization, isn't it? if so, maybe document it
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.
Yes, official Nautobot Apps support is a planned feature.
Added Q&A covering Nautobot / NetBox apps support.
Data flow diagram is here: https://github.com/nautobot/nautobot-app-netbox-importer/pull/110/files#diff-a854f6366a0abe3dea5e2e1ce1802a7123a271bb6670d891c805b923b7cfc77c |
All comments should be addressed now. |
wireless.wirelesslan => wireless.wirelesslan | Disabled with reason: Nautobot content type: `wireless.wirelesslan` not found | ||
wireless.wirelesslink => wireless.wirelesslink | Disabled with reason: Nautobot content type: `wireless.wirelesslink` not found | ||
django_rq.queue => django_rq.queue | Disabled with reason: Nautobot content type: `django_rq.queue` not found | ||
secrets.secret => secrets.secret | Disabled with reason: Nautobot content type: `secrets.secret` not found |
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.
Is this the same as extras.secret
?
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.
Added to the follow-up ticket.
I don't pretend to be the one who should be a gatekeeper to this PR, and I'm sure it might take some time to grok the documentation @snaselj has added but I do feel it should be re-reviewed. |
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.
LGTM
Let's get this in, and it could be a great opportunity to create a follow-up PR to address the new NetBox 3.7 release to demonstrate how a new version should be added
Closes: NaN
What's Changed
3.0
-3.6
support.2.0
-2.1
support.Considerations
created
andlast_updated
fields.nautobot_netbox_importer/diffsync/netbox.py
.django.core.exceptions.ValidationError: ['Rack R308 (Row 3) and power panel Panel 4 (MDF) are in different locations']
.django.core.exceptions.ValidationError: {'parent': ['A Location of type Location may only have a Location of the same type as its parent.']}
.InternalTypeStr
toenum
.Not a scope of this PR
ManyToMany
field values?