Awx: Smart Inventory filters aren't working correctly when using the GUI

Created on 10 Jan 2018  ·  3Comments  ·  Source: ansible/awx

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • UI
SUMMARY

There is a difference in what filters can be used on the GUI to the API.
The GUI rejects valid options that the API accepts and are valid.

ENVIRONMENT
  • AWX version: 1.0.1.8
  • AWX install method: docker on linux
  • Ansible version: 2.4.0.0
STEPS TO REPRODUCE

Using the GUI, which fails:

  1. Create a new Smart Inventory
  2. Add a filter using "groups.name:GROUP1 or groups.name:GROUP2"

Using the API, which works:

  1. Browse to api/v2/inventories/
  2. POST:

{
"name": "Smart Inventory Test",
"description": "Testing",
"organization": 2,
"kind": "smart",
"host_filter": "groups__name=GROUP1 or groups__name=GROUP2",
"variables": "",
"insights_credential": null
}

EXPECTED RESULTS

GUI can use the same filters as the API.

ACTUAL RESULTS

The GUI failed to use the filter.

ADDITIONAL INFORMATION
ui low needs_devel bug

Most helpful comment

Really annoying I had this problem too and stuck with running curl requests to build my smart filters.
also this stupid syntax of __ is not very well explained
equivalent GUI examples are not provided.
We should not have to search though bug reports to find good examples of the syntax.

curl -sXPOST http://admin:blahblah@server/api/v2/inventories/ -d @smartfilter -H "Content-Type: application/json"

Smartfilter file

{
"name": "DEV Website Inventory",
"description": "All development servers ",
"organization": 1,
"kind": "smart",
"host_filter": "name__icontains=sd1d or name__icontains=sd2d or name__contains=hd1d",
"variables": "",
"insights_credential": null
}

image

Trying to do the same thing in the gui (its like it is splinting the search on a space token) but I
image

All 3 comments

+1
the same for:
/api/v2/hosts/?order_by=name&page_size=5&inventory__organization=2&host_filter=(search=HOSTNAME1%20or%20search=HOSTNAME2)

Really annoying I had this problem too and stuck with running curl requests to build my smart filters.
also this stupid syntax of __ is not very well explained
equivalent GUI examples are not provided.
We should not have to search though bug reports to find good examples of the syntax.

curl -sXPOST http://admin:blahblah@server/api/v2/inventories/ -d @smartfilter -H "Content-Type: application/json"

Smartfilter file

{
"name": "DEV Website Inventory",
"description": "All development servers ",
"organization": 1,
"kind": "smart",
"host_filter": "name__icontains=sd1d or name__icontains=sd2d or name__contains=hd1d",
"variables": "",
"insights_credential": null
}

image

Trying to do the same thing in the gui (its like it is splinting the search on a space token) but I
image

Was this page helpful?
0 / 5 - 0 ratings