def get_injected_network_template(network_info, use_ipv6=CONF.use_ipv6, template=CONF.injected_network_template):
 if (network_info is None):
  return None
 if hasattr(network_info, 'legacy'):
  network_info = network_info.legacy()
 nets = []
 ifc_num = (-1)
 have_injected_networks = False
 for (network_ref, mapping) in network_info:
  ifc_num += 1
  if (not network_ref['injected']):
   continue
  have_injected_networks = True
  address = mapping['ips'][0]['ip']
  netmask = mapping['ips'][0]['netmask']
  address_v6 = None
  gateway_v6 = None
  netmask_v6 = None
  if use_ipv6:
   address_v6 = mapping['ip6s'][0]['ip']
   netmask_v6 = mapping['ip6s'][0]['netmask']
   gateway_v6 = mapping['gateway_v6']
  net_info = {'name': ('eth%d' % ifc_num), 'address': address, 'netmask': netmask, 'gateway': mapping['gateway'], 'broadcast': mapping['broadcast'], 'dns': ' '.join(mapping['dns']), 'address_v6': address_v6, 'gateway_v6': gateway_v6, 'netmask_v6': netmask_v6}
  nets.append(net_info)
 if (have_injected_networks is False):
  return None
 if (not template):
  return None
 _late_load_cheetah()
 ifc_template = open(template).read()
 return str(Template(ifc_template, searchList=[{'interfaces': nets, 'use_ipv6': use_ipv6}]))

def get_injected_network_template ( network_info , use_ipv6 = CONF . use_ipv6 , template = CONF . injected_network_template ) : if ( network_info is None ) : return None if hasattr ( network_info , 'legacy' ) : network_info = network_info . legacy ( ) nets = [ ] ifc_num = ( - 1 ) have_injected_networks = False for ( network_ref , mapping ) in network_info : ifc_num += 1 if ( not network_ref [ 'injected' ] ) : continue have_injected_networks = True address = mapping [ 'ips' ] [ 0 ] [ 'ip' ] netmask = mapping [ 'ips' ] [ 0 ] [ 'netmask' ] address_v6 = None gateway_v6 = None netmask_v6 = None if use_ipv6 : address_v6 = mapping [ 'ip6s' ] [ 0 ] [ 'ip' ] netmask_v6 = mapping [ 'ip6s' ] [ 0 ] [ 'netmask' ] gateway_v6 = mapping [ 'gateway_v6' ] net_info = { 'name' : ( 'eth%d' % ifc_num ) , 'address' : address , 'netmask' : netmask , 'gateway' : mapping [ 'gateway' ] , 'broadcast' : mapping [ 'broadcast' ] , 'dns' : ' ' . join ( mapping [ 'dns' ] ) , 'address_v6' : address_v6 , 'gateway_v6' : gateway_v6 , 'netmask_v6' : netmask_v6 } nets . append ( net_info ) if ( have_injected_networks is False ) : return None if ( not template ) : return None _late_load_cheetah ( ) ifc_template = open ( template ) . read ( ) return str ( Template ( ifc_template , searchList = [ { 'interfaces' : nets , 'use_ipv6' : use_ipv6 } ] ) )
return a rendered network template for the given network_info .