From ce778848a5d0e6c7afffbe44d4c3694aadde45bb Mon Sep 17 00:00:00 2001 From: Gregory Meno Date: Tue, 29 Apr 2014 04:20:51 -0700 Subject: [PATCH] Changes invocation of serialize_remote_roles to internal task to avoid being run during nuke --- teuthology/run.py | 1 + teuthology/task/internal.py | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/teuthology/run.py b/teuthology/run.py index 42146edf53c56..e828e375b088b 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -134,6 +134,7 @@ def main(ctx): {'internal.save_config': None}, {'internal.check_lock': None}, {'internal.connect': None}, + {'internal.serialize_remote_roles': None}, {'internal.check_conflict': None}, ]) if not ctx.config.get('use_existing_cluster', False): diff --git a/teuthology/task/internal.py b/teuthology/task/internal.py index b13abfb3b8323..533d98a3ab1fa 100644 --- a/teuthology/task/internal.py +++ b/teuthology/task/internal.py @@ -231,20 +231,18 @@ def connect(ctx, config): for rem in remotes: ctx.cluster.add(rem, rem.name) - if hasattr(ctx, 'archive'): # connect is called in many invocations e.g. -nuke. We don't want write this then - serialize_remote_roles(ctx) -def serialize_remote_roles(ctx): +def serialize_remote_roles(ctx, config): """ Provides an explicit mapping for which remotes have been assigned what roles So that other software can be loosely coupled to teuthology """ - assert hasattr(ctx, 'archive') - if ctx.archive is not None: - with file(os.path.join(ctx.archive, 'info.yaml'), 'a') as info: - role_map = {'cluster': dict([(remote.name, {'roles': roles}) for remote, roles in ctx.cluster.remotes.iteritems()])} - yaml.safe_dump(role_map, info, default_flow_style=False) + with file(os.path.join(ctx.archive, 'info.yaml'), 'r+') as info_file: + info_yaml = yaml.safe_load(info_file) + info_file.seek(0) + info_yaml['cluster'] = dict([(remote.name, {'roles': roles}) for remote, roles in ctx.cluster.remotes.iteritems()]) + yaml.safe_dump(info_yaml, info_file, default_flow_style=False) def check_ceph_data(ctx, config): -- 2.47.3