def _expand_balancer(lb):
 ret = {}
 ret.update(lb.__dict__)
 hc = ret['extra']['healthchecks']
 ret['extra']['healthchecks'] = []
 for item in hc:
  ret['extra']['healthchecks'].append(_expand_item(item))
 fwr = ret['extra']['forwarding_rule']
 tp = ret['extra']['forwarding_rule'].targetpool
 reg = ret['extra']['forwarding_rule'].region
 ret['extra']['forwarding_rule'] = {}
 ret['extra']['forwarding_rule'].update(fwr.__dict__)
 ret['extra']['forwarding_rule']['targetpool'] = tp.name
 ret['extra']['forwarding_rule']['region'] = reg.name
 tp = ret['extra']['targetpool']
 hc = ret['extra']['targetpool'].healthchecks
 nodes = ret['extra']['targetpool'].nodes
 region = ret['extra']['targetpool'].region
 zones = ret['extra']['targetpool'].region.zones
 ret['extra']['targetpool'] = {}
 ret['extra']['targetpool'].update(tp.__dict__)
 ret['extra']['targetpool']['region'] = _expand_item(region)
 ret['extra']['targetpool']['nodes'] = []
 for n in nodes:
  ret['extra']['targetpool']['nodes'].append(_expand_node(n))
 ret['extra']['targetpool']['healthchecks'] = []
 for hci in hc:
  ret['extra']['targetpool']['healthchecks'].append(hci.name)
 ret['extra']['targetpool']['region']['zones'] = []
 for z in zones:
  ret['extra']['targetpool']['region']['zones'].append(z.name)
 return ret

def _expand_balancer ( lb ) : ret = { } ret . update ( lb . __dict__ ) hc = ret [ 'extra' ] [ 'healthchecks' ] ret [ 'extra' ] [ 'healthchecks' ] = [ ] for item in hc : ret [ 'extra' ] [ 'healthchecks' ] . append ( _expand_item ( item ) ) fwr = ret [ 'extra' ] [ 'forwarding_rule' ] tp = ret [ 'extra' ] [ 'forwarding_rule' ] . targetpool reg = ret [ 'extra' ] [ 'forwarding_rule' ] . region ret [ 'extra' ] [ 'forwarding_rule' ] = { } ret [ 'extra' ] [ 'forwarding_rule' ] . update ( fwr . __dict__ ) ret [ 'extra' ] [ 'forwarding_rule' ] [ 'targetpool' ] = tp . name ret [ 'extra' ] [ 'forwarding_rule' ] [ 'region' ] = reg . name tp = ret [ 'extra' ] [ 'targetpool' ] hc = ret [ 'extra' ] [ 'targetpool' ] . healthchecks nodes = ret [ 'extra' ] [ 'targetpool' ] . nodes region = ret [ 'extra' ] [ 'targetpool' ] . region zones = ret [ 'extra' ] [ 'targetpool' ] . region . zones ret [ 'extra' ] [ 'targetpool' ] = { } ret [ 'extra' ] [ 'targetpool' ] . update ( tp . __dict__ ) ret [ 'extra' ] [ 'targetpool' ] [ 'region' ] = _expand_item ( region ) ret [ 'extra' ] [ 'targetpool' ] [ 'nodes' ] = [ ] for n in nodes : ret [ 'extra' ] [ 'targetpool' ] [ 'nodes' ] . append ( _expand_node ( n ) ) ret [ 'extra' ] [ 'targetpool' ] [ 'healthchecks' ] = [ ] for hci in hc : ret [ 'extra' ] [ 'targetpool' ] [ 'healthchecks' ] . append ( hci . name ) ret [ 'extra' ] [ 'targetpool' ] [ 'region' ] [ 'zones' ] = [ ] for z in zones : ret [ 'extra' ] [ 'targetpool' ] [ 'region' ] [ 'zones' ] . append ( z . name ) return ret
convert the libcloud load-balancer object into something more serializable .