Revision f6eb380d lib/client/gnt_group.py
b/lib/client/gnt_group.py | ||
---|---|---|
181 | 181 |
SubmitOpCode(op, opts=opts) |
182 | 182 |
|
183 | 183 |
|
184 |
def EvacuateGroup(opts, args): |
|
185 |
"""Evacuate a node group. |
|
186 |
|
|
187 |
""" |
|
188 |
(group_name, ) = args |
|
189 |
|
|
190 |
cl = GetClient() |
|
191 |
|
|
192 |
op = opcodes.OpGroupEvacuate(group_name=group_name, |
|
193 |
iallocator=opts.iallocator, |
|
194 |
target_groups=opts.to, |
|
195 |
early_release=opts.early_release) |
|
196 |
result = SubmitOpCode(op, cl=cl, opts=opts) |
|
197 |
|
|
198 |
# Keep track of submitted jobs |
|
199 |
jex = JobExecutor(cl=cl, opts=opts) |
|
200 |
|
|
201 |
for (status, job_id) in result[constants.JOB_IDS_KEY]: |
|
202 |
jex.AddJobId(None, status, job_id) |
|
203 |
|
|
204 |
results = jex.GetResults() |
|
205 |
bad_cnt = len([row for row in results if not row[0]]) |
|
206 |
if bad_cnt == 0: |
|
207 |
ToStdout("All instances evacuated successfully.") |
|
208 |
rcode = constants.EXIT_SUCCESS |
|
209 |
else: |
|
210 |
ToStdout("There were %s errors during the evacuation.", bad_cnt) |
|
211 |
rcode = constants.EXIT_FAILURE |
|
212 |
|
|
213 |
return rcode |
|
214 |
|
|
184 | 215 |
commands = { |
185 | 216 |
"add": ( |
186 | 217 |
AddGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT], |
... | ... | |
209 | 240 |
"rename": ( |
210 | 241 |
RenameGroup, [ArgGroup(min=2, max=2)], [DRY_RUN_OPT], |
211 | 242 |
"[--dry-run] <group-name> <new-name>", "Rename a node group"), |
243 |
"evacuate": ( |
|
244 |
EvacuateGroup, [ArgGroup(min=1, max=1)], |
|
245 |
[TO_GROUP_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT], |
|
246 |
"-I <iallocator> [--to <group>]", "Evacuate all instances within a group"), |
|
212 | 247 |
"list-tags": ( |
213 | 248 |
ListTags, ARGS_ONE_GROUP, [PRIORITY_OPT], |
214 | 249 |
"<instance_name>", "List the tags of the given instance"), |
Also available in: Unified diff