nautobot / nautobot-app-bgp-models

Nautobot BGP models plugin
https://docs.nautobot.com/projects/bgp-models/en/latest/
Other
18 stars 8 forks source link

Bad requirement - 'ASN requires a specified Provider' #122

Closed ChrisGrundemann closed 1 year ago

ChrisGrundemann commented 1 year ago

Environment

Expected Behavior

I'm setting up bgp-models for an internet/network service provider (ISP/NSP). As such, most eBGP sessions are to customers. Second most are to peers (across internet exchanges and/or through private network interconnects (PNIs)). The smallest group of eBGP sessions are to transit providers.

I want and need to be able to build BGP peerings between all of these neighbor types (in addition to the iBGP stuff). This means that I should be able to add an eBGP Peer Endpoint from an ASN belonging to a customer, a peer, and/or a transit provider. I should be able to do this through the GUI or through the API (pynautobot) because ISPs/NSPs (and others) have lots of BGP sessions and adding hundreds of peerings manually is hugely tedious and time consuming to the point of unreasonableness.

Observed Behavior

When I try to import / add a peering with an external neighbor, I get an error when creating the endpoint (using pynautobot):

  File "/home/chris/PycharmProjects/sot-tools/venv/lib/python3.8/site-packages/pynautobot/core/query.py", line 276, in _make_call
    raise RequestError(req)
pynautobot.core.query.RequestError: The request failed with code 400 Bad Request: {'__all__': ['ASN requires a specified Provider']}

This is a bug, because I should not be required to tie a Provider to a customer or peer ASN. To whit: I am not required to do so when using the GUI. In the GUI I can add the same ASN to the same PeerEndpoint and I do not get an error.

Steps to Reproduce

  1. Use the pynautobot .create function; attempting to create a new PeerEndpoint for an eBGP neighbor (the far / external side)
  2. Include the UUID for the eBGP neighbor's ASN
  3. Get errored out (error above, relevant code snip below)
  4. Do the same thing in the GUI and it works
    nb = pynautobot.api(url=nauto_url, token=nauto_token)
    endpoints = nb.plugins.bgp.peer_endpoints
            farend = endpoints.create(
                source_ip=ip_id,
                autonomous_system=asn_id,
                peering=peering_id,
                enabled="true",
            )

Note: There may be issues with my import script, because I can't test it until this error is cleared out of the way.

Thanks! =)

mzbroch commented 1 year ago

The error reported is raised in the Peer Endpoint Validation, and is there by the design and is related to the network wide view of peerings. This validation forces user to specify ASN's provider in case of lack of the routing-instance specified / modelled. This would be the case for external peering where remote device is not modelled.

So what we envisioned are the views:

In that case, I would recommend:

I hope that could solve Your use case

ChrisGrundemann commented 1 year ago

Yes, that is a possible workaround - all ISPs could do a bunch of useless work to force this to be functional as-is. My point, however, is that the forced validation is a bug and should be removed.

Maybe to help me understand you can explain why this requirement should continue to be enforced? And, why it should only be enforced on the API but not the GUI. Thanks!

mzbroch commented 1 year ago

@ChrisGrundemann Released in https://github.com/nautobot/nautobot-plugin-bgp-models/releases/tag/v0.8.0