Skip to content

Commit

Permalink
Port has_key to python3 compatible syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jctanner authored and abadger committed Nov 16, 2016
1 parent c09060e commit 2d2bb62
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions contrib/inventory/gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def node_to_dict(self, inst):
if inst is None:
return {}

if inst.extra['metadata'].has_key('items'):
if 'items' in inst.extra['metadata']:
for entry in inst.extra['metadata']['items']:
md[entry['key']] = entry['value']

Expand Down Expand Up @@ -419,7 +419,7 @@ def group_instances(self, zones=None):
if zones and zone not in zones:
continue

if groups.has_key(zone): groups[zone].append(name)
if zone in groups: groups[zone].append(name)
else: groups[zone] = [name]

tags = node.extra['tags']
Expand All @@ -428,25 +428,25 @@ def group_instances(self, zones=None):
tag = t[6:]
else:
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]

net = node.extra['networkInterfaces'][0]['network'].split('/')[-1]
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]

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]

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]

status = node.extra['status']
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]

groups["_meta"] = meta
Expand Down

0 comments on commit 2d2bb62

Please sign in to comment.