]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move internal.check_lock to its own module
authorZack Cerza <zack@redhat.com>
Thu, 17 Mar 2016 20:27:51 +0000 (14:27 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 1 Nov 2016 22:46:54 +0000 (16:46 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/task/internal/__init__.py
teuthology/task/internal/check_lock.py [new file with mode: 0644]

index 5187402d31690756b36d8f091297decb2d220ac3..89bcef96502ef592014f363d4205bd66d922272f 100644 (file)
@@ -12,7 +12,6 @@ import yaml
 import subprocess
 
 from teuthology import lock
-from teuthology import lockstatus
 from teuthology import misc
 from teuthology.packaging import get_builder_project
 from teuthology import report
@@ -65,33 +64,6 @@ def save_config(ctx, config):
             yaml.safe_dump(ctx.config, f, default_flow_style=False)
 
 
-def check_lock(ctx, config, check_up=True):
-    """
-    Check lock status of remote machines.
-    """
-    if not teuth_config.lock_server or ctx.config.get('check-locks') is False:
-        log.info('Lock checking disabled.')
-        return
-    log.info('Checking locks...')
-    for machine in ctx.config['targets'].iterkeys():
-        status = lockstatus.get_status(machine)
-        log.debug('machine status is %s', repr(status))
-        assert status is not None, \
-            'could not read lock status for {name}'.format(name=machine)
-        if check_up:
-            assert status['up'], 'machine {name} is marked down'.format(
-                name=machine
-            )
-        assert status['locked'], \
-            'machine {name} is not locked'.format(name=machine)
-        assert status['locked_by'] == ctx.owner, \
-            'machine {name} is locked by {user}, not {owner}'.format(
-                name=machine,
-                user=status['locked_by'],
-                owner=ctx.owner,
-            )
-
-
 def check_packages(ctx, config):
     """
     Checks gitbuilder to determine if there are missing packages for this job.
diff --git a/teuthology/task/internal/check_lock.py b/teuthology/task/internal/check_lock.py
new file mode 100644 (file)
index 0000000..da7ceb3
--- /dev/null
@@ -0,0 +1,34 @@
+import logging
+
+from teuthology import lockstatus
+
+from teuthology.config import config as teuth_config
+
+log = logging.getLogger(__name__)
+
+
+def check_lock(ctx, config, check_up=True):
+    """
+    Check lock status of remote machines.
+    """
+    if not teuth_config.lock_server or ctx.config.get('check-locks') is False:
+        log.info('Lock checking disabled.')
+        return
+    log.info('Checking locks...')
+    for machine in ctx.config['targets'].iterkeys():
+        status = lockstatus.get_status(machine)
+        log.debug('machine status is %s', repr(status))
+        assert status is not None, \
+            'could not read lock status for {name}'.format(name=machine)
+        if check_up:
+            assert status['up'], 'machine {name} is marked down'.format(
+                name=machine
+            )
+        assert status['locked'], \
+            'machine {name} is not locked'.format(name=machine)
+        assert status['locked_by'] == ctx.owner, \
+            'machine {name} is locked by {user}, not {owner}'.format(
+                name=machine,
+                user=status['locked_by'],
+                owner=ctx.owner,
+            )