view changes for py3

Python3 changes several methods on dict's to views, requiring us to
convert them to lists.

Change-Id: Ib08c03564f198d1c08142c44bf9baac6a73816dd
diff --git a/tests/base.py b/tests/base.py
index 5b3a79a..f355e50 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -2282,7 +2282,7 @@
 
     def countJobResults(self, jobs, result):
         jobs = filter(lambda x: x.result == result, jobs)
-        return len(jobs)
+        return len(list(jobs))
 
     def getJobFromHistory(self, name, project=None):
         for job in self.history:
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index bc827b3..61e9683 100755
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -3339,7 +3339,7 @@
             if time.time() - start > 10:
                 raise Exception("Timeout waiting for gearman server to report "
                                 + "back to the client")
-            build = self.executor.builds.values()[0]
+            build = list(self.executor.builds.values())[0]
             if build.worker.name == "My Worker":
                 break
             else:
@@ -3512,7 +3512,7 @@
             if time.time() - start > 10:
                 raise Exception("Timeout waiting for gearman server to report "
                                 + "back to the client")
-            build = self.executor_client.builds.values()[0]
+            build = list(self.executor_client.builds.values())[0]
             if build.worker.name == "My Worker":
                 break
             else:
diff --git a/zuul/configloader.py b/zuul/configloader.py
index 070e731..b23846d 100644
--- a/zuul/configloader.py
+++ b/zuul/configloader.py
@@ -111,7 +111,7 @@
         r = super(ZuulSafeLoader, self).construct_mapping(node, deep)
         keys = frozenset(r.keys())
         if len(keys) == 1 and keys.intersection(self.zuul_node_types):
-            d = r.values()[0]
+            d = list(r.values())[0]
             if isinstance(d, dict):
                 d['_start_mark'] = node.start_mark
                 d['_source_context'] = self.zuul_context
@@ -493,7 +493,7 @@
                 attrs = dict(name=conf_job)
             elif isinstance(conf_job, dict):
                 # A dictionary in a job tree may override params
-                jobname, attrs = conf_job.items()[0]
+                jobname, attrs = list(conf_job.items())[0]
                 if attrs:
                     # We are overriding params, so make a new job def
                     attrs['name'] = jobname
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index dfa5a2b..ce156de 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -369,7 +369,7 @@
         self.command_socket.stop()
         self.update_queue.put(None)
 
-        for job_worker in self.job_workers.values():
+        for job_worker in list(self.job_workers.values()):
             try:
                 job_worker.stop()
             except Exception:
diff --git a/zuul/manager/__init__.py b/zuul/manager/__init__.py
index bdfde48..5b32e5b 100644
--- a/zuul/manager/__init__.py
+++ b/zuul/manager/__init__.py
@@ -426,7 +426,7 @@
             build.result = 'CANCELED'
             canceled = True
             canceled_jobs.add(build.job.name)
-        for jobname, nodeset in old_build_set.nodesets.items()[:]:
+        for jobname, nodeset in list(old_build_set.nodesets.items()):
             if jobname in canceled_jobs:
                 continue
             self.sched.nodepool.returnNodeSet(nodeset)
diff --git a/zuul/model.py b/zuul/model.py
index 1e6e45b..ab44047 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -1206,7 +1206,7 @@
         return self.builds.get(job_name)
 
     def getBuilds(self):
-        keys = self.builds.keys()
+        keys = list(self.builds.keys())
         keys.sort()
         return [self.builds.get(x) for x in keys]
 
@@ -2332,7 +2332,7 @@
                 raise Exception("Configuration item dictionaries must have "
                                 "a single key (when parsing %s)" %
                                 (conf,))
-            key, value = item.items()[0]
+            key, value = list(item.items())[0]
             if key == 'tenant':
                 self.tenants.append(value)
             else:
@@ -2390,7 +2390,7 @@
                 raise Exception("Configuration item dictionaries must have "
                                 "a single key (when parsing %s)" %
                                 (conf,))
-            key, value = item.items()[0]
+            key, value = list(item.items())[0]
             if key == 'project':
                 name = value['name']
                 self.projects.setdefault(name, []).append(value)
@@ -2697,7 +2697,7 @@
             if hostname:
                 project = hostname_dict.get(hostname)
             else:
-                values = hostname_dict.values()
+                values = list(hostname_dict.values())
                 if len(values) == 1:
                     project = values[0]
                 else:
diff --git a/zuul/zk.py b/zuul/zk.py
index 5cd7bee..a7616a4 100644
--- a/zuul/zk.py
+++ b/zuul/zk.py
@@ -168,7 +168,7 @@
             if data:
                 data = self._strToDict(data)
                 node_request.updateFromDict(data)
-                request_nodes = node_request.nodeset.getNodes()
+                request_nodes = list(node_request.nodeset.getNodes())
                 for i, nodeid in enumerate(data.get('nodes', [])):
                     node_path = '%s/%s' % (self.NODE_ROOT, nodeid)
                     node_data, node_stat = self.client.get(node_path)