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

Ensure the id attribute is returned for a node

This commit is contained in:
Matt Martz 2014-01-09 14:05:32 -06:00
parent 3ed902eee2
commit e3adaa648a

View file

@ -118,7 +118,6 @@ EXAMPLES = '''
''' '''
import sys import sys
import os
from types import NoneType from types import NoneType
@ -136,6 +135,12 @@ PROTOCOLS = ['DNS_TCP', 'DNS_UDP', 'FTP', 'HTTP', 'HTTPS', 'IMAPS', 'IMAPv4',
'TCP_CLIENT_FIRST', 'UDP', 'UDP_STREAM', 'SFTP'] 'TCP_CLIENT_FIRST', 'UDP', 'UDP_STREAM', 'SFTP']
def node_to_dict(obj):
node = obj.to_dict()
node['id'] = obj.id
return node
def to_dict(obj): def to_dict(obj):
instance = {} instance = {}
for key in dir(obj): for key in dir(obj):
@ -151,7 +156,7 @@ def to_dict(obj):
elif key == 'nodes': elif key == 'nodes':
instance[key] = [] instance[key] = []
for node in value: for node in value:
instance[key].append(node.to_dict()) instance[key].append(node_to_dict(node))
elif (isinstance(value, NON_CALLABLES) and elif (isinstance(value, NON_CALLABLES) and
not key.startswith('_')): not key.startswith('_')):
instance[key] = value instance[key] = value