]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
add exec task
authorSage Weil <sage@inktank.com>
Mon, 22 Oct 2012 23:51:54 +0000 (16:51 -0700)
committerSage Weil <sage@inktank.com>
Mon, 22 Oct 2012 23:51:54 +0000 (16:51 -0700)
teuthology/misc.py
teuthology/task/exec.py [new file with mode: 0644]

index b88ff4ea4a33d30e675a5b011092b5fc76e71d6b..0422a826e947eead08fa5e23c7e2a759669d45f3 100644 (file)
@@ -138,6 +138,11 @@ def roles_of_type(roles_for_host, type_):
         id_ = name[len(prefix):]
         yield id_
 
+def all_roles(cluster):
+    for _, roles_for_host in cluster.remotes.iteritems():
+        for name in roles_for_host:
+            yield name
+
 def all_roles_of_type(cluster, type_):
     prefix = '{type}.'.format(type=type_)
     for _, roles_for_host in cluster.remotes.iteritems():
diff --git a/teuthology/task/exec.py b/teuthology/task/exec.py
new file mode 100644 (file)
index 0000000..8961ee6
--- /dev/null
@@ -0,0 +1,42 @@
+import contextlib
+import logging
+import os
+
+from teuthology import misc as teuthology
+
+log = logging.getLogger(__name__)
+
+def task(ctx, config):
+    """
+    Execute commands on a given role
+
+        tasks:
+        - ceph:
+        - kclient: [client.a]
+        - exec:
+            client.a:
+              - echo 'module libceph +p' > /sys/kernel/debug/dynamic_debug/control
+              - echo 'module ceph +p' > /sys/kernel/debug/dynamic_debug/control
+        - interactive:
+
+    """
+    log.info('Executing custom commands...')
+    assert isinstance(config, dict), "task exec got invalid config"
+
+    if 'all' in config and len(config) == 1:
+        a = config['all']
+        roles = teuthology.all_roles(ctx.cluster)
+        config = dict((id_, a) for id_ in roles)
+
+    for role, ls in config.iteritems():
+        (remote,) = ctx.cluster.only(role).remotes.iterkeys()
+        log.info('Running commands on role %s host %s', role, remote.name)
+        for c in ls:
+            remote.run(
+                args=[
+                    'sudo',
+                    'bash',
+                    '-c',
+                    c],
+                )
+