Revision 20777413
b/lib/cmdlib.py | ||
---|---|---|
56 | 56 |
|
57 | 57 |
Note that all commands require root permissions. |
58 | 58 |
|
59 |
@ivar dry_run_result: the value (if any) that will be returned to the caller |
|
60 |
in dry-run mode (signalled by opcode dry_run parameter) |
|
61 |
|
|
59 | 62 |
""" |
60 | 63 |
HPATH = None |
61 | 64 |
HTYPE = None |
... | ... | |
86 | 89 |
# logging |
87 | 90 |
self.LogWarning = processor.LogWarning |
88 | 91 |
self.LogInfo = processor.LogInfo |
92 |
# support for dry-run |
|
93 |
self.dry_run_result = None |
|
89 | 94 |
|
90 | 95 |
for attr_name in self._OP_REQP: |
91 | 96 |
attr_val = getattr(op, attr_name, None) |
b/lib/mcpu.py | ||
---|---|---|
113 | 113 |
h_results = hm.RunPhase(constants.HOOKS_PHASE_PRE) |
114 | 114 |
lu.HooksCallBack(constants.HOOKS_PHASE_PRE, h_results, |
115 | 115 |
self._feedback_fn, None) |
116 |
|
|
117 |
if getattr(lu.op, "dry_run", False): |
|
118 |
# in this mode, no post-hooks are run, and the config is not |
|
119 |
# written (as it might have been modified by another LU, and we |
|
120 |
# shouldn't do writeout on behalf of other threads |
|
121 |
self.LogInfo("dry-run mode requested, not actually executing" |
|
122 |
" the operation") |
|
123 |
return lu.dry_run_result |
|
124 |
|
|
116 | 125 |
try: |
117 | 126 |
result = lu.Exec(self._feedback_fn) |
118 | 127 |
h_results = hm.RunPhase(constants.HOOKS_PHASE_POST) |
b/lib/opcodes.py | ||
---|---|---|
103 | 103 |
from this class should override OP_ID. |
104 | 104 |
|
105 | 105 |
@cvar OP_ID: The ID of this opcode. This should be unique amongst all |
106 |
childre of this class. |
|
106 |
children of this class. |
|
107 |
@ivar dry_run: Whether the LU should be run in dry-run mode, i.e. just |
|
108 |
the check steps |
|
107 | 109 |
|
108 | 110 |
""" |
109 | 111 |
OP_ID = "OP_ABSTRACT" |
110 |
__slots__ = BaseOpCode.__slots__ + [] |
|
112 |
__slots__ = BaseOpCode.__slots__ + ["dry_run"]
|
|
111 | 113 |
|
112 | 114 |
def __getstate__(self): |
113 | 115 |
"""Specialized getstate for opcodes. |
Also available in: Unified diff