Project

General

Profile

Actions

Feature #185

closed

Query "and not"

Added by Dis Connect about 14 years ago. Updated about 13 years ago.

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

Description

We need to be able to query for "class foo AND NOT class bar AND NOT class baz..."


Related issues 1 (0 open1 closed)

Follows Foreman - Feature #719: Add new search functionailyClosedAmos Benari03/09/2011Actions
Actions #1

Updated by Ohad Levy about 14 years ago

a which work around is to call the gethosts method multiple times e.g.
for an AND operations

gethosts(...) & gethosts(...)

this basically returns an array, so you can use logical operators on them.

Actions #2

Updated by Dis Connect about 14 years ago

This is a usable workaround but it is pretty unpleasant.

The old iclassify scripts are simple one-liners:
QUERY="tag:appserver AND NOT tag:foo AND NOT tag:platform AND NOT..etc"

New ones look more like this: (use += for 'or')
hosts = gethosts( { "class" => "appserver" } )
hosts -= gethosts( {"class" => "platform" } )
hosts -= gethosts( {"class" => "foo" } )
...

Just fyi the 'and' case works works cleanly:
hosts=gethosts( { "class" => ["appserver","foo"] } )

(Extra detail in case anyone else stumbles across this bug report and needs a solution :) ..)

Actions #3

Updated by Ohad Levy about 14 years ago

Dis Connect wrote:

This is a usable workaround but it is pretty unpleasant.

The old iclassify scripts are simple one-liners:
QUERY="tag:appserver AND NOT tag:foo AND NOT tag:platform AND NOT..etc"

I just said its a work around for now :)

Just fyi the 'and' case works works cleanly:

yes I know - I did remember spending some time on getting it to work ;)

Actions #4

Updated by Dis Connect almost 14 years ago

Doesn't work with verbose. So a basic query to get 5 facts about host class 'foo' and not class 'bar' can hammer the foreman server half to death:
  • get all hosts 'foo'
  • get all hosts 'bar' and subtract
  • for all remaining hosts, query again by hostname, verbose.
  • operate on the facts you want

This doesn't even pretend to scale..

With 'and not':
  • get all hosts 'foo' and not 'bar', verbose
  • operate on the facts you want
Actions #5

Updated by Dis Connect almost 14 years ago

[[http://www.davebalmain.com/api/classes/Ferret/QueryParser.html]] A query language that would add a ton of flexibility to foreman.

Actions #6

Updated by Ohad Levy about 13 years ago

  • Category set to Search
  • Status changed from New to Closed
  • Assignee set to Ohad Levy
  • Target version set to 0.3

implemented as part of #719

Actions

Also available in: Atom PDF