1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Remove itervalues (not available on py3)

This commit is contained in:
Toshio Kuratomi 2016-12-13 05:28:21 -08:00
parent a8af6c6baf
commit 51491c9904
4 changed files with 9 additions and 9 deletions

View file

@ -26,7 +26,7 @@ import re
import os import os
import ConfigParser import ConfigParser
from novaclient import client as nova_client from novaclient import client as nova_client
from six import iteritems from six import iteritems, itervalues
try: try:
import json import json
@ -105,7 +105,7 @@ def get_ips(server, access_ip=True):
# Iterate through each servers network(s), get addresses and get type # Iterate through each servers network(s), get addresses and get type
addresses = getattr(server, 'addresses', {}) addresses = getattr(server, 'addresses', {})
if len(addresses) > 0: if len(addresses) > 0:
for network in addresses.itervalues(): for network in itervalues(addresses):
for address in network: for address in network:
if address.get('OS-EXT-IPS:type', False) == 'fixed': if address.get('OS-EXT-IPS:type', False) == 'fixed':
private.append(address['addr']) private.append(address['addr'])

View file

@ -379,7 +379,7 @@ def main():
# Finally, remove anything left in the groupRules -- these will be defunct rules # Finally, remove anything left in the groupRules -- these will be defunct rules
if purge_rules: if purge_rules:
for (rule, grant) in groupRules.itervalues() : for (rule, grant) in groupRules.values():
grantGroup = None grantGroup = None
if grant.group_id: if grant.group_id:
if grant.owner_id != group.owner_id: if grant.owner_id != group.owner_id:
@ -456,7 +456,7 @@ def main():
# Finally, remove anything left in the groupRules -- these will be defunct rules # Finally, remove anything left in the groupRules -- these will be defunct rules
if purge_rules_egress: if purge_rules_egress:
for (rule, grant) in groupRules.itervalues(): for (rule, grant) in groupRules.values():
grantGroup = None grantGroup = None
if grant.group_id: if grant.group_id:
grantGroup = groups[grant.group_id].id grantGroup = groups[grant.group_id].id

View file

@ -388,7 +388,7 @@ class LXDContainerManagement(object):
@staticmethod @staticmethod
def _has_all_ipv4_addresses(addresses): def _has_all_ipv4_addresses(addresses):
return len(addresses) > 0 and all([len(v) > 0 for v in addresses.itervalues()]) return len(addresses) > 0 and all([len(v) > 0 for v in addresses.values()])
def _get_addresses(self): def _get_addresses(self):
try: try:

View file

@ -94,7 +94,7 @@ def get_networks(session):
recs = session.xenapi.network.get_all_records() recs = session.xenapi.network.get_all_records()
xs_networks = {} xs_networks = {}
networks = change_keys(recs, key='uuid') networks = change_keys(recs, key='uuid')
for network in networks.itervalues(): for network in networks.values():
xs_networks[network['name_label']] = network xs_networks[network['name_label']] = network
return xs_networks return xs_networks
@ -104,7 +104,7 @@ def get_pifs(session):
pifs = change_keys(recs, key='uuid') pifs = change_keys(recs, key='uuid')
xs_pifs = {} xs_pifs = {}
devicenums = range(0, 7) devicenums = range(0, 7)
for pif in pifs.itervalues(): for pif in pifs.values():
for eth in devicenums: for eth in devicenums:
interface_name = "eth%s" % (eth) interface_name = "eth%s" % (eth)
bond_name = interface_name.replace('eth', 'bond') bond_name = interface_name.replace('eth', 'bond')
@ -151,7 +151,7 @@ def get_vms(session):
return None return None
vms = change_keys(recs, key='uuid') vms = change_keys(recs, key='uuid')
for vm in vms.itervalues(): for vm in vms.values():
xs_vms[vm['name_label']] = vm xs_vms[vm['name_label']] = vm
return xs_vms return xs_vms
@ -162,7 +162,7 @@ def get_srs(session):
if not recs: if not recs:
return None return None
srs = change_keys(recs, key='uuid') srs = change_keys(recs, key='uuid')
for sr in srs.itervalues(): for sr in srs.values():
xs_srs[sr['name_label']] = sr xs_srs[sr['name_label']] = sr
return xs_srs return xs_srs