+ op = opcodes.OpVerifyDisks()
+ job_id = client.SubmitJob([op])
+ result = cli.PollJob(job_id, cl=client, feedback_fn=logging.debug)[0]
+ client.ArchiveJob(job_id)
+ if not isinstance(result, (tuple, list)):
+ logging.error("Can't get a valid result from verify-disks")
+ return
+ offline_disk_instances = result[2]
+ if not offline_disk_instances:
+ # nothing to do
+ return
+ logging.debug("Will activate disks for instances %s",
+ ", ".join(offline_disk_instances))
+ # we submit only one job, and wait for it. not optimal, but spams
+ # less the job queue
+ job = [opcodes.OpActivateInstanceDisks(instance_name=name)
+ for name in offline_disk_instances]
+ job_id = cli.SendJob(job, cl=client)
+
+ cli.PollJob(job_id, cl=client, feedback_fn=logging.debug)