From: Gregory Meno Date: Tue, 29 Apr 2014 11:20:51 +0000 (-0700) Subject: Changes invocation of serialize_remote_roles to internal task to avoid being run... X-Git-Tag: v0.94.10~27^2^2~364^2~223 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ce778848a5d0e6c7afffbe44d4c3694aadde45bb;p=ceph.git Changes invocation of serialize_remote_roles to internal task to avoid being run during nuke --- diff --git a/teuthology/run.py b/teuthology/run.py index 42146edf53c5..e828e375b088 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 b13abfb3b832..533d98a3ab1f 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):