netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Expand search to description and comment fields

Open JosephRPalmer opened this issue 10 years ago • 9 comments

It would be great if IPs were searchable by description for implementations with large numbers of IP addresses.

JosephRPalmer avatar Jul 21 '16 15:07 JosephRPalmer

This probably ties int #166

ryanmerolle avatar Jul 21 '16 16:07 ryanmerolle

Yes, this would be great!

farewelldave avatar Jul 21 '16 19:07 farewelldave

I just hit this while trying the demo, the search should be really flexible IMHO, almost google like. No matter what you search you should get results in all fields and categories, saving you search in different fields, or making mistakes.

malaiam avatar Jul 27 '16 13:07 malaiam

I've expanded the scope of this issue to include all objects.

jeremystretch avatar Jul 29 '16 15:07 jeremystretch

38aee33df01ccddb35607bebdbfe233f857c78dd added the following fields to the "q" search filter:

  • Circuits
    • Provider: comments
    • Ciruit: comments, pp_info, xconnect_id
  • DCIM
    • Site: comments
    • Rack: comments
    • Device: comments
  • IPAM
    • VRF: RD, description (new filter)
    • Aggregate: prefix, description (new filter)
    • Prefix: description
    • IPAddress: description
    • VLAN: VID, name, description (new filter)
  • Secrets
    • Secret: name, device.name (new filter)
  • Tenancy
    • Tenant: description, comments

jeremystretch avatar Jul 29 '16 16:07 jeremystretch

Thanks for adding additional search fields!

We are now using NetBox as a data source for provisioning system. We import server serial numbers and (pre-allocated) IP addresses into NetBox and boot bare-metal servers with PXE (with DHCP temporary IP addresses). A Python script in PXE live system would first collect server serial number (with dmidecode -s system-serial-number) before querying NetBox for permanent IP address of that server for provisioning purpose.

It would be great if serial number could be added as a search field for devices. Thanks!

wzyboy avatar Aug 02 '16 11:08 wzyboy

To be clear, I mean the /api/dcim/devices/ API.

wzyboy avatar Aug 02 '16 11:08 wzyboy

The fields I listed above are just the new additions. Serial has always been included in device search (also the serials of installed modules):

    def search(self, queryset, value):
        return queryset.filter(
            Q(name__icontains=value) |
            Q(serial__icontains=value) |
            Q(modules__serial__icontains=value) |
            Q(comments__icontains=value)
        ).distinct()

jeremystretch avatar Aug 02 '16 15:08 jeremystretch

Yes, I know I can generally search for foo and all devices with foo values would be returned in JSON. However, if device A has string foo in comments field and device B has string foo in serial field. Device A and B would both be returned when searching for foo. We had to manually check if foo appears in serial field. It would be nice if we can just search for foo in serial field.

wzyboy avatar Aug 03 '16 03:08 wzyboy