#NEWLINE# def _test_auto_schedule( self , host_index ) : #NEWLINE# #INDENT# self . config ( dhcp_agents_per_network = self . max_agents_per_network ) #NEWLINE# scheduler = dhcp_agent_scheduler . ChanceScheduler ( ) #NEWLINE# self . ctx = context . get_admin_context ( ) #NEWLINE# msg = ( 'host_index = %s' % host_index ) #NEWLINE# hosts = [ ( '%s-agent-%s' % ( host_index , i ) ) for i in range ( self . agent_count ) ] #NEWLINE# dhcp_agents = self . _create_and_set_agents_down ( hosts ) #NEWLINE# self . _networks = [ ( '%s-network-%s' % ( host_index , i ) ) for i in range ( self . network_count ) ] #NEWLINE# self . _save_networks ( self . _networks ) #NEWLINE# for ( agent , networks ) in six . iteritems ( self . hosted_networks ) : #NEWLINE# #INDENT# agent_index = self . _extract_index ( agent ) #NEWLINE# for net in networks : #NEWLINE# #INDENT# net_index = self . _extract_index ( net ) #NEWLINE# scheduler . resource_filter . bind ( self . ctx , [ dhcp_agents [ agent_index ] ] , self . _networks [ net_index ] ) #NEWLINE# #UNINDENT# #UNINDENT# retval = scheduler . auto_schedule_networks ( self , self . ctx , hosts [ host_index ] ) #NEWLINE# self . assertEqual ( self . expected_auto_schedule_return_value , retval , message = msg ) #NEWLINE# agent_id = dhcp_agents [ host_index ] . id #NEWLINE# hosted_networks = self . _get_hosted_networks_on_dhcp_agent ( agent_id ) #NEWLINE# hosted_net_ids = [ self . _strip_host_index ( net ) for net in hosted_networks ] #NEWLINE# expected_hosted_networks = self . expected_hosted_networks [ ( 'agent-%s' % host_index ) ] #NEWLINE# self . assertItemsEqual ( hosted_net_ids , expected_hosted_networks , msg )