def network_field_data(request, include_empty_option=False):
 tenant_id = request.user.tenant_id
 networks = []
 if api.base.is_service_enabled(request, 'network'):
  try:
   networks = api.neutron.network_list_for_tenant(request, tenant_id)
   networks = [(n.id, n.name_or_id) for n in networks if n['subnets']]
   networks.sort(key=(lambda obj: obj[1]))
  except Exception as e:
   msg = _('Failed to get network list {0}').format(six.text_type(e))
   exceptions.handle(request, msg)
 if (not networks):
  if include_empty_option:
   return [('', _('No networks available'))]
  return []
 if include_empty_option:
  return ([('', _('Select Network'))] + networks)
 return networks

def network_field_data ( request , include_empty_option = False ) : tenant_id = request . user . tenant_id networks = [ ] if api . base . is_service_enabled ( request , 'network' ) : try : networks = api . neutron . network_list_for_tenant ( request , tenant_id ) networks = [ ( n . id , n . name_or_id ) for n in networks if n [ 'subnets' ] ] networks . sort ( key = ( lambda obj : obj [ 1 ] ) ) except Exception as e : msg = _ ( 'Failed to get network list {0}' ) . format ( six . text_type ( e ) ) exceptions . handle ( request , msg ) if ( not networks ) : if include_empty_option : return [ ( '' , _ ( 'No networks available' ) ) ] return [ ] if include_empty_option : return ( [ ( '' , _ ( 'Select Network' ) ) ] + networks ) return networks
returns a list of tuples of all networks .