From e3adaa648ab5cea47e8495d3a7b62376f2140371 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 9 Jan 2014 14:05:32 -0600 Subject: [PATCH] Ensure the id attribute is returned for a node --- library/cloud/rax_clb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/cloud/rax_clb b/library/cloud/rax_clb index 65435a42be4..56d7f62d78e 100644 --- a/library/cloud/rax_clb +++ b/library/cloud/rax_clb @@ -118,7 +118,6 @@ EXAMPLES = ''' ''' import sys -import os 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'] +def node_to_dict(obj): + node = obj.to_dict() + node['id'] = obj.id + return node + + def to_dict(obj): instance = {} for key in dir(obj): @@ -151,7 +156,7 @@ def to_dict(obj): elif key == 'nodes': instance[key] = [] for node in value: - instance[key].append(node.to_dict()) + instance[key].append(node_to_dict(node)) elif (isinstance(value, NON_CALLABLES) and not key.startswith('_')): instance[key] = value