Revision abd66bf8

b/lib/cli.py
2556 2556
                format_override=None, verbose=False):
2557 2557
  """Generic implementation for listing all items of a resource.
2558 2558

  
2559
  @param resource: One of L{constants.QR_OP_LUXI}
2559
  @param resource: One of L{constants.QR_VIA_LUXI}
2560 2560
  @type fields: list of strings
2561 2561
  @param fields: List of fields to query for
2562 2562
  @type names: list of strings
......
2607 2607
def GenericListFields(resource, fields, separator, header, cl=None):
2608 2608
  """Generic implementation for listing fields for a resource.
2609 2609

  
2610
  @param resource: One of L{constants.QR_OP_LUXI}
2610
  @param resource: One of L{constants.QR_VIA_LUXI}
2611 2611
  @type fields: list of strings
2612 2612
  @param fields: List of fields to query for
2613 2613
  @type separator: string or None
b/lib/cmdlib.py
11694 11694
  constants.QR_OS: _OsQuery,
11695 11695
  }
11696 11696

  
11697
assert set(_QUERY_IMPL.keys()) == constants.QR_OP_QUERY
11697
assert set(_QUERY_IMPL.keys()) == constants.QR_VIA_OP
11698 11698

  
11699 11699

  
11700 11700
def _GetQueryImplementation(name):
11701 11701
  """Returns the implemtnation for a query type.
11702 11702

  
11703
  @param name: Query type, must be one of L{constants.QR_OP_QUERY}
11703
  @param name: Query type, must be one of L{constants.QR_VIA_OP}
11704 11704

  
11705 11705
  """
11706 11706
  try:
b/lib/constants.py
1030 1030
QR_OS = "os"
1031 1031

  
1032 1032
#: List of resources which can be queried using L{opcodes.OpQuery}
1033
QR_OP_QUERY = frozenset([QR_INSTANCE, QR_NODE, QR_GROUP, QR_OS])
1033
QR_VIA_OP = frozenset([QR_INSTANCE, QR_NODE, QR_GROUP, QR_OS])
1034 1034

  
1035 1035
#: List of resources which can be queried using Local UniX Interface
1036
QR_OP_LUXI = QR_OP_QUERY.union([
1036
QR_VIA_LUXI = QR_VIA_OP.union([
1037 1037
  QR_LOCK,
1038 1038
  ])
1039 1039

  
1040
#: List of resources which can be queried using RAPI
1041
QR_VIA_RAPI = QR_VIA_LUXI
1042

  
1040 1043
# Query field types
1041 1044
QFT_UNKNOWN = "unknown"
1042 1045
QFT_TEXT = "text"
b/lib/luxi.py
500 500
  def Query(self, what, fields, filter_):
501 501
    """Query for resources/items.
502 502

  
503
    @param what: One of L{constants.QR_OP_LUXI}
503
    @param what: One of L{constants.QR_VIA_LUXI}
504 504
    @type fields: List of strings
505 505
    @param fields: List of requested fields
506 506
    @type filter_: None or list
......
515 515
  def QueryFields(self, what, fields):
516 516
    """Query for available fields.
517 517

  
518
    @param what: One of L{constants.QR_OP_LUXI}
518
    @param what: One of L{constants.QR_VIA_LUXI}
519 519
    @type fields: None or list of strings
520 520
    @param fields: List of requested fields
521 521
    @rtype: L{objects.QueryFieldsResponse}
b/lib/opcodes.py
109 109
_PGroupNodeParams = ("ndparams", None, ht.TMaybeDict,
110 110
                     "Default node parameters for group")
111 111

  
112
_PQueryWhat = ("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY),
112
_PQueryWhat = ("what", ht.NoDefault, ht.TElemOf(constants.QR_VIA_OP),
113 113
               "Resource(s) to query for")
114 114

  
115 115
_PIpCheckDoc = "Whether to ensure instance's IP address is inactive"
......
641 641
class OpQuery(OpCode):
642 642
  """Query for resources/items.
643 643

  
644
  @ivar what: Resources to query for, must be one of L{constants.QR_OP_QUERY}
644
  @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP}
645 645
  @ivar fields: List of fields to retrieve
646 646
  @ivar filter: Query filter
647 647

  
......
659 659
class OpQueryFields(OpCode):
660 660
  """Query for available resource/item fields.
661 661

  
662
  @ivar what: Resources to query for, must be one of L{constants.QR_OP_QUERY}
662
  @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP}
663 663
  @ivar fields: List of fields to retrieve
664 664

  
665 665
  """
b/lib/server/masterd.py
232 232
    elif method == luxi.REQ_QUERY:
233 233
      req = objects.QueryRequest.FromDict(args)
234 234

  
235
      if req.what in constants.QR_OP_QUERY:
235
      if req.what in constants.QR_VIA_OP:
236 236
        result = self._Query(opcodes.OpQuery(what=req.what, fields=req.fields,
237 237
                                             filter=req.filter))
238 238
      elif req.what == constants.QR_LOCK:
239 239
        if req.filter is not None:
240 240
          raise errors.OpPrereqError("Lock queries can't be filtered")
241 241
        return self.server.context.glm.QueryLocks(req.fields)
242
      elif req.what in constants.QR_OP_LUXI:
242
      elif req.what in constants.QR_VIA_LUXI:
243 243
        raise NotImplementedError
244 244
      else:
245 245
        raise errors.OpPrereqError("Resource type '%s' unknown" % req.what,
......
250 250
    elif method == luxi.REQ_QUERY_FIELDS:
251 251
      req = objects.QueryFieldsRequest.FromDict(args)
252 252

  
253
      if req.what in constants.QR_OP_QUERY:
253
      if req.what in constants.QR_VIA_OP:
254 254
        result = self._Query(opcodes.OpQueryFields(what=req.what,
255 255
                                                   fields=req.fields))
256 256
      elif req.what == constants.QR_LOCK:
257 257
        return query.QueryFields(query.LOCK_FIELDS, req.fields)
258
      elif req.what in constants.QR_OP_LUXI:
258
      elif req.what in constants.QR_VIA_LUXI:
259 259
        raise NotImplementedError
260 260
      else:
261 261
        raise errors.OpPrereqError("Resource type '%s' unknown" % req.what,
b/test/ganeti.cmdlib_unittest.py
143 143
class TestLUQuery(unittest.TestCase):
144 144
  def test(self):
145 145
    self.assertEqual(sorted(cmdlib._QUERY_IMPL.keys()),
146
                     sorted(constants.QR_OP_QUERY))
146
                     sorted(constants.QR_VIA_OP))
147 147

  
148
    assert constants.QR_NODE in constants.QR_OP_QUERY
149
    assert constants.QR_INSTANCE in constants.QR_OP_QUERY
148
    assert constants.QR_NODE in constants.QR_VIA_OP
149
    assert constants.QR_INSTANCE in constants.QR_VIA_OP
150 150

  
151
    for i in constants.QR_OP_QUERY:
151
    for i in constants.QR_VIA_OP:
152 152
      self.assert_(cmdlib._GetQueryImplementation(i))
153 153

  
154 154
    self.assertRaises(errors.OpPrereqError, cmdlib._GetQueryImplementation, "")

Also available in: Unified diff