netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.4k stars 2.61k forks source link

Add slug to object detail view in NetBox web UI #6955

Closed sc68cal closed 3 years ago

sc68cal commented 3 years ago

NetBox version

v2.11.7

Feature type

Change to existing functionality

Proposed functionality

Include the slug field in object details

Use case

When using the nb_lookup plugin for Ansible, when querying a prefix out of NetBox, based on a role attribute, people sometimes forget that while role is a string parameter in the REST API, it is not the Name attribute of the role, but actually the slug attribute.

This code doesn't work, and causes developer confusion

virtual_edge_tep_ipv4_nw: "{{ lookup('netbox.netbox.nb_lookup', 'prefixes',
                                  api_filter='site=' + netbox_site_slug +
                                  ' tag=' + az_name + ' role=' + '\"NSX-T Virtual Edge Tep\"' +
                                  ' family=4' + ' vlan_vid=401', 
                                  api_endpoint=netbox_url,
                                  token=netbox_token) }}"
"msg": "An unhandled exception occurred while running the lookup plugin 'netbox.netbox.nb_lookup'. 
Error was a <class 'pynetbox.core.query.RequestError'>, original message: 
The request failed with code 400 Bad Request: {'role': ['Select a valid choice. NSX-T Virtual Edge Tep is not one of the available choices.']}"

Using the role's slug value works.

virtual_edge_tep_ipv4_nw: "{{ lookup('netbox.netbox.nb_lookup', 'prefixes',
                                  api_filter='site=' + netbox_site_slug +
                                  ' tag=' + az_name + ' role=' + 'nsx-t-virtual-edge-tep' +
                                  ' family=4' + ' vlan_vid=401', 
                                  api_endpoint=netbox_url,
                                  token=netbox_token) }}"

So, it would be helpful if the NetBox UI listed the slug attribute in each object detail page, so that I don't have to log into netbox, find the prefix, and click the "Edit" button so I can see the slug

Database changes

No response

External dependencies

No response

sc68cal commented 3 years ago

Screen Shot 2021-08-13 at 12 36 26 PM