constants: Rename QR_OP_*, add QR_VIA_RAPI
authorMichael Hanselmann <hansmi@google.com>
Fri, 11 Mar 2011 13:26:17 +0000 (14:26 +0100)
committerMichael Hanselmann <hansmi@google.com>
Tue, 15 Mar 2011 13:04:08 +0000 (14:04 +0100)
Commit 28b71a76 added a list of resources which can be queried using
LUXI. Unfortunately the variable was named “QR_OP_LUXI”, which can be
confusing. This patch renames “QR_OP_QUERY” to “QR_VIA_OP”, “QR_OP_LUXI”
to “QR_VIA_LUXI” and adds a new variable, currently equal to
“QR_VIA_LUXI”, for remote API queries (mostly for documentation).

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

lib/cli.py
lib/cmdlib.py
lib/constants.py
lib/luxi.py
lib/opcodes.py
lib/server/masterd.py
test/ganeti.cmdlib_unittest.py

index 98add1b..7fc8d05 100644 (file)
@@ -2556,7 +2556,7 @@ def GenericList(resource, fields, names, unit, separator, header, cl=None,
                 format_override=None, verbose=False):
   """Generic implementation for listing all items of a resource.
 
-  @param resource: One of L{constants.QR_OP_LUXI}
+  @param resource: One of L{constants.QR_VIA_LUXI}
   @type fields: list of strings
   @param fields: List of fields to query for
   @type names: list of strings
@@ -2607,7 +2607,7 @@ def GenericList(resource, fields, names, unit, separator, header, cl=None,
 def GenericListFields(resource, fields, separator, header, cl=None):
   """Generic implementation for listing fields for a resource.
 
-  @param resource: One of L{constants.QR_OP_LUXI}
+  @param resource: One of L{constants.QR_VIA_LUXI}
   @type fields: list of strings
   @param fields: List of fields to query for
   @type separator: string or None
index c628a6e..8949c54 100644 (file)
@@ -11694,13 +11694,13 @@ _QUERY_IMPL = {
   constants.QR_OS: _OsQuery,
   }
 
-assert set(_QUERY_IMPL.keys()) == constants.QR_OP_QUERY
+assert set(_QUERY_IMPL.keys()) == constants.QR_VIA_OP
 
 
 def _GetQueryImplementation(name):
   """Returns the implemtnation for a query type.
 
-  @param name: Query type, must be one of L{constants.QR_OP_QUERY}
+  @param name: Query type, must be one of L{constants.QR_VIA_OP}
 
   """
   try:
index 0560dec..2ae1a43 100644 (file)
@@ -1030,13 +1030,16 @@ QR_GROUP = "group"
 QR_OS = "os"
 
 #: List of resources which can be queried using L{opcodes.OpQuery}
-QR_OP_QUERY = frozenset([QR_INSTANCE, QR_NODE, QR_GROUP, QR_OS])
+QR_VIA_OP = frozenset([QR_INSTANCE, QR_NODE, QR_GROUP, QR_OS])
 
 #: List of resources which can be queried using Local UniX Interface
-QR_OP_LUXI = QR_OP_QUERY.union([
+QR_VIA_LUXI = QR_VIA_OP.union([
   QR_LOCK,
   ])
 
+#: List of resources which can be queried using RAPI
+QR_VIA_RAPI = QR_VIA_LUXI
+
 # Query field types
 QFT_UNKNOWN = "unknown"
 QFT_TEXT = "text"
index 77532cf..66a886e 100644 (file)
@@ -500,7 +500,7 @@ class Client(object):
   def Query(self, what, fields, filter_):
     """Query for resources/items.
 
-    @param what: One of L{constants.QR_OP_LUXI}
+    @param what: One of L{constants.QR_VIA_LUXI}
     @type fields: List of strings
     @param fields: List of requested fields
     @type filter_: None or list
@@ -515,7 +515,7 @@ class Client(object):
   def QueryFields(self, what, fields):
     """Query for available fields.
 
-    @param what: One of L{constants.QR_OP_LUXI}
+    @param what: One of L{constants.QR_VIA_LUXI}
     @type fields: None or list of strings
     @param fields: List of requested fields
     @rtype: L{objects.QueryFieldsResponse}
index acace93..c711046 100644 (file)
@@ -109,7 +109,7 @@ _PNodeGroupAllocPolicy = \
 _PGroupNodeParams = ("ndparams", None, ht.TMaybeDict,
                      "Default node parameters for group")
 
-_PQueryWhat = ("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY),
+_PQueryWhat = ("what", ht.NoDefault, ht.TElemOf(constants.QR_VIA_OP),
                "Resource(s) to query for")
 
 _PIpCheckDoc = "Whether to ensure instance's IP address is inactive"
@@ -641,7 +641,7 @@ class OpClusterRedistConf(OpCode):
 class OpQuery(OpCode):
   """Query for resources/items.
 
-  @ivar what: Resources to query for, must be one of L{constants.QR_OP_QUERY}
+  @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP}
   @ivar fields: List of fields to retrieve
   @ivar filter: Query filter
 
@@ -659,7 +659,7 @@ class OpQuery(OpCode):
 class OpQueryFields(OpCode):
   """Query for available resource/item fields.
 
-  @ivar what: Resources to query for, must be one of L{constants.QR_OP_QUERY}
+  @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP}
   @ivar fields: List of fields to retrieve
 
   """
index 72b1466..89d6b3c 100644 (file)
@@ -232,14 +232,14 @@ class ClientOps:
     elif method == luxi.REQ_QUERY:
       req = objects.QueryRequest.FromDict(args)
 
-      if req.what in constants.QR_OP_QUERY:
+      if req.what in constants.QR_VIA_OP:
         result = self._Query(opcodes.OpQuery(what=req.what, fields=req.fields,
                                              filter=req.filter))
       elif req.what == constants.QR_LOCK:
         if req.filter is not None:
           raise errors.OpPrereqError("Lock queries can't be filtered")
         return self.server.context.glm.QueryLocks(req.fields)
-      elif req.what in constants.QR_OP_LUXI:
+      elif req.what in constants.QR_VIA_LUXI:
         raise NotImplementedError
       else:
         raise errors.OpPrereqError("Resource type '%s' unknown" % req.what,
@@ -250,12 +250,12 @@ class ClientOps:
     elif method == luxi.REQ_QUERY_FIELDS:
       req = objects.QueryFieldsRequest.FromDict(args)
 
-      if req.what in constants.QR_OP_QUERY:
+      if req.what in constants.QR_VIA_OP:
         result = self._Query(opcodes.OpQueryFields(what=req.what,
                                                    fields=req.fields))
       elif req.what == constants.QR_LOCK:
         return query.QueryFields(query.LOCK_FIELDS, req.fields)
-      elif req.what in constants.QR_OP_LUXI:
+      elif req.what in constants.QR_VIA_LUXI:
         raise NotImplementedError
       else:
         raise errors.OpPrereqError("Resource type '%s' unknown" % req.what,
index 4404d80..65ac193 100755 (executable)
@@ -143,12 +143,12 @@ class TestLUTestJqueue(unittest.TestCase):
 class TestLUQuery(unittest.TestCase):
   def test(self):
     self.assertEqual(sorted(cmdlib._QUERY_IMPL.keys()),
-                     sorted(constants.QR_OP_QUERY))
+                     sorted(constants.QR_VIA_OP))
 
-    assert constants.QR_NODE in constants.QR_OP_QUERY
-    assert constants.QR_INSTANCE in constants.QR_OP_QUERY
+    assert constants.QR_NODE in constants.QR_VIA_OP
+    assert constants.QR_INSTANCE in constants.QR_VIA_OP
 
-    for i in constants.QR_OP_QUERY:
+    for i in constants.QR_VIA_OP:
       self.assert_(cmdlib._GetQueryImplementation(i))
 
     self.assertRaises(errors.OpPrereqError, cmdlib._GetQueryImplementation, "")