Replacing dict.iteritems() with dict.items()

dict.iteritems() of python 2.x has been replaced with
dict.items() of python 3.x to provide compatibility
with both i.e python 2 as well as python 3.

Change-Id: If4611f04cc676a2b47f0fe6f646c2823cb0c4289
This commit is contained in:
sonu.kumar 2015-07-20 18:24:07 +05:30
parent 884d3613af
commit 1a71bb6790
2 changed files with 6 additions and 6 deletions

View File

@ -225,7 +225,7 @@ class IPABackend(base.Backend):
args = {'idnssoamname': servers[0]['name']} args = {'idnssoamname': servers[0]['name']}
if self.force: if self.force:
args['force'] = True args['force'] = True
for dkey, ipakey in domain2ipa.iteritems(): for dkey, ipakey in list(domain2ipa.items()):
if dkey in domain: if dkey in domain:
args[ipakey] = domain[dkey] args[ipakey] = domain[dkey]
ipareq['params'] = [params, args] ipareq['params'] = [params, args]
@ -245,7 +245,7 @@ class IPABackend(base.Backend):
ipareq = {'method': 'dnszone_mod', 'id': 0} ipareq = {'method': 'dnszone_mod', 'id': 0}
params = [domain['name']] params = [domain['name']]
args = {} args = {}
for dkey, ipakey in domain2ipa.iteritems(): for dkey, ipakey in list(domain2ipa.items()):
if dkey in domain: if dkey in domain:
args[ipakey] = domain[dkey] args[ipakey] = domain[dkey]
ipareq['params'] = [params, args] ipareq['params'] = [params, args]

View File

@ -79,7 +79,7 @@ class CannotUseIPABackend(Exception):
# create mapping of ipa record types to designate types # create mapping of ipa record types to designate types
iparectype2designate = {} iparectype2designate = {}
for rectype, tup in impl_ipa.rectype2iparectype.iteritems(): for rectype, tup in list(impl_ipa.rectype2iparectype.items()):
iparectype = tup[0] iparectype = tup[0]
iparectype2designate[iparectype] = rectype iparectype2designate[iparectype] = rectype
@ -195,7 +195,7 @@ def syncipaservers2des(servers, designatereq, designateurl):
(server, pprint.pformat(resp.json()))) (server, pprint.pformat(resp.json())))
# next - delete servers in designate not in ipa # next - delete servers in designate not in ipa
for server, sid in dservers.iteritems(): for server, sid in list(dservers.items()):
if server not in servers: if server not in servers:
delresp = designatereq.delete(srvurl + "/" + sid) delresp = designatereq.delete(srvurl + "/" + sid)
if delresp.status_code == 200: if delresp.status_code == 200:
@ -252,7 +252,7 @@ def main():
zrec['idnszoneactive'][0] == 'TRUE': zrec['idnszoneactive'][0] == 'TRUE':
# ipa returns every data field as a list # ipa returns every data field as a list
# convert the list to a scalar # convert the list to a scalar
for n, v in zrec.iteritems(): for n, v in list(zrec.items()):
if n in zoneskips: if n in zoneskips:
continue continue
if isinstance(v, list): if isinstance(v, list):
@ -345,7 +345,7 @@ def main():
zonerecs[desreq['name']] = resp.json()['id'] zonerecs[desreq['name']] = resp.json()['id']
# get the records for each zone # get the records for each zone
for zonename, domainid in zonerecs.iteritems(): for zonename, domainid in list(zonerecs.items()):
recurl = designateurl + "/domains/" + domainid + "/records" recurl = designateurl + "/domains/" + domainid + "/records"
iparecs = getiparecords(ipabackend, zonename, version) iparecs = getiparecords(ipabackend, zonename, version)
for rec in iparecs: for rec in iparecs: