]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Fix filter_hosts() when no filters are specified
authorZack Cerza <zack@redhat.com>
Mon, 27 Apr 2015 21:54:24 +0000 (15:54 -0600)
committerZack Cerza <zack@redhat.com>
Mon, 27 Apr 2015 21:56:35 +0000 (15:56 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/task/__init__.py
teuthology/test/task/__init__.py

index be462c29787fe0c49cac9be6167719e43a972d35..e9112279f34a9f30e136898138e110d249fb6cb2 100644 (file)
@@ -49,6 +49,9 @@ class Task(object):
         """
         if not hasattr(self.ctx, 'cluster'):
             return
+        elif 'hosts' not in self.config:
+            self.cluster = self.ctx.cluster
+            return self.cluster
         host_specs = self.config.get('hosts', list())
         cluster = Cluster()
         for host_spec in host_specs:
index 21f0ed3cae332136b1633ef78d00e918a4cab273..57b1dc74f9585d8f278d5b234ee1c540f3bdd220 100644 (file)
@@ -26,6 +26,17 @@ class TestTask(object):
             assert task.config['key_1'] == 'overridden'
             assert task.config['key_2'] == 'default'
 
+    def test_hosts_no_filter(self):
+        self.ctx.cluster = Cluster()
+        self.ctx.cluster.add(Remote('remote1'), ['role1'])
+        self.ctx.cluster.add(Remote('remote2'), ['role2'])
+        task_config = dict()
+        with Task(self.ctx, task_config) as task:
+            task_hosts = task.cluster.remotes.keys()
+            assert len(task_hosts) == 2
+            assert task_hosts[0].name == 'remote1'
+            assert task_hosts[1].name == 'remote2'
+
     def test_hosts_no_results(self):
         self.ctx.cluster = Cluster()
         self.ctx.cluster.add(Remote('remote1'), ['role1'])