From: Zack Cerza Date: Thu, 17 Mar 2016 20:27:51 +0000 (-0600) Subject: Move internal.check_lock to its own module X-Git-Tag: 1.1.0~509^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1ca2877ef13337263150965804351de72aa09682;p=teuthology.git Move internal.check_lock to its own module Signed-off-by: Zack Cerza --- diff --git a/teuthology/task/internal/__init__.py b/teuthology/task/internal/__init__.py index 5187402d3..89bcef965 100644 --- a/teuthology/task/internal/__init__.py +++ b/teuthology/task/internal/__init__.py @@ -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 index 000000000..da7ceb332 --- /dev/null +++ b/teuthology/task/internal/check_lock.py @@ -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, + )