#NEWLINE# def _generate_opts_per_subnet( self ) : #NEWLINE# #INDENT# options = [ ] #NEWLINE# subnet_index_map = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( self . conf . enable_isolated_metadata or self . conf . force_metadata ) : #NEWLINE# #INDENT# subnet_to_interface_ip = self . _make_subnet_interface_ip_map ( ) #NEWLINE# #UNINDENT# isolated_subnets = self . get_isolated_subnets ( self . network ) #NEWLINE# for ( i , subnet ) in enumerate ( self . network . subnets ) : #NEWLINE# #INDENT# addr_mode = getattr ( subnet , 'ipv6_address_mode' , None ) #NEWLINE# if ( ( not subnet . enable_dhcp ) or ( ( subnet . ip_version == 6 ) and ( addr_mode == n_const . IPV6_SLAAC ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if subnet . dns_nameservers : #NEWLINE# #INDENT# options . append ( self . _format_option ( subnet . ip_version , i , 'dns-server' , ',' . join ( Dnsmasq . _convert_to_literal_addrs ( subnet . ip_version , subnet . dns_nameservers ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# subnet_index_map [ subnet . id ] = i #NEWLINE# #UNINDENT# if ( self . conf . dhcp_domain and ( subnet . ip_version == 6 ) ) : #NEWLINE# #INDENT# options . append ( ( 'tag:tag%s,option6:domain-search,%s' % ( i , '' . join ( self . conf . dhcp_domain ) ) ) ) #NEWLINE# #UNINDENT# gateway = subnet . gateway_ip #NEWLINE# host_routes = [ ] #NEWLINE# for hr in subnet . host_routes : #NEWLINE# #INDENT# if ( hr . destination == constants . IPv4_ANY ) : #NEWLINE# #INDENT# if ( not gateway ) : #NEWLINE# #INDENT# gateway = hr . nexthop #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# host_routes . append ( ( '%s,%s' % ( hr . destination , hr . nexthop ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( self . conf . force_metadata or ( isolated_subnets [ subnet . id ] and self . conf . enable_isolated_metadata and ( subnet . ip_version == 4 ) ) ) : #NEWLINE# #INDENT# subnet_dhcp_ip = subnet_to_interface_ip [ subnet . id ] #NEWLINE# host_routes . append ( ( '%s/32,%s' % ( METADATA_DEFAULT_IP , subnet_dhcp_ip ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not isolated_subnets [ subnet . id ] ) and gateway ) : #NEWLINE# #INDENT# host_routes . append ( ( '%s/32,%s' % ( METADATA_DEFAULT_IP , gateway ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( subnet . ip_version == 4 ) : #NEWLINE# #INDENT# host_routes . extend ( [ ( '%s,0.0.0.0' % s . cidr ) for s in self . network . subnets if ( ( s . ip_version == 4 ) and ( s . cidr != subnet . cidr ) ) ] ) #NEWLINE# if host_routes : #NEWLINE# #INDENT# if gateway : #NEWLINE# #INDENT# host_routes . append ( ( '%s,%s' % ( constants . IPv4_ANY , addr_mode ) ) ) #NEWLINE# #UNINDENT# options . append ( self . _format_option ( subnet . ip_version , i , 'classless-static-route' , ',' . join ( host_routes ) ) ) #NEWLINE# options . append ( self . _format_option ( subnet . ip_version , i , WIN2k3_STATIC_DNS , ',' . join ( host_routes ) ) ) #NEWLINE# #UNINDENT# if gateway : #NEWLINE# #INDENT# options . append ( self . _format_option ( subnet . ip_version , i , 'router' , gateway ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# options . append ( self . _format_option ( subnet . ip_version , i , 'router' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( options , subnet_index_map )