Through the UI - fact search -> show unique host results?

Hi folks,

I'm trying to figure out the equivalent of:

grep $value facts | print $hostnames | sort -u

That'll get us a list of hosts that all have $facts. We know for a fact (no
pun intended) that there's a potential for each host to have multiple facts
with $value (we're scanning for blockdevice models).

What does the Foreman UI give us? If we search for this in the facts pane:
facts.blockdevice_sda_model = SYMMETRIX or facts.blockdevice_sdb_model =
SYMMETRIX or (sdc, sdd, etc…)

We get a list that'll have $host1 in there once for every blockdevice that
matches. In our case, that means well over 100k matches (we have hosts with
lots of blockdevices :slight_smile: ). How can I apply a "unique" filter/modifier to
that so a host appears only once?

Some other considerations:

  • The people running this query do not have access to the Foreman DB
  • The do have access to the CLI/API, so we can always write a script
    that'll iterate through all the pages (hundreds of them).
  • We're running Foreman 1.12

Hi,

If I understand correctly what you are trying to do, you can run that
search on the host index page instead of on the facts page, and you will
only get the list of hosts matching the value.
That is also possible by passing the search string as a parameter to the
api/cli (for the host list) for automation.

··· On Wed, Mar 1, 2017 at 5:05 PM, Chris Baldwin wrote:

Hi folks,

I’m trying to figure out the equivalent of:

grep $value facts | print $hostnames | sort -u

That’ll get us a list of hosts that all have $facts. We know for a fact
(no pun intended) that there’s a potential for each host to have multiple
facts with $value (we’re scanning for blockdevice models).

What does the Foreman UI give us? If we search for this in the facts pane:
facts.blockdevice_sda_model = SYMMETRIX or facts.blockdevice_sdb_model =
SYMMETRIX or (sdc, sdd, etc…)

We get a list that’ll have $host1 in there once for every blockdevice that
matches. In our case, that means well over 100k matches (we have hosts with
lots of blockdevices :slight_smile: ). How can I apply a “unique” filter/modifier to
that so a host appears only once?

Some other considerations:

  • The people running this query do not have access to the Foreman DB
  • The do have access to the CLI/API, so we can always write a script
    that’ll iterate through all the pages (hundreds of them).
  • We’re running Foreman 1.12


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


Have a nice day,
Tomer Brisker
Red Hat Engineering

Hi,

Thanks for the suggestion! It didn't work as expected though.

Doing this in a dev environment with ~40 hosts, I searched for this:
facts.blockdevice_sda_model ~ Virtual or facts.blockdevice_sdb_model ~
Virtual or facts.blockdevice_sdc_model ~ Virtual

In the 'facts' page, that would give me multiple matches per host.
In the 'hosts' page, it gives me one match per ???. To illustrate:

The search in 'facts':
Displaying entries 1 - 50 of 51 in total

··· -

The same search in ‘hosts’:
Displaying entries 1 - 50 of 697710 in total - 0 selected

Searching in hosts didn’t solve this :frowning:

-Chris

On Wednesday, March 1, 2017 at 10:14:55 AM UTC-5, Tomer Brisker wrote:

Hi,

If I understand correctly what you are trying to do, you can run that
search on the host index page instead of on the facts page, and you will
only get the list of hosts matching the value.
That is also possible by passing the search string as a parameter to the
api/cli (for the host list) for automation.

On Wed, Mar 1, 2017 at 5:05 PM, Chris Baldwin <ooga...@gmail.com > <javascript:>> wrote:

Hi folks,

I’m trying to figure out the equivalent of:

grep $value facts | print $hostnames | sort -u

That’ll get us a list of hosts that all have $facts. We know for a fact
(no pun intended) that there’s a potential for each host to have multiple
facts with $value (we’re scanning for blockdevice models).

What does the Foreman UI give us? If we search for this in the facts pane:
facts.blockdevice_sda_model = SYMMETRIX or facts.blockdevice_sdb_model =
SYMMETRIX or (sdc, sdd, etc…)

We get a list that’ll have $host1 in there once for every blockdevice
that matches. In our case, that means well over 100k matches (we have hosts
with lots of blockdevices :slight_smile: ). How can I apply a “unique” filter/modifier
to that so a host appears only once?

Some other considerations:

  • The people running this query do not have access to the Foreman DB
  • The do have access to the CLI/API, so we can always write a script
    that’ll iterate through all the pages (hundreds of them).
  • We’re running Foreman 1.12


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-user...@googlegroups.com <javascript:>.
To post to this group, send email to forema...@googlegroups.com
<javascript:>.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


Have a nice day,
Tomer Brisker
Red Hat Engineering