]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add push_inventory() subtask
authorZack Cerza <zack.cerza@inktank.com>
Mon, 8 Sep 2014 19:13:31 +0000 (13:13 -0600)
committerZack Cerza <zack.cerza@inktank.com>
Thu, 11 Sep 2014 21:12:52 +0000 (15:12 -0600)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/task/internal.py

index cb0b41ce0d67b6ea5441a50759b28cfc09c22fb1..459740c4698681584c85f506e0c90063120b4f7e 100644 (file)
@@ -15,6 +15,7 @@ from teuthology import lockstatus
 from teuthology import lock
 from teuthology import misc
 from teuthology import provision
+from teuthology.config import config as teuth_config
 from teuthology.parallel import parallel
 from ..orchestra import cluster, remote, run
 
@@ -227,6 +228,23 @@ def connect(ctx, config):
             ctx.cluster.add(rem, rem.name)
 
 
+@contextlib.contextmanager
+def push_inventory(ctx, config):
+    if not teuth_config.lock_server:
+        yield
+        return
+
+    def push():
+        for rem in ctx.cluster.remotes.keys():
+            info = rem.inventory_info
+            lock.update_inventory(info)
+    try:
+        push()
+        yield
+    except Exception:
+        log.exception("Error pushing inventory")
+
+
 def serialize_remote_roles(ctx, config):
     """
     Provides an explicit mapping for which remotes have been assigned what roles