Revision fbeb41e6 lib/cmdlib/backup.py
b/lib/cmdlib/backup.py | ||
---|---|---|
29 | 29 |
from ganeti import errors |
30 | 30 |
from ganeti import locking |
31 | 31 |
from ganeti import masterd |
32 |
from ganeti import qlang |
|
33 | 32 |
from ganeti import query |
34 | 33 |
from ganeti import utils |
35 | 34 |
|
36 | 35 |
from ganeti.cmdlib.base import QueryBase, NoHooksLU, LogicalUnit |
37 |
from ganeti.cmdlib.common import GetWantedNodes, ShareAll, CheckNodeOnline, \
|
|
36 |
from ganeti.cmdlib.common import CheckNodeOnline, \ |
|
38 | 37 |
ExpandNodeUuidAndName |
39 | 38 |
from ganeti.cmdlib.instance_storage import StartInstanceDisks, \ |
40 | 39 |
ShutdownInstanceDisks |
... | ... | |
49 | 48 |
SORT_FIELD = "node" |
50 | 49 |
|
51 | 50 |
def ExpandNames(self, lu): |
52 |
lu.needed_locks = {} |
|
53 |
|
|
54 |
# The following variables interact with _QueryBase._GetNames |
|
55 |
if self.names: |
|
56 |
(self.wanted, _) = GetWantedNodes(lu, self.names) |
|
57 |
else: |
|
58 |
self.wanted = locking.ALL_SET |
|
59 |
|
|
60 |
self.do_locking = self.use_locking |
|
61 |
|
|
62 |
if self.do_locking: |
|
63 |
lu.share_locks = ShareAll() |
|
64 |
lu.needed_locks = { |
|
65 |
locking.LEVEL_NODE: self.wanted, |
|
66 |
} |
|
67 |
|
|
68 |
if not self.names: |
|
69 |
lu.needed_locks[locking.LEVEL_NODE_ALLOC] = locking.ALL_SET |
|
51 |
raise NotImplementedError |
|
70 | 52 |
|
71 | 53 |
def DeclareLocks(self, lu, level): |
72 | 54 |
pass |
73 | 55 |
|
74 | 56 |
def _GetQueryData(self, lu): |
75 |
"""Computes the list of nodes and their attributes. |
|
76 |
|
|
77 |
""" |
|
78 |
# Locking is not used |
|
79 |
# TODO |
|
80 |
assert not (compat.any(lu.glm.is_owned(level) |
|
81 |
for level in locking.LEVELS |
|
82 |
if level != locking.LEVEL_CLUSTER) or |
|
83 |
self.do_locking or self.use_locking) |
|
84 |
|
|
85 |
node_uuids = self._GetNames(lu, lu.cfg.GetNodeList(), locking.LEVEL_NODE) |
|
86 |
|
|
87 |
result = [] |
|
88 |
for (node_uuid, nres) in lu.rpc.call_export_list(node_uuids).items(): |
|
89 |
node = lu.cfg.GetNodeInfo(node_uuid) |
|
90 |
if nres.fail_msg: |
|
91 |
result.append((node.name, None)) |
|
92 |
else: |
|
93 |
result.extend((node.name, expname) for expname in nres.payload) |
|
94 |
|
|
95 |
return result |
|
57 |
raise NotImplementedError |
|
96 | 58 |
|
97 | 59 |
|
98 | 60 |
class LUBackupQuery(NoHooksLU): |
... | ... | |
102 | 64 |
REQ_BGL = False |
103 | 65 |
|
104 | 66 |
def CheckArguments(self): |
105 |
self.expq = ExportQuery(qlang.MakeSimpleFilter("node", self.op.nodes), |
|
106 |
["node", "export"], self.op.use_locking) |
|
67 |
raise NotImplementedError |
|
107 | 68 |
|
108 | 69 |
def ExpandNames(self): |
109 |
self.expq.ExpandNames(self)
|
|
70 |
raise NotImplementedError
|
|
110 | 71 |
|
111 | 72 |
def DeclareLocks(self, level): |
112 |
self.expq.DeclareLocks(self, level)
|
|
73 |
raise NotImplementedError
|
|
113 | 74 |
|
114 | 75 |
def Exec(self, feedback_fn): |
115 |
result = {} |
|
116 |
|
|
117 |
for (node, expname) in self.expq.OldStyleQuery(self): |
|
118 |
if expname is None: |
|
119 |
result[node] = False |
|
120 |
else: |
|
121 |
result.setdefault(node, []).append(expname) |
|
122 |
|
|
123 |
return result |
|
76 |
raise NotImplementedError |
|
124 | 77 |
|
125 | 78 |
|
126 | 79 |
class LUBackupPrepare(NoHooksLU): |
Also available in: Unified diff