Direct¶
Direct backend.
- cumin.backends.direct.grammar()[source]¶
Define the query grammar.
Backus-Naur form (BNF) of the grammar:
<grammar> ::= <item> | <item> <boolean> <grammar> <item> ::= <hosts> | "(" <grammar> ")" <boolean> ::= "and not" | "and" | "xor" | "or"
Given that the pyparsing library defines the grammar in a BNF-like style, for the details of the tokens not specified above check directly the source code.
- Returns:
the grammar parser.
- Return type:
- class cumin.backends.direct.DirectQuery(config)[source]¶
Bases:
BaseQueryAggregator
DirectQuery query builder.
The direct backend allow to use Cumin without any external dependency for the hosts selection. It allow to write arbitrarily complex queries with subgroups and boolean operators, but each item must be either the hostname itself, or the using host expansion using the powerful
ClusterShell.NodeSet.NodeSet
syntax.The typical usage for the direct backend is as a reliable alternative in cases in which the primary host selection mechanism is not working and also for testing the transports without any external backend dependency.
Some query examples:
Simple selection:
host1.domain
ClusterShell syntax for hosts expansion:
host10[10-42].domain,host2010.other-domain
A complex selection:
host100[1-5].domain or (host10[30-40].domain and (host10[10-42].domain and not host33.domain))
Query aggregator constructor, initialize the stack.
- Parameters:
according to parent
cumin.backends.BaseQuery.__init__()
.
- grammar = Forward: {Group:({{~{{{{'and not' | 'and'} | 'xor'} | 'or'}} W:(!&,-.0-9A-[]-...)} | {{'(' : ...} ')'}}) [Group:({{'and not' | 'and'} | 'xor'} | 'or'} {{~{{{{'and not' | 'and'} | 'xor'} | 'or'}} W:(!&,-.0-9A-[]-...)} | {{'(' : ...} ')'})]...}¶
load the grammar parser only once in a singleton-like way.
- Type:
- _parse_token(token)[source]¶
Concrete implementation of parent abstract method.
- Parameters:
according to parent
cumin.backends.BaseQueryAggregator._parse_token()
.
- cumin.backends.direct.GRAMMAR_PREFIX = 'D'¶
the prefix associate to this grammar, to register this backend into the general grammar. Required by the backend auto-loader in
cumin.grammar.get_registered_backends()
.- Type:
- cumin.backends.direct.query_class¶
Required by the backend auto-loader in
cumin.grammar.get_registered_backends()
.