def _get_nets(vif, subnet, version, net_num, link_id):
 if (subnet.get_meta('dhcp_server') is not None):
  net_info = {'id': ('network%d' % net_num), 'type': ('ipv%d_dhcp' % version), 'link': link_id, 'network_id': vif['network']['id']}
  return net_info
 ip = subnet['ips'][0]
 address = ip['address']
 if (version == 4):
  netmask = model.get_netmask(ip, subnet)
 elif (version == 6):
  netmask = str(subnet.as_netaddr().netmask)
 net_info = {'id': ('network%d' % net_num), 'type': ('ipv%d' % version), 'link': link_id, 'ip_address': address, 'netmask': netmask, 'routes': _get_default_route(version, subnet), 'network_id': vif['network']['id']}
 for route in subnet['routes']:
  route_addr = netaddr.IPNetwork(route['cidr'])
  new_route = {'network': str(route_addr.network), 'netmask': str(route_addr.netmask), 'gateway': route['gateway']['address']}
  net_info['routes'].append(new_route)
 return net_info

def _get_nets ( vif , subnet , version , net_num , link_id ) : if ( subnet . get_meta ( 'dhcp_server' ) is not None ) : net_info = { 'id' : ( 'network%d' % net_num ) , 'type' : ( 'ipv%d_dhcp' % version ) , 'link' : link_id , 'network_id' : vif [ 'network' ] [ 'id' ] } return net_info ip = subnet [ 'ips' ] [ 0 ] address = ip [ 'address' ] if ( version == 4 ) : netmask = model . get_netmask ( ip , subnet ) elif ( version == 6 ) : netmask = str ( subnet . as_netaddr ( ) . netmask ) net_info = { 'id' : ( 'network%d' % net_num ) , 'type' : ( 'ipv%d' % version ) , 'link' : link_id , 'ip_address' : address , 'netmask' : netmask , 'routes' : _get_default_route ( version , subnet ) , 'network_id' : vif [ 'network' ] [ 'id' ] } for route in subnet [ 'routes' ] : route_addr = netaddr . IPNetwork ( route [ 'cidr' ] ) new_route = { 'network' : str ( route_addr . network ) , 'netmask' : str ( route_addr . netmask ) , 'gateway' : route [ 'gateway' ] [ 'address' ] } net_info [ 'routes' ] . append ( new_route ) return net_info
get networks for the given vif and subnet .