Revision 16629d10 lib/qlang.py

b/lib/qlang.py
38 38

  
39 39
from ganeti import errors
40 40
from ganeti import netutils
41
from ganeti import utils
41 42

  
42 43

  
43 44
# Logic operators with one or more operands, each of which is a filter on its
......
146 147
  number = pyp.Combine(pyp.Optional(num_sign) + pyp.Word(pyp.nums))
147 148
  number.setParseAction(lambda toks: int(toks[0]))
148 149

  
150
  quoted_string = pyp.quotedString.copy().setParseAction(pyp.removeQuotes)
151

  
149 152
  # Right-hand-side value
150
  rval = (number | pyp.quotedString.setParseAction(pyp.removeQuotes))
153
  rval = (number | quoted_string)
151 154

  
152 155
  # Boolean condition
153 156
  bool_cond = field_name.copy()
......
184 187
  not_regexp_cond.setParseAction(lambda (field, value):
185 188
                                 [[OP_NOT, [OP_REGEXP, field, value]]])
186 189

  
190
  # Globbing, e.g. name =* "*.site"
191
  glob_cond = (field_name + pyp.Suppress("=*") + quoted_string)
192
  glob_cond.setParseAction(lambda (field, value):
193
                           [[OP_REGEXP, field,
194
                             utils.DnsNameGlobPattern(value)]])
195

  
196
  not_glob_cond = (field_name + pyp.Suppress("!*") + quoted_string)
197
  not_glob_cond.setParseAction(lambda (field, value):
198
                               [[OP_NOT, [OP_REGEXP, field,
199
                                          utils.DnsNameGlobPattern(value)]]])
200

  
187 201
  # All possible conditions
188 202
  condition = (binary_cond ^ bool_cond ^
189 203
               in_cond ^ not_in_cond ^
190
               regexp_cond ^ not_regexp_cond)
204
               regexp_cond ^ not_regexp_cond ^
205
               glob_cond ^ not_glob_cond)
191 206

  
192 207
  # Associativity operators
193 208
  filter_expr = pyp.operatorPrecedence(condition, [

Also available in: Unified diff