commit fbeb41e66d4330b81750832c36f468c0c658247d
Author: Helga Velroyen <helgav@google.com>
Date:   Fri Nov 15 09:48:26 2013 +0100

    Switch to haskell for export (aka backup) queries
    
    This patch removes the python implementation of export
    (aka backup) queries. So far, it is replaced by
    'NotImplemented' exceptions, but later in this series
    it will be replaced completely.
    
    Signed-off-by: Helga Velroyen <helgav@google.com>
    Reviewed-by: Hrvoje Ribicic <riba@google.com>

diff --git a/lib/cmdlib/backup.py b/lib/cmdlib/backup.py
index 0054817..14b88ed 100644
--- a/lib/cmdlib/backup.py
+++ b/lib/cmdlib/backup.py
@@ -29,12 +29,11 @@ from ganeti import constants
 from ganeti import errors
 from ganeti import locking
 from ganeti import masterd
-from ganeti import qlang
 from ganeti import query
 from ganeti import utils
 
 from ganeti.cmdlib.base import QueryBase, NoHooksLU, LogicalUnit
-from ganeti.cmdlib.common import GetWantedNodes, ShareAll, CheckNodeOnline, \
+from ganeti.cmdlib.common import CheckNodeOnline, \
   ExpandNodeUuidAndName
 from ganeti.cmdlib.instance_storage import StartInstanceDisks, \
   ShutdownInstanceDisks
@@ -49,50 +48,13 @@ class ExportQuery(QueryBase):
   SORT_FIELD = "node"
 
   def ExpandNames(self, lu):
-    lu.needed_locks = {}
-
-    # The following variables interact with _QueryBase._GetNames
-    if self.names:
-      (self.wanted, _) = GetWantedNodes(lu, self.names)
-    else:
-      self.wanted = locking.ALL_SET
-
-    self.do_locking = self.use_locking
-
-    if self.do_locking:
-      lu.share_locks = ShareAll()
-      lu.needed_locks = {
-        locking.LEVEL_NODE: self.wanted,
-        }
-
-      if not self.names:
-        lu.needed_locks[locking.LEVEL_NODE_ALLOC] = locking.ALL_SET
+    raise NotImplementedError
 
   def DeclareLocks(self, lu, level):
     pass
 
   def _GetQueryData(self, lu):
-    """Computes the list of nodes and their attributes.
-
-    """
-    # Locking is not used
-    # TODO
-    assert not (compat.any(lu.glm.is_owned(level)
-                           for level in locking.LEVELS
-                           if level != locking.LEVEL_CLUSTER) or
-                self.do_locking or self.use_locking)
-
-    node_uuids = self._GetNames(lu, lu.cfg.GetNodeList(), locking.LEVEL_NODE)
-
-    result = []
-    for (node_uuid, nres) in lu.rpc.call_export_list(node_uuids).items():
-      node = lu.cfg.GetNodeInfo(node_uuid)
-      if nres.fail_msg:
-        result.append((node.name, None))
-      else:
-        result.extend((node.name, expname) for expname in nres.payload)
-
-    return result
+    raise NotImplementedError
 
 
 class LUBackupQuery(NoHooksLU):
@@ -102,25 +64,16 @@ class LUBackupQuery(NoHooksLU):
   REQ_BGL = False
 
   def CheckArguments(self):
-    self.expq = ExportQuery(qlang.MakeSimpleFilter("node", self.op.nodes),
-                            ["node", "export"], self.op.use_locking)
+    raise NotImplementedError
 
   def ExpandNames(self):
-    self.expq.ExpandNames(self)
+    raise NotImplementedError
 
   def DeclareLocks(self, level):
-    self.expq.DeclareLocks(self, level)
+    raise NotImplementedError
 
   def Exec(self, feedback_fn):
-    result = {}
-
-    for (node, expname) in self.expq.OldStyleQuery(self):
-      if expname is None:
-        result[node] = False
-      else:
-        result.setdefault(node, []).append(expname)
-
-    return result
+    raise NotImplementedError
 
 
 class LUBackupPrepare(NoHooksLU):
diff --git a/lib/cmdlib/query.py b/lib/cmdlib/query.py
index abf6504..a46f7c3 100644
--- a/lib/cmdlib/query.py
+++ b/lib/cmdlib/query.py
@@ -24,7 +24,6 @@
 from ganeti import constants
 from ganeti import errors
 from ganeti import query
-from ganeti.cmdlib.backup import ExportQuery
 from ganeti.cmdlib.base import NoHooksLU
 from ganeti.cmdlib.cluster import ClusterQuery
 from ganeti.cmdlib.group import GroupQuery
@@ -40,7 +39,6 @@ _QUERY_IMPL = {
   constants.QR_GROUP: GroupQuery,
   constants.QR_OS: OsQuery,
   constants.QR_EXTSTORAGE: ExtStorageQuery,
-  constants.QR_EXPORT: ExportQuery,
   }
 
 assert set(_QUERY_IMPL.keys()) == constants.QR_VIA_OP
diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs
index 1fbbdb2..8f7b705 100644
--- a/src/Ganeti/Constants.hs
+++ b/src/Ganeti/Constants.hs
@@ -3340,12 +3340,15 @@ qrViaOp =
                        qrInstance,
                        qrGroup,
                        qrOs,
-                       qrExport,
                        qrExtstorage]
 
 -- | List of resources which can be queried using Local UniX Interface
 qrViaLuxi :: FrozenSet String
-qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob, qrNode, qrNetwork]
+qrViaLuxi = ConstantUtils.mkSet [qrExport,
+                                 qrJob,
+                                 qrLock,
+                                 qrNetwork,
+                                 qrNode]
 
 -- | List of resources which can be queried using RAPI
 qrViaRapi :: FrozenSet String
diff --git a/test/py/cmdlib/backup_unittest.py b/test/py/cmdlib/backup_unittest.py
index 411f1ea..36fb409 100644
--- a/test/py/cmdlib/backup_unittest.py
+++ b/test/py/cmdlib/backup_unittest.py
@@ -31,46 +31,6 @@ from testsupport import *
 import testutils
 
 
-class TestLUBackupQuery(CmdlibTestCase):
-  def setUp(self):
-    super(TestLUBackupQuery, self).setUp()
-
-    self.fields = query._BuildExportFields().keys()
-
-  def testFailingExportList(self):
-    self.rpc.call_export_list.return_value = \
-      self.RpcResultsBuilder() \
-        .AddFailedNode(self.master) \
-        .Build()
-    op = opcodes.OpBackupQuery(nodes=[self.master.name])
-    ret = self.ExecOpCode(op)
-    self.assertEqual({self.master.name: False}, ret)
-
-  def testQueryOneNode(self):
-    self.rpc.call_export_list.return_value = \
-      self.RpcResultsBuilder() \
-        .AddSuccessfulNode(self.master,
-                           ["mock_export1", "mock_export2"]) \
-        .Build()
-    op = opcodes.OpBackupQuery(nodes=[self.master.name])
-    ret = self.ExecOpCode(op)
-    self.assertEqual({self.master.name: ["mock_export1", "mock_export2"]}, ret)
-
-  def testQueryAllNodes(self):
-    node = self.cfg.AddNewNode()
-    self.rpc.call_export_list.return_value = \
-      self.RpcResultsBuilder() \
-        .AddSuccessfulNode(self.master, ["mock_export1"]) \
-        .AddSuccessfulNode(node, ["mock_export2"]) \
-        .Build()
-    op = opcodes.OpBackupQuery()
-    ret = self.ExecOpCode(op)
-    self.assertEqual({
-                       self.master.name: ["mock_export1"],
-                       node.name: ["mock_export2"]
-                     }, ret)
-
-
 class TestLUBackupPrepare(CmdlibTestCase):
   @patchUtils("instance_utils")
   def testPrepareLocalExport(self, utils):
