Port has_key to python3 compatible syntax

This commit is contained in:
James Tanner 2016-11-16 14:53:03 -05:00 committed by Toshio Kuratomi
parent c09060e8ff
commit 2d2bb626d4

View file

@ -342,7 +342,7 @@ class GceInventory(object):
if inst is None: if inst is None:
return {} return {}
if inst.extra['metadata'].has_key('items'): if 'items' in inst.extra['metadata']:
for entry in inst.extra['metadata']['items']: for entry in inst.extra['metadata']['items']:
md[entry['key']] = entry['value'] md[entry['key']] = entry['value']
@ -419,7 +419,7 @@ class GceInventory(object):
if zones and zone not in zones: if zones and zone not in zones:
continue continue
if groups.has_key(zone): groups[zone].append(name) if zone in groups: groups[zone].append(name)
else: groups[zone] = [name] else: groups[zone] = [name]
tags = node.extra['tags'] tags = node.extra['tags']
@ -428,25 +428,25 @@ class GceInventory(object):
tag = t[6:] tag = t[6:]
else: else:
tag = 'tag_%s' % t tag = 'tag_%s' % t
if groups.has_key(tag): groups[tag].append(name) if tag in groups: groups[tag].append(name)
else: groups[tag] = [name] else: groups[tag] = [name]
net = node.extra['networkInterfaces'][0]['network'].split('/')[-1] net = node.extra['networkInterfaces'][0]['network'].split('/')[-1]
net = 'network_%s' % net net = 'network_%s' % net
if groups.has_key(net): groups[net].append(name) if net in groups: groups[net].append(name)
else: groups[net] = [name] else: groups[net] = [name]
machine_type = node.size machine_type = node.size
if groups.has_key(machine_type): groups[machine_type].append(name) if machine_type in groups: groups[machine_type].append(name)
else: groups[machine_type] = [name] else: groups[machine_type] = [name]
image = node.image and node.image or 'persistent_disk' image = node.image and node.image or 'persistent_disk'
if groups.has_key(image): groups[image].append(name) if image in groups: groups[image].append(name)
else: groups[image] = [name] else: groups[image] = [name]
status = node.extra['status'] status = node.extra['status']
stat = 'status_%s' % status.lower() stat = 'status_%s' % status.lower()
if groups.has_key(stat): groups[stat].append(name) if stat in groups: groups[stat].append(name)
else: groups[stat] = [name] else: groups[stat] = [name]
groups["_meta"] = meta groups["_meta"] = meta