]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Moves node: remote mapping to the internal task.
authorGregory Meno <gregory.meno@inktank.com>
Thu, 24 Apr 2014 20:18:59 +0000 (13:18 -0700)
committerGregory Meno <gregory.meno@inktank.com>
Tue, 29 Apr 2014 12:09:07 +0000 (05:09 -0700)
teuthology/task/interactive.py
teuthology/task/internal.py

index a38411577ec995b3b8228bf889b015a731e668e1..dd1676e49a850a7b674868b464f1df3e3dee24f4 100644 (file)
@@ -6,8 +6,6 @@ import readline
 import rlcompleter
 rlcompleter.__name__ # silence pyflakes
 import pprint
-import yaml
-import os
 
 readline.parse_and_bind('tab: complete')
 
@@ -30,11 +28,6 @@ def task(ctx, config):
         - interactive:
     """
 
-    # TODO perhaps this would be better in the install task
-    if ctx.archive is not None:
-        with file(os.path.join(ctx.archive, 'cluster.yaml'), 'w') as f:
-            yaml.safe_dump({'cluster': dict([(x.name,y) for x,y in ctx.cluster.remotes.iteritems()])}, f, default_flow_style=False)
-
     pp = pprint.PrettyPrinter().pprint
     code.interact(
         banner='Ceph test interactive mode, use ctx to interact with the cluster, press control-D to exit...',
index d4df0b45ad0a4223abc6f989d2a9c3c25a1cb79f..b13abfb3b832344701d3c5e941c9a8b204400698 100644 (file)
@@ -231,6 +231,22 @@ 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):
+    """
+    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)
+
+
 def check_ceph_data(ctx, config):
     """
     Check for old /var/lib/ceph directories and detect staleness.