]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
orchestra/daemon: update resolve_role_list() for multi-cluster setups
authorJosh Durgin <jdurgin@redhat.com>
Wed, 16 Mar 2016 06:09:17 +0000 (23:09 -0700)
committerJosh Durgin <jdurgin@redhat.com>
Mon, 11 Apr 2016 21:36:41 +0000 (14:36 -0700)
Add a parameter for backwards compatibility, to determine whether the
returned roles should include the cluster.

Signed-off-by: Josh Durgin <jdurgin@redhat.com>
teuthology/orchestra/daemon.py

index 199b63e5aabaec80871c52f51dd7e87c72a00b01..690aee07bc8b992566a22286348568a97cb147f0 100644 (file)
@@ -2,6 +2,7 @@ import logging
 import struct
 
 from . import run
+from .. import misc
 
 log = logging.getLogger(__name__)
 
@@ -192,7 +193,7 @@ class DaemonGroup(object):
         role = cluster + '.' + type_
         return self.daemons.get(role, {}).values()
 
-    def resolve_role_list(self, roles, types):
+    def resolve_role_list(self, roles, types, cluster_aware=False):
         """
         Resolve a configuration setting that may be None or contain wildcards
         into a list of roles (where a role is e.g. 'mds.a' or 'osd.0').  This
@@ -218,6 +219,10 @@ class DaemonGroup(object):
 
         :param roles: List (of roles or wildcards) or None (select all suitable roles)
         :param types: List of acceptable role types, for example ['osd', 'mds'].
+        :param cluster_aware: bool to determine whether to consider include
+                              cluster in the returned roles - just for
+                              backwards compatibility with pre-jewel versions of
+                              ceph-qa-suite
         :return: List of strings like ["mds.0", "osd.2"]
         """
         assert (isinstance(roles, list) or roles is None)
@@ -226,23 +231,32 @@ class DaemonGroup(object):
         if roles is None:
             # Handle default: all roles available
             for type_ in types:
-                for daemon in self.iter_daemons_of_role(type_):
-                    resolved.append(type_ + '.' + daemon.id_)
+                for role, daemons in self.daemons.items():
+                    if not role.endswith('.' + type_):
+                        continue
+                    for daemon in daemons.values():
+                        prefix = type_
+                        if cluster_aware:
+                            prefix = daemon.role
+                        resolved.append(prefix + daemon.id_)
         else:
             # Handle explicit list of roles or wildcards
             for raw_role in roles:
                 try:
-                    role_type, role_id = raw_role.split(".")
+                    cluster, role_type, role_id = misc.split_role(raw_role)
                 except ValueError:
-                    raise RuntimeError("Invalid role '{0}', roles must be of format <type>.<id>".format(raw_role))
+                    raise RuntimeError("Invalid role '{0}', roles must be of format [<cluster>.]<type>.<id>".format(raw_role))
 
                 if role_type not in types:
                     raise RuntimeError("Invalid role type '{0}' in role '{1}'".format(role_type, raw_role))
 
                 if role_id == "*":
                     # Handle wildcard, all roles of the type
-                    for daemon in self.iter_daemons_of_role(role_type):
-                        resolved.append(role_type + '.' + daemon.id_)
+                    for daemon in self.iter_daemons_of_role(role_type, cluster=cluster):
+                        prefix = role_type
+                        if cluster_aware:
+                            prefix = daemon.role
+                        resolved.append(prefix + daemon.id_)
                 else:
                     # Handle explicit role
                     resolved.append(raw_role)