]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
teuthology-nuke: move it into its own file.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Wed, 10 Aug 2011 22:38:57 +0000 (15:38 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Wed, 10 Aug 2011 22:38:57 +0000 (15:38 -0700)
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
setup.py
teuthology/nuke.py [new file with mode: 0644]
teuthology/run.py

index 74d17f6a2b70ec2ad2c8a87121ae8f73af30f753..442bd9058b5af5567241079ae32bff95fbd3ceb7 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -25,7 +25,7 @@ setup(
     entry_points={
         'console_scripts': [
             'teuthology = teuthology.run:main',
-            'teuthology-nuke = teuthology.run:nuke',
+            'teuthology-nuke = teuthology.nuke:main',
             'teuthology-suite = teuthology.suite:main',
             'teuthology-ls = teuthology.suite:ls',
             'teuthology-worker = teuthology.queue:worker',
diff --git a/teuthology/nuke.py b/teuthology/nuke.py
new file mode 100644 (file)
index 0000000..200fc71
--- /dev/null
@@ -0,0 +1,177 @@
+import argparse
+import yaml
+
+def parse_args():
+    from teuthology.run import config_file
+    from teuthology.run import MergeConfig
+
+    parser = argparse.ArgumentParser(description='Reset test machines')
+    parser.add_argument(
+        '-v', '--verbose',
+        action='store_true', default=None,
+        help='be more verbose'
+        )
+    parser.add_argument(
+        'config',
+        metavar='CONFFILE',
+        nargs='+',
+        type=config_file,
+        action=MergeConfig,
+        default={},
+        help='config file to read',
+        )
+    parser.add_argument(
+        '--archive',
+        metavar='DIR',
+        help='path to archive results in',
+        )
+    parser.add_argument(
+        '--owner',
+        help='job owner',
+        )
+    args = parser.parse_args()
+    return args
+
+def main():
+    from gevent import monkey; monkey.patch_all()
+    from orchestra import monkey; monkey.patch_all()
+
+    import logging
+    import time
+
+    log = logging.getLogger(__name__)
+
+    ctx = parse_args()
+
+    loglevel = logging.INFO
+    if ctx.verbose:
+        loglevel = logging.DEBUG
+
+    logging.basicConfig(
+        level=loglevel,
+        )
+
+    from teuthology.misc import read_config
+    read_config(ctx)
+
+    log.info('\n  '.join(['targets:', ] + yaml.safe_dump(ctx.config['targets'], default_flow_style=False).splitlines()))
+
+    if ctx.owner is None:
+        from teuthology.misc import get_user
+        ctx.owner = get_user()
+
+    from teuthology.task.internal import check_lock, connect
+    check_lock(ctx, None)
+    connect(ctx, None)
+
+    log.info('Unmount cfuse and killing daemons...')
+    from orchestra import run
+    nodes = {}
+    for remote in ctx.cluster.remotes.iterkeys():
+        proc = remote.run(
+            args=[
+                'if', 'grep', '-q', 'cfuse', '/etc/mtab', run.Raw(';'),
+                'then',
+                'grep', 'cfuse', '/etc/mtab', run.Raw('|'),
+                'grep', '-o', " /.* fuse", run.Raw('|'),
+                'grep', '-o', "/.* ", run.Raw('|'),
+                'xargs', 'sudo', 'fusermount', '-u', run.Raw(';'),
+                'fi',
+                run.Raw(';'),
+                'killall',
+                '--quiet',
+                '/tmp/cephtest/binary/usr/local/bin/cmon',
+                '/tmp/cephtest/binary/usr/local/bin/cosd',
+                '/tmp/cephtest/binary/usr/local/bin/cmds',
+                '/tmp/cephtest/binary/usr/local/bin/cfuse',
+                run.Raw(';'),
+                'if', 'test', '-e', '/etc/rsyslog.d/80-cephtest.conf',
+                run.Raw(';'),
+                'then',
+                'sudo', 'rm', '-f', '--', '/etc/rsyslog.d/80-cephtest.conf',
+                run.Raw('&&'),
+                'sudo', 'initctl', 'restart', 'rsyslog',
+                run.Raw(';'),
+                'fi',
+                run.Raw(';'),
+                ],
+            wait=False,
+            )
+        nodes[remote.name] = proc
+    
+    for name, proc in nodes.iteritems():
+        log.info('Waiting for %s to finish shutdowns...', name)
+        proc.exitstatus.get()
+    log.info('All daemons killed.')
+
+    nodes = {}
+    log.info('Looking for kernel mounts to handle...')
+    for remote in ctx.cluster.remotes.iterkeys():
+        proc = remote.run(
+            args=[
+                'grep', '-q', " ceph " , '/etc/mtab'
+                ],
+            wait=False,
+            )
+        nodes[remote] = proc
+    kernel_mounts = list()
+    for remote, proc in nodes.iteritems():
+        try:
+            proc.exitstatus.get()
+            log.debug('kernel mount exists on %s', remote.name)
+            kernel_mounts.append(remote)
+        except run.CommandFailedError: # no mounts!
+            log.debug('no kernel mount on %s', remote.name)
+    """
+    properly we should be able to just do a forced unmount,
+    but that doesn't seem to be working, so we'll reboot instead 
+    nodes = {}
+    for remote in kernel_mounts:
+        log.info('clearing kernel mount from %s', remote.name)
+        proc = remote.run(
+            args=[
+                'grep', 'ceph', '/etc/mtab', run.Raw('|'),
+                'grep', '-o', "on /.* type", run.Raw('|'),
+                'grep', '-o', "/.* ", run.Raw('|'),
+                'xargs', 'sudo', 'umount', '-f', run.Raw(';')
+                'fi'
+                ]
+            wait=False
+            )
+        nodes[remote] = proc
+    """
+    nodes = {}
+    
+    for remote in kernel_mounts:
+        log.info('rebooting %s', remote.name)
+        proc = remote.run( # note use of -n to force a no-sync reboot
+            args=['sudo', 'reboot', '-f', '-n'],
+            wait=False
+            )
+        nodes[remote] = proc
+        # we just ignore these procs because reboot -f doesn't actually
+        # send anything back to the ssh client!
+        #for remote, proc in nodes.iteritems():
+        #proc.exitstatus.get()
+    from teuthology.misc import reconnect
+    if kernel_mounts:
+        log.info('waiting for nodes to reboot')
+        time.sleep(5) #if we try and reconnect too quickly, it succeeds!
+        reconnect(ctx, 300)     #allow 5 minutes for the reboots
+
+
+    nodes = {}
+    log.info('Clearing filesystem of test data...')
+    for remote in ctx.cluster.remotes.iterkeys():
+        proc = remote.run(
+            args=[
+                'sudo', 'rm', '-rf', '/tmp/cephtest',
+                ],
+            wait=False,
+            )
+        nodes[remote.name] = proc
+
+    for name, proc in nodes.iteritems():
+        log.info('Waiting for %s to clear filesystem...', name)
+        proc.exitstatus.get()
+    log.info('Filesystem Cleared.')
index a1938e7b9b20a866f5f664aa82cd51594e1fddf8..f162335d0ce835769eb48b9cbb9c498d92c06417 100644 (file)
@@ -159,152 +159,6 @@ def main():
             with file(os.path.join(ctx.archive, 'summary.yaml'), 'w') as f:
                 yaml.safe_dump(ctx.summary, f, default_flow_style=False)
 
-
-def nuke():
-    from gevent import monkey; monkey.patch_all()
-    from orchestra import monkey; monkey.patch_all()
-
-    import logging
-    import time
-
-    log = logging.getLogger(__name__)
-    ctx = parse_args()
-
-    loglevel = logging.INFO
-    if ctx.verbose:
-        loglevel = logging.DEBUG
-
-    logging.basicConfig(
-        level=loglevel,
-        )
-
-    from teuthology.misc import read_config
-    read_config(ctx)
-
-    log.info('\n  '.join(['targets:', ] + yaml.safe_dump(ctx.config['targets'], default_flow_style=False).splitlines()))
-
-    if ctx.owner is None:
-        from teuthology.misc import get_user
-        ctx.owner = get_user()
-
-    from teuthology.task.internal import check_lock, connect
-    check_lock(ctx, None)
-    connect(ctx, None)
-
-    log.info('Unmount cfuse and killing daemons...')
-
-    from orchestra import run
-    nodes = {}
-    for remote in ctx.cluster.remotes.iterkeys():
-        proc = remote.run(
-            args=[
-                'if', 'grep', '-q', 'cfuse', '/etc/mtab', run.Raw(';'),
-                'then',
-                'grep', 'cfuse', '/etc/mtab', run.Raw('|'),
-                'grep', '-o', " /.* fuse", run.Raw('|'),
-                'grep', '-o', "/.* ", run.Raw('|'),
-                'xargs', 'sudo', 'fusermount', '-u', run.Raw(';'),
-                'fi',
-                run.Raw(';'),
-                'killall',
-                '--quiet',
-                '/tmp/cephtest/binary/usr/local/bin/cmon',
-                '/tmp/cephtest/binary/usr/local/bin/cosd',
-                '/tmp/cephtest/binary/usr/local/bin/cmds',
-                '/tmp/cephtest/binary/usr/local/bin/cfuse',
-                run.Raw(';'),
-                'if', 'test', '-e', '/etc/rsyslog.d/80-cephtest.conf',
-                run.Raw(';'),
-                'then',
-                'sudo', 'rm', '-f', '--', '/etc/rsyslog.d/80-cephtest.conf',
-                run.Raw('&&'),
-                'sudo', 'initctl', 'restart', 'rsyslog',
-                run.Raw(';'),
-                'fi',
-                run.Raw(';'),
-                ],
-            wait=False,
-            )
-        nodes[remote.name] = proc
-
-    for name, proc in nodes.iteritems():
-        log.info('Waiting for %s to finish shutdowns...', name)
-        proc.exitstatus.get()
-    log.info('Shutdowns Done.')
-
-    nodes = {}
-    log.info('Looking for kernel mounts to handle...')
-    for remote in ctx.cluster.remotes.iterkeys():
-        proc = remote.run(
-            args=[
-                'grep', '-q', " ceph " , '/etc/mtab'
-                ],
-            wait=False,
-            )
-        nodes[remote] = proc
-    kernel_mounts = list()
-    for remote, proc in nodes.iteritems():
-        try:
-            proc.exitstatus.get()
-            log.debug('kernel mount exists on %s', remote.name)
-            kernel_mounts.append(remote)
-        except run.CommandFailedError: # no mounts!
-            log.debug('no kernel mount on %s', remote.name)
-    """
-    properly we should be able to just do a forced unmount,
-    but that doesn't seem to be working, so we'll reboot instead 
-    nodes = {}
-    for remote in kernel_mounts:
-        log.info('clearing kernel mount from %s', remote.name)
-        proc = remote.run(
-            args=[
-                'grep', 'ceph', '/etc/mtab', run.Raw('|'),
-                'grep', '-o', "on /.* type", run.Raw('|'),
-                'grep', '-o', "/.* ", run.Raw('|'),
-                'xargs', 'sudo', 'umount', '-f', run.Raw(';')
-                'fi'
-                ]
-            wait=False
-            )
-        nodes[remote] = proc
-    """
-    nodes = {}
-    
-    for remote in kernel_mounts:
-        log.info('rebooting %s', remote.name)
-        proc = remote.run( # note use of -n to force a no-sync reboot
-            args=['sudo', 'reboot', '-f', '-n'],
-            wait=False
-            )
-        nodes[remote] = proc
-        # we just ignore these procs because reboot -f doesn't actually
-        # send anything back to the ssh client!
-        #for remote, proc in nodes.iteritems():
-        #proc.exitstatus.get()
-    from teuthology.misc import reconnect
-    if kernel_mounts:
-        log.info('waiting for nodes to reboot')
-        time.sleep(5) #if we try and reconnect too quickly, it succeeds!
-        reconnect(ctx, 300)     #allow 5 minutes for the reboots
-
-
-    nodes = {}
-    log.info('Clearing filesystem of test data...')
-    for remote in ctx.cluster.remotes.iterkeys():
-        proc = remote.run(
-            args=[
-                'sudo', 'rm', '-rf', '/tmp/cephtest',
-                ],
-            wait=False,
-            )
-        nodes[remote.name] = proc
-
-    for name, proc in nodes.iteritems():
-        log.info('Waiting for %s to clear filesystem...', name)
-        proc.exitstatus.get()
-    log.info('Filesystem Cleared.')
-
-
 def schedule():
     parser = argparse.ArgumentParser(description='Schedule ceph integration tests')
     parser.add_argument(