Feature #185
closedQuery "and not"
Description
We need to be able to query for "class foo AND NOT class bar AND NOT class baz..."
Updated by Ohad Levy almost 15 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.
Updated by Dis Connect almost 15 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 :) ..)
Updated by Ohad Levy almost 15 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 ;)
Updated by Dis Connect over 14 years ago
- 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
Updated by Dis Connect over 14 years ago
[[http://www.davebalmain.com/api/classes/Ferret/QueryParser.html]] A query language that would add a ton of flexibility to foreman.
Updated by Ohad Levy over 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