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

Uniqueness Checks for ASN, sessions and routing policies #19

Closed
liquid-metal opened this issue May 5, 2021 · 3 comments
Closed

Uniqueness Checks for ASN, sessions and routing policies #19

liquid-metal opened this issue May 5, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@liquid-metal
Copy link

When creating a new

  • AS
  • BGP session
  • Routing Policy

duplicate entries will be created if there is already an object with the same properties.

@liquid-metal
Copy link
Author

Had a quick look at the model, is there any reason the number property of ASN (or BGPBase to be more precise) is nullable and not unique?
For now, I have added the unique=True constraint to the field, which seems to work, but this is a breaking change for existing databases:

  • There may already be multiple entries with same ASN
  • There may be entries with ASN set to None

Trying to set null=False breaks the migration:

You are trying to change the nullable field 'number' on asn to non-nullable without a default; we can't do that (the database needs something to populate existing rows).

Unfortunately, I am not as comfortable with Django and its migrations, is there a possibility to resolve this?

@k01ek
Copy link
Collaborator

k01ek commented May 6, 2021

I think ASN shouldn't be unique. AS number is like a VLAN, you can use the same number for different purposes depending on device or site. Maybe it should use a combination of some fields to get unique.

@liquid-metal
Copy link
Author

do you have a specific use case? In my understanding ASNs are global should always be unique.
For VLANs I see the point in having one set of VLANs per site (although I noticed netbox lets you create indistinguishable VLANs as well).
In any case, null should not be allowed for AS numbers (or am I mistaken?)

@k01ek k01ek self-assigned this May 11, 2021
@k01ek k01ek added the bug Something isn't working label May 11, 2021
@k01ek k01ek mentioned this issue May 28, 2021
@k01ek k01ek closed this as completed Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants