Closed jeffkala closed 3 weeks ago
I think the issue here is that the length
field is being passed in as a string, but it needs to be an integer. Try this:
---
prefixes:
- "!next_prefix":
locations: "{{ site_name.parent.parent.parent.id }}"
type: "container"
length: {{ ipam_templates[site_size | lower]['template_prefix_size'] | int }}
status__name: "Active"
description: "{{ site_name }} Parent Prefix"
type: "container"
"!ref": "parent_prefix"
Did try this and still got the same error. Even just hardcoded the length and it fails.
---
prefixes:
- "!next_prefix":
locations: "{{ site_name.parent.parent.parent.id }}"
type: "container"
length: 25
status__name: "Active"
description: "{{ site_name }} Parent Prefix"
type: "container"
"!ref": "parent_prefix"
Does seem like its something about no prefixes available in certain circumstances. If I play around with it and make the length much smaller it results in the expected error around "no prefixes available for ..." still debugging further to see what is happening but if I ensure the prefix is available it works as expected.
Still troubleshooting, but the culprit was a relationship with the attributes below. Once the relationship was deleted and nautobot restarted, the design job started working.
In a similar example, I just changed the source and destination to not have potential namepsace issues with the method names, such as prefix -> prefix1 and VLAN -> VLAN1 and that fixed the issue.
I was able to reproduce this in a test and it is exactly as @itdependsnetworks mentioned. Design Builder translates the source/destination labels of custom relationships to actual fields on a proxy model. If there is a clash then this type of issue is caused. If you look at the Prefix
model it already has a vlan
field:
In [4]: Prefix._meta.get_field("vlan")
Out[4]: <django.db.models.fields.related.ForeignKey: vlan>
@jeffkala do you consider this a bug that we should try and mitigate?
At least maybe we can just document it and provide best practices to work around it? I'm not fully onboard that we "must" mitigate it as it seems rare its hit.
PR #200 introduces an error message and protection from overwriting built-in fields. This image is an example error message in the job result:
PR #200 introduces an error message and protection from overwriting built-in fields. This image is an example error message in the job result:
looks great @abates
Environment
Expected Behavior
!next-prefix action tag will get-next properly when a filter criteria is specified to determine the "parent" prefixes to search in.
Observed Behavior
Steps to Reproduce
For additonal testing did validate the same _get_next functionality from ORM returns a value.