from cStringIO import StringIO
+import bunch
import json
import logging
import os
remote=mon0_remote,
)
-
- log.info('Mounting cfuse clients...')
- cfuse_daemons = {}
- for idx, roles_for_host in enumerate(ROLES):
- for id_ in teuthology.roles_of_type(roles_for_host, 'client'):
- mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
- run.run(
- client=connections[idx],
- args=[
- 'mkdir',
- '--',
- mnt,
- ],
- )
- proc = run.run(
- client=connections[idx],
- args=[
- '/tmp/cephtest/daemon-helper',
- '/tmp/cephtest/binary/usr/local/bin/cfuse',
- '-f',
- '--name', 'client.{id}'.format(id=id_),
- '-c', '/tmp/cephtest/ceph.conf',
- # TODO cfuse doesn't understand dash dash '--',
- mnt,
- ],
- logger=log.getChild('cfuse.{id}'.format(id=id_)),
- stdin=run.PIPE,
- wait=False,
- )
- cfuse_daemons[id_] = proc
- for idx, roles_for_host in enumerate(ROLES):
- for id_ in teuthology.roles_of_type(roles_for_host, 'client'):
- mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
- teuthology.wait_until_fuse_mounted(
- remote=remotes[idx],
- fuse=cfuse_daemons[id_],
- mountpoint=mnt,
- )
-
# TODO kclient mount/umount
# TODO rbd
],
)
- import code
- import readline
- import rlcompleter
- rlcompleter.__name__ # silence pyflakes
- readline.parse_and_bind('tab: complete')
- code.interact(
- banner='Ceph test interactive mode, press control-D to exit...',
- # TODO simplify this
- local=dict(
- config=config,
- ROLES=ROLES,
- connections=connections,
- cluster=cluster,
- ),
+ ctx = bunch.Bunch(
+ cluster=cluster,
+ )
+ from teuthology.run_tasks import run_tasks
+ run_tasks(
+ tasks=[
+ {'cfuse': ['client.0']},
+ {'interactive': None},
+ ],
+ ctx=ctx,
)
-
- log.info('Unmounting cfuse clients...')
- for idx, roles_for_host in enumerate(ROLES):
- for id_ in teuthology.roles_of_type(roles_for_host, 'client'):
- mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
- run.run(
- client=connections[idx],
- args=[
- 'fusermount',
- '-u',
- mnt,
- ],
- )
- run.wait(cfuse_daemons.itervalues())
-
log.info('Shutting down mds daemons...')
for id_, proc in mds_daemons.iteritems():
-e git+https://github.com/tv42/orchestra.git#egg=orchestra
configobj
PyYAML
+bunch >=1.0.0
'orchestra',
'configobj',
'PyYAML',
+ 'bunch >=1.0.0',
],
)
--- /dev/null
+import sys
+import logging
+
+log = logging.getLogger(__name__)
+
+def _run_one_task(taskname, **kwargs):
+ parent = __import__('teuthology.task', globals(), locals(), [taskname], 0)
+ mod = getattr(parent, taskname)
+ fn = getattr(mod, 'task')
+ return fn(**kwargs)
+
+def run_tasks(tasks, ctx):
+ stack = []
+ try:
+ for taskdict in tasks:
+ try:
+ ((taskname, config),) = taskdict.iteritems()
+ except ValueError:
+ raise RuntimeError('Invalid task definition: %s' % taskdict)
+ log.info('Running task %s...', taskname)
+ manager = _run_one_task(taskname, ctx=ctx, config=config)
+ if hasattr(manager, '__enter__'):
+ manager.__enter__()
+ stack.append(manager)
+ except:
+ log.exception('Saw exception from tasks')
+ finally:
+ try:
+ exc_info = sys.exc_info()
+ while stack:
+ manager = stack.pop()
+ log.debug('Unwinding manager %s', manager)
+ try:
+ suppress = manager.__exit__(*exc_info)
+ except:
+ log.exception('Manager failed: %s', manager)
+ else:
+ if suppress:
+ sys.exc_clear()
+ exc_info = (None, None, None)
+
+ if exc_info != (None, None, None):
+ log.debug('Exception was not quenched, raising %s', exc_info[1])
+ raise exc_info[0], exc_info[1], exc_info[2]
+ finally:
+ # be careful about cyclic references
+ del exc_info
--- /dev/null
+import contextlib
+import logging
+import os
+
+from teuthology import misc as teuthology
+from orchestra import run
+
+log = logging.getLogger(__name__)
+
+@contextlib.contextmanager
+def task(ctx, config):
+ log.info('Mounting cfuse clients...')
+ assert isinstance(config, list), \
+ "task fuse automatic configuration not supported yet, list all clients"
+ cfuse_daemons = {}
+
+ for role in config:
+ assert isinstance(role, basestring)
+ PREFIX = 'client.'
+ assert role.startswith(PREFIX)
+ id_ = role[len(PREFIX):]
+ (remote,) = ctx.cluster.only(role).remotes.iterkeys()
+ mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
+ remote.run(
+ args=[
+ 'mkdir',
+ '--',
+ mnt,
+ ],
+ )
+ proc = remote.run(
+ args=[
+ '/tmp/cephtest/daemon-helper',
+ '/tmp/cephtest/binary/usr/local/bin/cfuse',
+ '-f',
+ '--name', 'client.{id}'.format(id=id_),
+ '-c', '/tmp/cephtest/ceph.conf',
+ # TODO cfuse doesn't understand dash dash '--',
+ mnt,
+ ],
+ logger=log.getChild('cfuse.{id}'.format(id=id_)),
+ stdin=run.PIPE,
+ wait=False,
+ )
+ cfuse_daemons[id_] = proc
+
+ for role in config:
+ assert isinstance(role, basestring)
+ PREFIX = 'client.'
+ assert role.startswith(PREFIX)
+ id_ = role[len(PREFIX):]
+ (remote,) = ctx.cluster.only(role).remotes.iterkeys()
+ mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
+ teuthology.wait_until_fuse_mounted(
+ remote=remote,
+ fuse=cfuse_daemons[id_],
+ mountpoint=mnt,
+ )
+
+ try:
+ yield
+ finally:
+ log.info('Unmounting cfuse clients...')
+ for role in config:
+ assert isinstance(role, basestring)
+ PREFIX = 'client.'
+ assert role.startswith(PREFIX)
+ id_ = role[len(PREFIX):]
+ (remote,) = ctx.cluster.only(role).remotes.iterkeys()
+ mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
+ remote.run(
+ args=[
+ 'fusermount',
+ '-u',
+ mnt,
+ ],
+ )
+ run.wait(cfuse_daemons.itervalues())
--- /dev/null
+import code
+import readline
+import rlcompleter
+rlcompleter.__name__ # silence pyflakes
+
+readline.parse_and_bind('tab: complete')
+
+def task(ctx, config):
+ code.interact(
+ banner='Ceph test interactive mode, use ctx to interact with the cluster, press control-D to exit...',
+ # TODO simplify this
+ local=dict(
+ ctx=ctx,
+ config=config,
+ ),
+ )
--- /dev/null
+def task(ctx, config):
+ """
+ This task does nothing.
+ """
+ pass