Skip to content
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

Device un-racking #137

Merged
merged 19 commits into from
Feb 26, 2024
Merged

Device un-racking #137

merged 19 commits into from
Feb 26, 2024

Conversation

snaselj
Copy link
Contributor

@snaselj snaselj commented Feb 19, 2024

Closes: NaN

What's Changed

  • Added testing half U device racking.

extras.status: 2
ipam.fhrpgroup: 1
tenancy.tenant: 11
tenancy.tenantgroup: 1
- Validation issues: -------------------------------------------------------------------------------
. dcim.device: 1 ..................................................................................
4f3495b5-00e6-5917-a148-77e109f96b0f Half U Device | {'position': ['A U0 device type (Half U Device Type) cannot be assigned to a rack position.']}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the device can't be assigned to the rack, the validation issue is created, but the device is saved with the rack assignment now.

Does it makes sense to add --unrack-failing-devices flag to nautobot-server import_netbox management command to unrack these devices?

WDYT pls. @glennmatthews @chadell ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thought process is that if a Device can't be assigned to a rack (due to some validation), the importer should not rack it and log it. I don't understand "the device is saved with the rack assignment now". How is it possible if it fails?
I understand that unrack-failing-devices should be the default option, and I don't see how it can be racked if it's not possible 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The record is saved using save() so that it's imported in Nautobot. However, after each save() there is another valided_save() call. These calls gathers all records, that has been saved, however validation failed for those records.

In summary, there is a section listing all ValidationIssues, that means, records are saved, however there is an issue with data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As same, as in previous version of NetBox importer, there is a switch --bypass-data-validation in management command, that allows saving data to Nautobot, that fails validated_save() call. When this switch is disabled, the importer fails if there are any ValidationIssues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformulating my question.

Current behavior:

There is a NetBox device with u_height = 0.5, some rack and position assigned. When importing, u_height is converted (truncated) to integer, so u_height = 0. The device is saved using save(), but the VaidationIssue is created as it doesn't pass validated_save() call. Device is assigned to the rack, but data are invalid. Device is NOT displayed in the Nautobot UI Non-Racked Devices section.

Should I implement --unrack-failing-devices flag to nautobot-server import_netbox management command to un-rack these devices?

Un-racking means setting position = None for these devices.

Pros:

  • The device is displayed in the Non-Racked Devices section.
  • Device data are valid and can be updated. validated_save() call would pass.

Cons:

  • position is lost.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I understand now. We offer the user a way to customize how to handle this situation that leads to a Device assigned to a rack but not visible in the non-racked Devices.
My question is with the invalid data (keeping the position but having no rack), is this useful for the user? I mean, if you can use the position with this u_height, why do we need to keep it? thus, I would make it the default behavior, and maybe add a flag to --do-not-unrack-failing-devices

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented --no-unrack-zero-uheight-devices to better describe what is this feature doing.

@snaselj
Copy link
Contributor Author

snaselj commented Feb 21, 2024

Blocked by: #139

Copy link
Contributor

@chadell chadell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@snaselj snaselj marked this pull request as ready for review February 26, 2024 11:28
@snaselj snaselj merged commit 075f139 into develop Feb 26, 2024
14 checks passed
@snaselj snaselj deleted the u/snaselj-napps-246-unracking branch February 26, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants