Revision 1a8c0ce1
b/lib/cli.py | ||
---|---|---|
346 | 346 |
interaction functions. |
347 | 347 |
|
348 | 348 |
""" |
349 |
if proc is None: |
|
350 |
proc = mcpu.Processor() |
|
351 | 349 |
if feedback_fn is None: |
352 | 350 |
feedback_fn = logger.ToStdout |
353 |
return proc.ExecOpCode(op, feedback_fn) |
|
351 |
if proc is None: |
|
352 |
proc = mcpu.Processor(feedback=feedback_fn) |
|
353 |
return proc.ExecOpCode(op) |
|
354 | 354 |
|
355 | 355 |
|
356 | 356 |
def FormatError(err): |
b/lib/cmdlib.py | ||
---|---|---|
4027 | 4027 |
# shutdown the instance, unless requested not to do so |
4028 | 4028 |
if self.op.shutdown: |
4029 | 4029 |
op = opcodes.OpShutdownInstance(instance_name=instance.name) |
4030 |
self.processor.ChainOpCode(op, feedback_fn)
|
|
4030 |
self.processor.ChainOpCode(op) |
|
4031 | 4031 |
|
4032 | 4032 |
vgname = self.cfg.GetVGName() |
4033 | 4033 |
|
... | ... | |
4053 | 4053 |
if self.op.shutdown: |
4054 | 4054 |
op = opcodes.OpStartupInstance(instance_name=instance.name, |
4055 | 4055 |
force=False) |
4056 |
self.processor.ChainOpCode(op, feedback_fn)
|
|
4056 |
self.processor.ChainOpCode(op) |
|
4057 | 4057 |
|
4058 | 4058 |
# TODO: check for size |
4059 | 4059 |
|
... | ... | |
4079 | 4079 |
# substitutes an empty list with the full cluster node list. |
4080 | 4080 |
if nodelist: |
4081 | 4081 |
op = opcodes.OpQueryExports(nodes=nodelist) |
4082 |
exportlist = self.processor.ChainOpCode(op, feedback_fn)
|
|
4082 |
exportlist = self.processor.ChainOpCode(op) |
|
4083 | 4083 |
for node in exportlist: |
4084 | 4084 |
if instance.name in exportlist[node]: |
4085 | 4085 |
if not rpc.call_export_remove(node, instance.name): |
b/lib/mcpu.py | ||
---|---|---|
84 | 84 |
opcodes.OpDelTags: cmdlib.LUDelTags, |
85 | 85 |
} |
86 | 86 |
|
87 |
|
|
88 |
def __init__(self): |
|
87 |
def __init__(self, feedback=None): |
|
89 | 88 |
"""Constructor for Processor |
90 | 89 |
|
90 |
Args: |
|
91 |
- feedback_fn: the feedback function (taking one string) to be run when |
|
92 |
interesting events are happening |
|
91 | 93 |
""" |
92 | 94 |
self.cfg = None |
93 | 95 |
self.sstore = None |
96 |
self._feedback_fn = feedback |
|
94 | 97 |
|
95 |
def ExecOpCode(self, op, feedback_fn):
|
|
98 |
def ExecOpCode(self, op): |
|
96 | 99 |
"""Execute an opcode. |
97 | 100 |
|
98 | 101 |
Args: |
99 | 102 |
- cfg: the configuration in which we execute this opcode |
100 | 103 |
- opcode: the opcode to be executed |
101 |
- feedback_fn: the feedback function (taking one string) to be run when |
|
102 |
interesting events are happening |
|
103 | 104 |
|
104 | 105 |
""" |
105 | 106 |
if not isinstance(op, opcodes.OpCode): |
... | ... | |
121 | 122 |
lu.CheckPrereq() |
122 | 123 |
hm = HooksMaster(rpc.call_hooks_runner, lu) |
123 | 124 |
hm.RunPhase(constants.HOOKS_PHASE_PRE) |
124 |
result = lu.Exec(feedback_fn) |
|
125 |
result = lu.Exec(self._feedback_fn)
|
|
125 | 126 |
hm.RunPhase(constants.HOOKS_PHASE_POST) |
126 | 127 |
if lu.cfg is not None: |
127 | 128 |
# we use lu.cfg and not self.cfg as for init cluster, self.cfg |
... | ... | |
132 | 133 |
|
133 | 134 |
return result |
134 | 135 |
|
135 |
def ChainOpCode(self, op, feedback_fn):
|
|
136 |
def ChainOpCode(self, op): |
|
136 | 137 |
"""Chain and execute an opcode. |
137 | 138 |
|
138 | 139 |
This is used by LUs when they need to execute a child LU. |
139 | 140 |
|
140 | 141 |
Args: |
141 | 142 |
- opcode: the opcode to be executed |
142 |
- feedback_fn: the feedback function (taking one string) to be run when |
|
143 |
interesting events are happening |
|
144 | 143 |
|
145 | 144 |
""" |
146 | 145 |
if not isinstance(op, opcodes.OpCode): |
... | ... | |
160 | 159 |
#if do_hooks: |
161 | 160 |
# hm = HooksMaster(rpc.call_hooks_runner, lu) |
162 | 161 |
# hm.RunPhase(constants.HOOKS_PHASE_PRE) |
163 |
result = lu.Exec(feedback_fn) |
|
162 |
result = lu.Exec(self._feedback_fn)
|
|
164 | 163 |
#if do_hooks: |
165 | 164 |
# hm.RunPhase(constants.HOOKS_PHASE_POST) |
166 | 165 |
return result |
b/tools/burnin | ||
---|---|---|
81 | 81 |
""" |
82 | 82 |
|
83 | 83 |
logger.SetupLogging(debug=True, program="ganeti/burnin") |
84 |
proc = mcpu.Processor() |
|
84 |
proc = mcpu.Processor(feedback=Feedback)
|
|
85 | 85 |
result = proc.ExecOpCode(opcodes.OpQueryNodes(output_fields=["name"], |
86 |
names=[]), Feedback)
|
|
86 |
names=[])) |
|
87 | 87 |
nodelist = [data[0] for data in result] |
88 | 88 |
|
89 | 89 |
Feedback("- Testing global parameters") |
90 | 90 |
|
91 |
result = proc.ExecOpCode(opcodes.OpDiagnoseOS(), Feedback)
|
|
91 |
result = proc.ExecOpCode(opcodes.OpDiagnoseOS()) |
|
92 | 92 |
|
93 | 93 |
if not result: |
94 | 94 |
Feedback("Can't get the OS list") |
... | ... | |
135 | 135 |
ip_check=True, |
136 | 136 |
wait_for_sync=True) |
137 | 137 |
Feedback("- Add instance %s on node %s" % (instance_name, pnode)) |
138 |
result = proc.ExecOpCode(op, Feedback)
|
|
138 |
result = proc.ExecOpCode(op) |
|
139 | 139 |
to_remove.append(instance_name) |
140 | 140 |
idx = next_idx |
141 | 141 |
|
... | ... | |
148 | 148 |
remote_node=None) |
149 | 149 |
|
150 | 150 |
Feedback("- Replace disks for instance %s" % (instance_name)) |
151 |
result = proc.ExecOpCode(op, Feedback)
|
|
151 |
result = proc.ExecOpCode(op) |
|
152 | 152 |
else: |
153 | 153 |
Feedback("- Can't run replace1, not enough nodes") |
154 | 154 |
|
... | ... | |
160 | 160 |
ignore_consistency=True) |
161 | 161 |
|
162 | 162 |
Feedback("- Failover instance %s" % (instance_name)) |
163 |
result = proc.ExecOpCode(op, Feedback)
|
|
163 |
result = proc.ExecOpCode(op) |
|
164 | 164 |
else: |
165 | 165 |
Feedback("- Can't run failovers, not enough nodes") |
166 | 166 |
|
... | ... | |
168 | 168 |
for instance_name in args: |
169 | 169 |
op = opcodes.OpShutdownInstance(instance_name=instance_name) |
170 | 170 |
Feedback("- Shutdown instance %s" % instance_name) |
171 |
result = proc.ExecOpCode(op, Feedback)
|
|
171 |
result = proc.ExecOpCode(op) |
|
172 | 172 |
op = opcodes.OpStartupInstance(instance_name=instance_name, force=False) |
173 | 173 |
Feedback("- Start instance %s" % instance_name) |
174 |
result = proc.ExecOpCode(op, Feedback)
|
|
174 |
result = proc.ExecOpCode(op) |
|
175 | 175 |
|
176 | 176 |
finally: |
177 | 177 |
# remove |
178 | 178 |
for instance_name in to_remove: |
179 | 179 |
op = opcodes.OpRemoveInstance(instance_name=instance_name) |
180 | 180 |
Feedback("- Remove instance %s" % instance_name) |
181 |
result = proc.ExecOpCode(op, Feedback)
|
|
181 |
result = proc.ExecOpCode(op) |
|
182 | 182 |
|
183 | 183 |
return 0 |
184 | 184 |
|
Also available in: Unified diff