Revision ae1a845c lib/watcher/__init__.py
b/lib/watcher/__init__.py | ||
---|---|---|
597 | 597 |
"""Run gnt-cluster verify-disks. |
598 | 598 |
|
599 | 599 |
""" |
600 |
op = opcodes.OpClusterVerifyDisks() |
|
601 |
job_id = client.SubmitJob([op]) |
|
600 |
job_id = client.SubmitJob([opcodes.OpClusterVerifyDisks()]) |
|
602 | 601 |
result = cli.PollJob(job_id, cl=client, feedback_fn=logging.debug)[0] |
603 | 602 |
client.ArchiveJob(job_id) |
604 |
if not isinstance(result, (tuple, list)): |
|
605 |
logging.error("Can't get a valid result from verify-disks") |
|
606 |
return |
|
607 |
offline_disk_instances = result[1] |
|
603 |
|
|
604 |
# Keep track of submitted jobs |
|
605 |
jex = cli.JobExecutor(cl=client, feedback_fn=logging.debug) |
|
606 |
|
|
607 |
archive_jobs = set() |
|
608 |
for (status, job_id) in result[constants.JOB_IDS_KEY]: |
|
609 |
jex.AddJobId(None, status, job_id) |
|
610 |
if status: |
|
611 |
archive_jobs.add(job_id) |
|
612 |
|
|
613 |
offline_disk_instances = set() |
|
614 |
|
|
615 |
for (status, result) in jex.GetResults(): |
|
616 |
if not status: |
|
617 |
logging.error("Verify-disks job failed: %s", result) |
|
618 |
continue |
|
619 |
|
|
620 |
((_, instances, _), ) = result |
|
621 |
|
|
622 |
offline_disk_instances.update(instances) |
|
623 |
|
|
624 |
for job_id in archive_jobs: |
|
625 |
client.ArchiveJob(job_id) |
|
626 |
|
|
608 | 627 |
if not offline_disk_instances: |
609 | 628 |
# nothing to do |
610 | 629 |
logging.debug("verify-disks reported no offline disks, nothing to do") |
611 | 630 |
return |
631 |
|
|
612 | 632 |
logging.debug("Will activate disks for instance(s) %s", |
613 | 633 |
utils.CommaJoin(offline_disk_instances)) |
634 |
|
|
614 | 635 |
# we submit only one job, and wait for it. not optimal, but spams |
615 | 636 |
# less the job queue |
616 | 637 |
job = [] |
Also available in: Unified diff