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

Weight Import Bug #534

Closed
danner26 opened this issue Mar 8, 2023 · 1 comment
Closed

Weight Import Bug #534

danner26 opened this issue Mar 8, 2023 · 1 comment

Comments

@danner26
Copy link
Member

danner26 commented Mar 8, 2023

I believe there might be a bug within pynetbox. When doing an import with a device that has the weight object defined, specifically with 2 decimal places, I keep experiencing the following error: {"weight":["A valid number is required."]}. I currently hold the belief that this error is directly related to either be a pynetbox issue or an upstream NetBox issue, but I am leaning towards pynetbox. I have already verified that the Weight model in NetBox is a DecimalField (with decimal_places=2).

I haven't confirmed or denied this, but @jsenecal and I tackled a seemingly similar issue in the devicetype-library when validating weight objects. You can reference this PR for more information but essentially we needed to add parse_float=decimal.Decimal to our json.loads() statement and create a custom loader (i.e. Loader=DecimalSafeLoader - see tests/yaml_loader.py in the devicetype-library for reference).

Here is some sample JSON of the data we are passing into the pynetbox dcim.device_types.create() function (the YAML can be found here): {'manufacturer': {'name': 'Datto', 'slug': 'datto'}, 'model': 'AP440', 'slug': 'datto-ap440', 'part_number': 'AP440', 'u_height': 0, 'is_full_depth': False, 'comments': '[Datto Access Points](https://www.datto.com/product-assets/wifi/AP840_840E_Datasheet_US.pdf)', 'weight': [{'value': 1.19, 'unit': 'lb'}], 'power-ports': [{'name': 'DC', 'type': 'dc-terminal', 'maximum_draw': 26}], 'interfaces': [{'name': 'Port 1', 'type': '1000base-t'}, {'name': 'Port 2', 'type': '1000base-t', 'poe_mode': 'pd', 'poe_type': 'type2-ieee802.3at'}, {'name': 'WiFi', 'type': 'ieee802.11ax'}]}

Please let me know if I can assist in any way or provide anymore information

@danner26
Copy link
Member Author

danner26 commented Mar 9, 2023

We actually figure this issue out, so this can be ignored
See this discussion if you need more information

@danner26 danner26 closed this as completed Mar 9, 2023
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

No branches or pull requests

1 participant