dropbox / nsot

Network Source of Truth is an open source IPAM and network inventory database
https://nsot.readthedocs.io
Other
399 stars 66 forks source link

Bug in circuit lookup using natural key by A or Z endpoint #298

Closed jathanism closed 6 years ago

jathanism commented 7 years ago
$ nsot circuits list -l 1
+-------------------------------------------------------------------------------+
| ID   Name (Key)                    Endpoint A      Endpoint Z      Attributes |
+-------------------------------------------------------------------------------+
| 1    foo2-bb01:ae0_foo2-bb02:ae0   foo2-bb01:ae0   foo2-bb02:ae0              |
+-------------------------------------------------------------------------------+

$ nsot circuits list -A foo2-bb01:ae0
No circuit found matching args: name=None, endpoint_z=None, endpoint_a=foo2-bb01:ae0, limit=None, offset=None, attributes=(), query=None, id=None!

(It should return the same result)

Lookup using interface ID number works:

$ nsot circuits list -A 329804
+-------------------------------------------------------------------------------+
| ID   Name (Key)                    Endpoint A      Endpoint Z      Attributes |
+-------------------------------------------------------------------------------+
| 1    foo2-bb01:ae0_foo2-bb02:ae0   foo2-bb01:ae0   foo2-bb02:ae0              |
+-------------------------------------------------------------------------------+

Confirmed that https://localhost:8990/api/sites/1/circuits/?endpoint_a=foo2-bb01:ae0 returns [] Confirmed that https://localhost:8990/api/sites/1/circuits/?endpoint_a=329804 returns a payload

GET /api/sites/1/circuits/?endpoint_a=329804
HTTP 200 OK
Allow: GET, POST, PUT, PATCH, OPTIONS
Content-Type: application/json
Vary: Accept

[
    {
        "name": "foo2-bb01:ae0_foo2-bb02:ae0",
        "endpoint_z": "foo2-bb02:ae0",
        "endpoint_a": "foo2-bb01:ae0",
        "name_slug": "foo2-bb01:ae0_foo2-bb02:ae0",
        "attributes": {},
        "id": 1
    }
]