]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tasks/ceph: add ceph.stop task
authorJohn Spray <jspray@redhat.com>
Wed, 20 Aug 2014 11:30:27 +0000 (12:30 +0100)
committerJohn Spray <jspray@redhat.com>
Thu, 21 Aug 2014 22:09:00 +0000 (23:09 +0100)
So that we can explicitly stop daemons on demand.  Useful
for MDS tool tests that want the MDS daemons not to be running,
is this is more solid and explicit than doing e.g. "ceph mds
stop" from within workunits.

Signed-off-by: John Spray <john.spray@redhat.com>
tasks/ceph.py

index 07eb604ba9a02d237921efe805379264149369a7..02f306a0ffc898910fa561b2f03ce41485a0fa60 100644 (file)
@@ -21,6 +21,7 @@ from teuthology.orchestra.run import CommandFailedError
 from teuthology.orchestra.daemon import DaemonGroup
 
 DEFAULT_CONF_PATH = '/etc/ceph/ceph.conf'
+CEPH_ROLE_TYPES = ['mon', 'osd', 'mds', 'rgw']
 
 log = logging.getLogger(__name__)
 
@@ -1049,7 +1050,7 @@ def restart(ctx, config):
 
    For example::
       tasks:
-      - ceph.restart: [osd.0, mon.1]
+      - ceph.restart: [osd.0, mon.1, mds.*]
 
    or::
 
@@ -1064,19 +1065,11 @@ def restart(ctx, config):
     """
     if config is None:
         config = {}
-    if isinstance(config, list):
-        config = { 'daemons': config }
-    if 'daemons' not in config:
-        config['daemons'] = []
-        type_daemon = ['mon', 'osd', 'mds', 'rgw']
-        for d in type_daemon:
-            type_ = d
-            for daemon in ctx.daemons.iter_daemons_of_role(type_):
-                config['daemons'].append(type_ + '.' + daemon.id_)
-
-    assert isinstance(config['daemons'], list)
-    daemons = dict.fromkeys(config['daemons'])
-    for i in daemons.keys():
+    elif isinstance(config, list):
+        config = {'daemons': config}
+
+    daemons = ctx.daemons.resolve_role_list(config.get('daemons', None), CEPH_ROLE_TYPES)
+    for i in daemons:
         type_ = i.split('.', 1)[0]
         id_ = i.split('.', 1)[1]
         ctx.daemons.get_daemon(type_, id_).stop()
@@ -1088,6 +1081,38 @@ def restart(ctx, config):
         wait_for_osds_up(ctx=ctx, config=None)
     yield
 
+
+@contextlib.contextmanager
+def stop(ctx, config):
+    """
+    Stop ceph daemons
+
+    For example::
+      tasks:
+      - ceph.stop: [mds.*]
+
+      tasks:
+      - ceph.stop: [osd.0, osd.2]
+
+      tasks:
+      - ceph.stop:
+          daemons: [osd.0, osd.2]
+
+    """
+    if config is None:
+        config = {}
+    elif isinstance(config, list):
+        config = {'daemons': config}
+
+    daemons = ctx.daemons.resolve_role_list(config.get('daemons', None), CEPH_ROLE_TYPES)
+    for i in daemons:
+        type_ = i.split('.', 1)[0]
+        id_ = i.split('.', 1)[1]
+        ctx.daemons.get_daemon(type_, id_).stop()
+
+    yield
+
+
 @contextlib.contextmanager
 def task(ctx, config):
     """