Switch RAPI to use same tags listing as CLI
authorIustin Pop <iustin@google.com>
Sun, 19 Aug 2012 00:44:44 +0000 (02:44 +0200)
committerIustin Pop <iustin@google.com>
Tue, 28 Aug 2012 15:02:45 +0000 (17:02 +0200)
Currently, RAPI uses queries (as in QueryNode with field tags) for
getting the tags, whereas the CLI uses the QueryTags Luxi
command. Since this discrepancy is not good, let's switch RAPI to use
the same method as the CLI.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

lib/rapi/rlib2.py

index e434340..addb938 100644 (file)
@@ -1340,16 +1340,7 @@ class _R_Tags(baserlib.OpcodeResource):
         raise http.HttpBadRequest("Missing name on tag request")
 
       cl = self.GetClient()
-      if kind == constants.TAG_INSTANCE:
-        fn = cl.QueryInstances
-      elif kind == constants.TAG_NODEGROUP:
-        fn = cl.QueryGroups
-      else:
-        fn = cl.QueryNodes
-      result = fn(names=[self.name], fields=["tags"], use_locking=False)
-      if not result or not result[0]:
-        raise http.HttpBadGateway("Invalid response from tag query")
-      tags = result[0][0]
+      tags = list(cl.QueryTags(kind, self.name))
 
     elif kind == constants.TAG_CLUSTER:
       assert not self.name