-
Notifications
You must be signed in to change notification settings - Fork 7
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
Overhaul of peer endpoint's IP #149
base: develop
Are you sure you want to change the base?
Conversation
# If source IP and source-interface, ensure source-ip is defined on source-interface: | ||
if (self.source_ip and self.source_interface) and ( | ||
not self.source_interface.ip_addresses.filter(pk=self.source_ip.pk)): | ||
raise ValidationError("Selected source IP is not assigned to the selected source interface") |
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.
Just checking - is it invalid to e.g. use a loopback IP as the source_ip but specify a physical source_interface?
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.
I think You are correct - if we allow for the logic defined in local_ip()
:
- source_ip
- soure_interface
so that source_interface
should not be validated for its IP address
raise ValidationError("Can not set both IP and Update source options") | ||
# If source IP and source-interface, ensure source-ip is defined on source-interface: | ||
if (self.source_ip and self.source_interface) and ( | ||
not self.source_interface.ip_addresses.filter(pk=self.source_ip.pk)): |
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.
Probably should add an .exists()
here and in the similar logic below.
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.
I would say we should remove this check entirely as per above comment
""" | ||
for endpoint in self.endpoints.all(): | ||
if not endpoint.local_ip: | ||
raise ValidationError(f"Peer endpoint does not have a local IP") |
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.
Probably would be good to indicate which endpoint(s) specifically are failing?
@@ -589,28 +598,66 @@ def to_csv(self): | |||
self.peer, | |||
) | |||
|
|||
ip = models.ForeignKey( # Computed IP |
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.
should the __str__
method be changed to use this instead of local_ip?
on_delete=models.PROTECT, | ||
blank=True, | ||
null=True, | ||
related_name="bgp_peer_endpoints", |
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 needs a different related_name
than the source_ip
related_name
, doesn't it?
to="ipam.IPAddress", | ||
on_delete=models.PROTECT, | ||
blank=True, | ||
null=True, |
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.
Should this be non-nullable?
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.
Interesting - now I'm thinking it's possible and would be a very good validation for the data consistency
|
||
# Priority 4: Source IP defined through source-interface on the PeerGroup | ||
if interface_source_ip and inherited_source_interface: | ||
return interface_source_ip |
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.
Do we need a final else
case to either return None or raise an exception?
ip
attribute on thePeerEndpoint
model. This attribute should always store the computed endpoint's IP Address.source_interface
- performprimary_ip
lookup.peer_endpoint.source_ip
source_ip
is set - implemented bypeer_endpoint.save()
source_ip
is removed - implemented bypeer_endpoint.save()
source_ip
is changed - implemented bypeer_endpoint.save()
peer_group.source_ip
source_ip
set on peergroup - send signal any time this setting changes on the parent peer_groupthis will only impact peer_endpoints if they had
peer_group.source_interface
inheritance beforeimplemented through
handle_peergroup_updates
signalsource_ip
removed on peergroup - send signal any time peer endpoint is added to the peer groupimplemented through
handle_peergroup_updates
signalsource_ip
changed on the peergroup - send signal any time peer endpoint is removed from the peer groupimplemented through
handle_peergroup_updates
signalprotect
peer_group.endpoints.all()
from becoming invalid - implementedpeer_endpoint.source_interface
source_interface
is set - implemented bypeer_endpoint.save()
source_interface
is removed - implemented bypeer_endpoint.save()
source_interface
is changed - implemented bypeer_endpoint.save()
peer_group.source_interface
handle_peergroup_updates
peer_group.endpoints.all()
from becoming invalid - implementedpeer_group.clean()
peerendpoint
added to apeer_group
- IP validated duringpeerendpoint.clean()
peerendpoint
removed from apeer_group
- IP validated duringpeerendpoint.clean()
source_ip
based onis_primary
onIPAddressAssignment
source_ip
based onis_primary
onIPAddressAssignment
peer_endpoint.ip
values