]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
check for ceph health function
authorVasu Kulkarni <vasu@redhat.com>
Wed, 7 Dec 2016 04:09:08 +0000 (20:09 -0800)
committerVasu Kulkarni <vasu@redhat.com>
Tue, 20 Dec 2016 22:42:58 +0000 (14:42 -0800)
Signed-off-by: Vasu Kulkarni <vasu@redhat.com>
teuthology/task/ceph_ansible.py

index eb413846fc0914a9b81cc9ac787f259b1cefda0f..a39a00458a83062b2c519ff7b7c22688266f1b9f 100644 (file)
@@ -205,6 +205,22 @@ class CephAnsible(Task):
         hosts_file.flush()
         return hosts_file.name
 
+    def wait_for_ceph_health(self):
+        with contextutil.safe_while(sleep=15, tries=6,
+                                    action='check health') as proceed:
+            (remote,) = self.ctx.cluster.only('mon.a').remotes
+            remote.run(args=['sudo', 'ceph', 'osd', 'tree'])
+            remote.run(args=['sudo', 'ceph', '-s'])
+            log.info("Waiting for Ceph health to reach HEALTH_OK \
+                        or HEALTH WARN")
+            while proceed():
+                out = StringIO()
+                remote.run(args=['sudo', 'ceph', 'health'], stdout=out)
+                out = out.getvalue().split(None, 1)[0]
+                log.info("cluster in state: %s", out)
+                if out in ('HEALTH_OK', 'HEALTH_WARN'):
+                    break
+
     def get_host_vars(self, remote):
         extra_vars = self.config.get('vars', dict())
         host_vars = dict()