Skip to content

Add an interfaces list view #3564

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

Closed
darcynz opened this issue Oct 3, 2019 · 21 comments
Closed

Add an interfaces list view #3564

darcynz opened this issue Oct 3, 2019 · 21 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Milestone

Comments

@darcynz
Copy link

darcynz commented Oct 3, 2019

Environment

  • Python version:
  • NetBox version:

Proposed Functionality

Add a GUI page for interfaces -> https://netbox/api/dcim/interfaces/. Filtering by site/region and tags would allow easier management of interfaces.

Export template functionality would also add.

Use Case

Enable holistic management of interfaces.

We would use this for our Switch port register (currently done in a spreadsheet to keep track of allocated interfaces in the datacenter).

In general Netbox would be ideal for holistic management of interfaces, making it easy to view them and. It can also be leveraged by adding metadata via tags. Eg monitoring groups.

Noted this was raised before ( #291) but wanted to show the relevance with our use case.

Database Changes

None that I'm aware off

External Dependencies

None that I'm aware off

@jeremystretch jeremystretch added the status: under review Further discussion is needed to determine this issue's scope and/or implementation label Oct 7, 2019
@jeremystretch
Copy link
Member

I don't think it would make sense to do this for only interfaces and not for the six other types of device components (console ports, power ports, etc.).

@jeremystretch jeremystretch changed the title Interfaces Page Add an interfaces list view Oct 7, 2019
@wols
Copy link

wols commented Oct 7, 2019

I could export all interface descriptions (before the connection) to fill device configuration templates.

@darcynz
Copy link
Author

darcynz commented Oct 9, 2019

I agree. I can see benefits seeing the the other components holistically eg one use case could be to find devices with only one power port that need another. It would also enable each component type as a source of truth domain, as users able to see the items holistically easily and any mistakes / omissions. Currently this is done via reports.

Perhaps a multi discipline components page could work. The main difficulty would be filtering, I suppose component specific tags could be listed under their own headings. A check box filter could be used to hide/add component types.

Curious to see community thoughts on this...

@darcynz
Copy link
Author

darcynz commented Oct 22, 2019

We've managed to make a work around via a recent post (Thanks Jeremy!!) that enables exporting associated interfaces via the device model.

Would still be great to see interfaces via the GUI but this helps provide the overview we wanted.

In case any one else is looking to do the same, below is the adjusted the template to give a report like format:

devicename, deviceid, interfacename,  IP Address(es), description, connected device, connected endpoint, formfactor, mtu, lag, enabled?,  tags
{% for device in queryset %}{% for interface in device.interfaces.all %}{{ device.name }},{{ device.id}},{{ interface.name }}, {% for ip in interface.ip_addresses.all %}{{ ip.address }} - {% endfor %}, {{ interface.description}}, {{interface.connected_endpoint.device}}, {{interface.connected_endpoint}},{{interface.form_factor}}, {{interface.mtu}}, {{interface.lag}}, {{ interface.enabled}}, {% for tag in interface.tags.names %}{{tag}}{% if not forloop.last %} - {% endif %}{%endfor %}
{% endfor %}{% endfor %}

@candlerb
Copy link
Contributor

Adding an explicit 'interfaces' view opens the door to importing interfaces as CSV, which was requested as #822 (and #1492 for virtual machines)

@candlerb
Copy link
Contributor

candlerb commented Nov 7, 2019

Just found another use case for this: I wanted to view which MAC addresses I have stored in Netbox.

@candlerb
Copy link
Contributor

candlerb commented Nov 7, 2019

The example export above doesn't work with virtualmachines.

The admin interface does let you create an export template for dcim > interfaces, so I made this:

name,device,virtual_machine,type,enabled,mac_address,mtu,mgmt_only
{%- for i in queryset %}
{{i.name}},{{i.device}},{{i.virtual_machine}},{{i.type}},{{i.enabled}},{{i.mac_address}},{{i.mtu}},{{i.mgmt_only}}
{%- endfor %}

However, the GUI doesn't appear to have anywhere to run it :-(

If I manually create the URL /dcim/interfaces/?export=foo I get a 404. As was recently mentioned elsewhere, I don't think the API allows you to run an export either.

Workaround is to use nbshell:

>>> print(ExportTemplate.objects.get(name="foo").render(Interface.objects.all()))

@darcynz
Copy link
Author

darcynz commented Nov 7, 2019

Thanks Brian! Forgot about VM's, That export will be handy!

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Nov 7, 2019
@jeremystretch jeremystretch added this to the v2.7 milestone Nov 7, 2019
@DanSheps DanSheps self-assigned this Nov 15, 2019
@hellerve
Copy link
Contributor

hellerve commented Nov 15, 2019

We have a working version of interface lists (including filters and so on) in our fork of NetBox.

Did we agree on only doing this for interfaces for now instead of other device components? If so, I’d happily provide the code that we have. If not this should also not be a big problem for us to implement!

EDIT: Oh, I see @DanSheps already volunteered to work on this. Sorry about that!

@DanSheps
Copy link
Member

I think we should definitely do all views.

@TheRealBecks
Copy link

@hellerve @DanSheps Maybe working together could lead into a faster result?

DanSheps added a commit to DanSheps/netbox that referenced this issue Nov 20, 2019
DanSheps added a commit to DanSheps/netbox that referenced this issue Nov 20, 2019
DanSheps added a commit to DanSheps/netbox that referenced this issue Nov 20, 2019
@steffann
Copy link
Contributor

Looks good! I did notice that for interfaces the "Device" column is empty when an interface belongs to a VM. Might be useful to change that column to "Device/VM".

@steffann
Copy link
Contributor

Also: while playing with it I found the order of the columns a bit confusing. I would suggest the following order (basically moving Device to the front):

  • Device/VM
  • Name
  • Type
  • Connection status
  • Cable

@candlerb
Copy link
Contributor

I would like to see MAC Address in a column, if only to be able to spot interfaces that haven't had MAC address recorded.

(Aside: it seems that connection status as an attribute of the interface is weird. It means it could be Planned at one end and Active at the other. Would it be better as an attribute of the cable?)

@darcynz
Copy link
Author

darcynz commented Nov 21, 2019 via email

@steffann
Copy link
Contributor

(Aside: it seems that connection status as an attribute of the interface is weird. It means it could be Planned at one end and Active at the other. Would it be better as an attribute of the cable?)

The attribute on the interface is basically a cache. It's set when any cable in the path is changed, and its value is based on the status of all the cables on the path. It will only show as connected if all cables are connected and there is a remote endpoint. So not as useless as it seems :)

@candlerb
Copy link
Contributor

I think description should be included. This would be consistent with /ipam/ipaddresses and /ipam/prefixes which also include description. /dcim/devices doesn't - but devices and VMs have "comments" rather than "description".

If screen estate is a problem, then one option would be switchable views:

  • a regular view with Device/VM, Name, Type, Description (Enabled?) (Mgmt Only?) (Cable?)
  • a technical view, with Device/VM, Name, Type, MTU, MAC address, VLAN mode, VLANs

@candlerb
Copy link
Contributor

Oh, and it would be great to see tags. However the other list views don't show tags either, so I guess that should be left out purely for consistency :-(

@DanSheps
Copy link
Member

I would like to see MAC Address in a column, if only to be able to spot interfaces that haven't had MAC address recorded.

I am trying to keep the view very generic at this point in time. In the future we can look at expanding the columns.

If screen estate is a problem, then one option would be switchable views:

This is going to be beyond the scope of the current issue. This would have to wait, most likely for a major UI revamp.

Oh, and it would be great to see tags. However the other list views don't show tags either, so I guess that should be left out purely for consistency :-(

This is going to maintain consistency with other list views more or less.

DanSheps added a commit to DanSheps/netbox that referenced this issue Nov 25, 2019
@jeremystretch
Copy link
Member

Regarding tags: I agree that it would nice to include them, but right now we're constrained by the use of HTML tables for most object lists. Ideally, tags should appear below the standard fields to ensure they don't force excessive wrapping of other fields. This would be best approached by converting to a more flexible rendering mechanism, but obviously that won't be trivial as it likely entails ditching django-tables2.

DanSheps added a commit to DanSheps/netbox that referenced this issue Nov 25, 2019
DanSheps added a commit to DanSheps/netbox that referenced this issue Nov 25, 2019
DanSheps added a commit to DanSheps/netbox that referenced this issue Nov 25, 2019
@DanSheps
Copy link
Member

DanSheps commented Nov 25, 2019

For everything except for interfaces and device bays, the following columns are used: 'pk', 'device', 'name', 'type', 'description', 'cable'

For interfaces: 'pk', 'parent', 'name', 'type', 'description', 'cable'

For device bays: 'pk', 'name', 'device', 'installed_device'

Ports are ordered by either device or parent

DanSheps added a commit to DanSheps/netbox that referenced this issue Dec 5, 2019
DanSheps added a commit to DanSheps/netbox that referenced this issue Dec 5, 2019
jeremystretch pushed a commit that referenced this issue Dec 5, 2019
* Initial Work on #3564

* #3564 - Fixup issue with filter on interface

* #3564 - Fix PEP8 errors

* #3564 - Finalize fields, readjust order, reduce repetition

* #3564 - Update Changelog

* #3564 - Fix extra space

* #3564 - Change interface table ordering

* #3564 - Minor cleanup

* #3564 - Add Import Links

* Fix PEP8
@lock lock bot locked as resolved and limited conversation to collaborators Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

8 participants