+"""
+Internal tasks are tasks that are started from the teuthology infrastructure.
+Note that there is no corresponding task defined for this module. All of
+the calls are made from other modules, most notably teuthology/run.py
+"""
from cStringIO import StringIO
import contextlib
import gevent
@contextlib.contextmanager
def base(ctx, config):
+ """
+ Create the test directory that we will be using on the remote system
+ """
log.info('Creating test directory...')
testdir = teuthology.get_testdir(ctx)
run.wait(
@contextlib.contextmanager
def lock_machines(ctx, config):
+ """
+ Lock machines. Called when the teuthology run finds and locks
+ new machines. This is not called if the one has teuthology-locked
+ machines and placed those keys in the Targets section of a yaml file.
+ """
log.info('Locking machines...')
assert isinstance(config[0], int), 'config[0] must be an integer'
machine_type = config[1]
lock.unlock_one(ctx, machine, ctx.owner)
def save_config(ctx, config):
+ """
+ Store the config in a yaml file
+ """
log.info('Saving configuration')
if ctx.archive is not None:
with file(os.path.join(ctx.archive, 'config.yaml'), 'w') as f:
yaml.safe_dump(ctx.config, f, default_flow_style=False)
def check_lock(ctx, config):
+ """
+ Check lock status of remote machines.
+ """
if ctx.config.get('check-locks') == False:
log.info('Lock checking disabled.')
return
@contextlib.contextmanager
def timer(ctx, config):
+ """
+ Start the timer used by teuthology
+ """
log.info('Starting timer...')
start = time.time()
try:
ctx.summary['duration'] = duration
def connect(ctx, config):
+ """
+ Open a connection to a remote host.
+ """
log.info('Opening connections...')
from ..orchestra import connection, remote
from ..orchestra import cluster
ctx.cluster.add(rem, rem.name)
def check_ceph_data(ctx, config):
+ """
+ Check for old /var/lib/ceph directories and detect staleness.
+ """
log.info('Checking for old /var/lib/ceph...')
processes = ctx.cluster.run(
args=[
raise RuntimeError('Stale /var/lib/ceph detected, aborting.')
def check_conflict(ctx, config):
+ """
+ Note directory use conflicts and stale directories.
+ """
log.info('Checking for old test directory...')
testdir = teuthology.get_testdir(ctx)
processes = ctx.cluster.run(
@contextlib.contextmanager
def archive(ctx, config):
+ """
+ Handle the creation and deletion of the archive directory.
+ """
log.info('Creating archive directory...')
archive_dir = teuthology.get_archive_dir(ctx)
run.wait(
@contextlib.contextmanager
def sudo(ctx, config):
+ """
+ Enable use of sudo
+ """
log.info('Configuring sudo...')
sudoers_file = '/etc/sudoers'
backup_ext = '.orig.teuthology'
@contextlib.contextmanager
def coredump(ctx, config):
+ """
+ Stash a coredump of this system if an error occurs.
+ """
log.info('Enabling coredump saving...')
archive_dir = teuthology.get_archive_dir(ctx)
run.wait(
@contextlib.contextmanager
def syslog(ctx, config):
+ """
+ start syslog / stop syslog on exit.
+ """
if ctx.archive is None:
# disable this whole feature if we're not going to archive the data anyway
yield
)
CONF = '/etc/rsyslog.d/80-cephtest.conf'
- conf_fp = StringIO("""
+ conf_fp = StringIO('''
kern.* -{adir}/syslog/kern.log;RSYSLOG_FileFormat
*.*;kern.none -{adir}/syslog/misc.log;RSYSLOG_FileFormat
-""".format(adir=archive_dir))
+'''.format(adir=archive_dir))
try:
for rem in ctx.cluster.remotes.iterkeys():
teuthology.sudo_write_file(
check_status=False,)
if r.exitstatus != 0:
p1 = subprocess.Popen(['cat', editinfo], stdout=subprocess.PIPE)
- p2 = subprocess.Popen(['ssh','-t','-t',str(remote), 'sudo', 'sh'],stdin=p1.stdout, stdout=subprocess.PIPE)
- _,err = p2.communicate()
+ p2 = subprocess.Popen(['ssh', '-t', '-t', str(remote), 'sudo', 'sh'], stdin=p1.stdout, stdout=subprocess.PIPE)
+ _, err = p2.communicate()
if err:
- log.info("Edit of /etc/sudoers failed: %s",err)
+ log.info("Edit of /etc/sudoers failed: %s", err)
p.spawn(_handle_vm_init, remote)
def _handle_vm_init(remote):
+ """
+ Initialize a remote vm by downloading and running ceph_qa_chef.
+ """
log.info('Running ceph_qa_chef on %s', remote)
- remote.run(args=['wget','-q','-O-',
+ remote.run(args=['wget', '-q', '-O-',
'http://ceph.com/git/?p=ceph-qa-chef.git;a=blob_plain;f=solo/solo-from-scratch;hb=HEAD',
run.Raw('|'),
'sh',