Replace .iteritems() with six.iteritems()

Replace .iteritems() with six.iteritems() everywhere except in
module_utils (because there's no 'six' on the remote host).  And except
in lib/ansible/galaxy/data/metadata_template.j2, because I'm not sure
six is available there.
This commit is contained in:
Marius Gedminas 2015-09-03 09:23:27 +03:00
commit 823677b490
28 changed files with 81 additions and 41 deletions

View file

@ -72,6 +72,8 @@ try:
except ImportError:
import simplejson as json
from six import iteritems
# NOTE -- this file assumes Ansible is being accessed FROM the cobbler
# server, so it does not attempt to login with a username and password.
# this will be addressed in a future version of this script.
@ -171,7 +173,7 @@ class CobblerInventory(object):
interfaces = host['interfaces']
# hostname is often empty for non-static IP hosts
if dns_name == '':
for (iname, ivalue) in interfaces.iteritems():
for (iname, ivalue) in iteritems(interfaces):
if ivalue['management'] or not ivalue['static']:
this_dns_name = ivalue.get('dns_name', None)
if this_dns_name is not None and this_dns_name is not "":
@ -203,7 +205,7 @@ class CobblerInventory(object):
self.cache[dns_name] = host
if "ks_meta" in host:
for key, value in host["ks_meta"].iteritems():
for key, value in iteritems(host["ks_meta"]):
self.cache[dns_name][key] = value
self.write_to_cache(self.cache, self.cache_path_cache)