#NEWLINE# def _create_and_allocate_ipam_subnet( self , cidr , allocation_pools = constants . ATTR_NOT_SPECIFIED , ip_version = 4 , v6_auto_address = False , tenant_id = None ) : #NEWLINE# #INDENT# v6_address_mode = constants . ATTR_NOT_SPECIFIED #NEWLINE# if v6_auto_address : #NEWLINE# #INDENT# ip_version = 6 #NEWLINE# v6_address_mode = n_const . IPV6_SLAAC #NEWLINE# #UNINDENT# subnet = self . _create_subnet ( self . plugin , self . ctx , self . net_id , cidr , ip_version = ip_version , allocation_pools = allocation_pools , v6_address_mode = v6_address_mode ) #NEWLINE# allocation_pool_ranges = [ netaddr . IPRange ( pool [ 'start' ] , pool [ 'end' ] ) for pool in subnet [ 'allocation_pools' ] ] #NEWLINE# subnet_req = ipam_req . SpecificSubnetRequest ( tenant_id , subnet [ 'id' ] , cidr , gateway_ip = subnet [ 'gateway_ip' ] , allocation_pools = allocation_pool_ranges ) #NEWLINE# ipam_subnet = self . ipam_pool . allocate_subnet ( subnet_req ) #NEWLINE# return ( ipam_subnet , subnet )