Commit fbeb41e6 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

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: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent 44ffd981
......@@ -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):
......
......@@ -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
......
......@@ -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
......
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment