Project

General

Profile

Actions

Feature #19680

open

Search fact_values for hosts with fact1 AND fact2

Added by Matteo Castellarin almost 7 years ago. Updated almost 7 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Search
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

It is possible to fetch selected facts from Foreman for all the machines with the command below:

  • curl -k -i -u '' "https://foreman.company.com/api/v2/fact_values?search=name%3Dvmware%3A%3Atemplate%20or%20project%3A%3Aname&per_page=10000"
Such command filters the two following facts:
  • vmware::template
    
  • project::name
    

Where the "encoded URL" provided is:

name=vmware::template or name=project::name

Question is...
The "or" clause (that we are using) works as expected, while the "and" clause surprisingly does not. Is this a known limitation? How can one query an "and" clause?

Actions #1

Updated by Dominic Cleal almost 7 years ago

  • Subject changed from Augeas AND clause not working? to Fact values search AND clause not working?
  • Category set to Search
  • Status changed from New to Need more information

Searching for a fact with name "one AND two" isn't really a valid query, there wouldn't be a fact with two names. Searching for fact "one OR two" returns facts with either name. What did you expect it to return?

Actions #2

Updated by Matteo Castellarin almost 7 years ago

Dominic Cleal wrote:

Searching for a fact with name "one AND two" isn't really a valid query, there wouldn't be a fact with two names. Searching for fact "one OR two" returns facts with either name. What did you expect it to return?

Hi Dominic

On the fact_values endpoint I am looking for all machines having fact one having an X value and fact two having a Y value.
This works perfectly with the OR clause, but the AND clause does not accept it.
Am I doing something wrong?

Actions #3

Updated by Dominic Cleal almost 7 years ago

  • Tracker changed from Bug to Feature
  • Subject changed from Fact values search AND clause not working? to Search fact_values for hosts with fact1 AND fact2
  • Status changed from Need more information to New

The fact_values search doesn't permit searching for hosts with certain facts (as you're attempting), it is searching for facts only. Its search doesn't have the option to filter by hosts with multiple facts.

Actions

Also available in: Atom PDF