Revision 0b38cf6e
b/lib/cmdlib.py | ||
---|---|---|
56 | 56 |
- redefine HPATH and HTYPE |
57 | 57 |
- optionally redefine their run requirements: |
58 | 58 |
REQ_MASTER: the LU needs to run on the master node |
59 |
REQ_WSSTORE: the LU needs a writable SimpleStore |
|
60 | 59 |
REQ_BGL: the LU needs to hold the Big Ganeti Lock exclusively |
61 | 60 |
|
62 | 61 |
Note that all commands require root permissions. |
... | ... | |
66 | 65 |
HTYPE = None |
67 | 66 |
_OP_REQP = [] |
68 | 67 |
REQ_MASTER = True |
69 |
REQ_WSSTORE = False |
|
70 | 68 |
REQ_BGL = True |
71 | 69 |
|
72 |
def __init__(self, processor, op, context, sstore):
|
|
70 |
def __init__(self, processor, op, context): |
|
73 | 71 |
"""Constructor for LogicalUnit. |
74 | 72 |
|
75 | 73 |
This needs to be overriden in derived classes in order to check op |
... | ... | |
79 | 77 |
self.proc = processor |
80 | 78 |
self.op = op |
81 | 79 |
self.cfg = context.cfg |
82 |
self.sstore = sstore |
|
83 | 80 |
self.context = context |
84 | 81 |
# Dicts used to declare locking needs to mcpu |
85 | 82 |
self.needed_locks = None |
b/lib/mcpu.py | ||
---|---|---|
34 | 34 |
from ganeti import errors |
35 | 35 |
from ganeti import rpc |
36 | 36 |
from ganeti import cmdlib |
37 |
from ganeti import ssconf |
|
38 | 37 |
from ganeti import logger |
39 | 38 |
from ganeti import locking |
40 | 39 |
|
... | ... | |
187 | 186 |
if lu_class is None: |
188 | 187 |
raise errors.OpCodeUnknown("Unknown opcode") |
189 | 188 |
|
190 |
if lu_class.REQ_WSSTORE: |
|
191 |
sstore = ssconf.WritableSimpleStore() |
|
192 |
else: |
|
193 |
sstore = ssconf.SimpleStore() |
|
194 |
|
|
195 | 189 |
# Acquire the Big Ganeti Lock exclusively if this LU requires it, and in a |
196 | 190 |
# shared fashion otherwise (to prevent concurrent run with an exclusive LU. |
197 | 191 |
self.context.glm.acquire(locking.LEVEL_CLUSTER, [locking.BGL], |
198 | 192 |
shared=not lu_class.REQ_BGL) |
199 | 193 |
try: |
200 | 194 |
self.exclusive_BGL = lu_class.REQ_BGL |
201 |
lu = lu_class(self, op, self.context, sstore)
|
|
195 |
lu = lu_class(self, op, self.context) |
|
202 | 196 |
lu.ExpandNames() |
203 | 197 |
assert lu.needed_locks is not None, "needed_locks not set by LU" |
204 | 198 |
result = self._LockAndExecLU(lu, locking.LEVEL_INSTANCE) |
Also available in: Unified diff