Revision 5c98b73e

b/lib/cmdlib/__init__.py
89 89
  LUInstanceReboot, \
90 90
  LUInstanceConsole
91 91
from ganeti.cmdlib.instance_query import \
92
  LUInstanceQuery, \
93 92
  LUInstanceQueryData
94 93
from ganeti.cmdlib.backup import \
95 94
  LUBackupPrepare, \
b/lib/cmdlib/instance_query.py
26 26
from ganeti import compat
27 27
from ganeti import constants
28 28
from ganeti import locking
29
from ganeti import query
30
from ganeti.cmdlib.base import QueryBase, NoHooksLU
29
from ganeti.cmdlib.base import NoHooksLU
31 30
from ganeti.cmdlib.common import ShareAll, GetWantedInstances, \
32 31
  CheckInstancesNodeGroups, AnnotateDiskParams
33 32
from ganeti.cmdlib.instance_utils import NICListToTuple
34 33
from ganeti.hypervisor import hv_base
35 34

  
36 35

  
37

  
38
class InstanceQuery(QueryBase):
39
  FIELDS = query.INSTANCE_FIELDS
40

  
41
  def ExpandNames(self, lu):
42
    raise NotImplementedError
43

  
44
  def DeclareLocks(self, lu, level):
45
    raise NotImplementedError
46

  
47

  
48
class LUInstanceQuery(NoHooksLU):
49
  """Logical unit for querying instances.
50

  
51
  """
52
  # pylint: disable=W0142
53
  REQ_BGL = False
54

  
55
  def CheckArguments(self):
56
    raise NotImplementedError
57

  
58
  def ExpandNames(self):
59
    raise NotImplementedError
60

  
61
  def DeclareLocks(self, level):
62
    raise NotImplementedError
63

  
64
  def Exec(self, feedback_fn):
65
    raise NotImplementedError
66

  
67

  
68 36
class LUInstanceQueryData(NoHooksLU):
69 37
  """Query runtime instance data.
70 38

  
b/lib/rapi/rlib2.py
886 886
  """/2/instances resource.
887 887

  
888 888
  """
889
  GET_OPCODE = opcodes.OpInstanceQuery
890 889
  POST_OPCODE = opcodes.OpInstanceCreate
891 890
  POST_RENAME = {
892 891
    "os": "os_type",
......
970 969
  """/2/instances/[instance_name] resource.
971 970

  
972 971
  """
973
  GET_OPCODE = opcodes.OpInstanceQuery
974 972
  DELETE_OPCODE = opcodes.OpInstanceRemove
975 973

  
976 974
  def GET(self):
b/lib/server/masterd.py
390 390
      logging.info("Received job query request for %s", msg)
391 391
      return queue.OldStyleQueryJobs(job_ids, fields)
392 392

  
393
    elif method == luxi.REQ_QUERY_INSTANCES:
394
      (names, fields, use_locking) = args
395
      logging.info("Received instance query request for %s", names)
396
      if use_locking:
397
        raise errors.OpPrereqError("Sync queries are not allowed",
398
                                   errors.ECODE_INVAL)
399
      op = opcodes.OpInstanceQuery(names=names, output_fields=fields,
400
                                   use_locking=use_locking)
401
      return self._Query(op)
402

  
403 393
    elif method == luxi.REQ_QUERY_CONFIG_VALUES:
404 394
      (fields, ) = args
405 395
      logging.info("Received config values query request for %s", fields)
b/src/Ganeti/OpCodes.hs
609 609
     , pIallocator
610 610
     ],
611 611
     "instance_name")
612
  , ("OpInstanceQuery",
613
     [t| [[JSValue]] |],
614
     OpDoc.opInstanceQuery,
615
     [ pOutputFields
616
     , pUseLocking
617
     , withDoc
618
       "Empty list to query all instances, instance names otherwise"
619
       pNames
620
     ],
621
     [])
622 612
  , ("OpInstanceQueryData",
623 613
     [t| JSObject (JSObject JSValue) |],
624 614
     OpDoc.opInstanceQueryData,

Also available in: Unified diff