#NEWLINE# def _allocate_fixed_ips( self , context , instance_id , host , networks , **kwargs ) : #NEWLINE# #INDENT# 'Calls allocate_fixed_ip once for each network.' #NEWLINE# green_pool = greenpool . GreenPool ( ) #NEWLINE# vpn = kwargs . get ( 'vpn' ) #NEWLINE# requested_networks = kwargs . get ( 'requested_networks' ) #NEWLINE# for network in networks : #NEWLINE# #INDENT# address = None #NEWLINE# if ( requested_networks is not None ) : #NEWLINE# #INDENT# for address in ( fixed_ip for ( uuid , fixed_ip ) in requested_networks if ( network [ 'uuid' ] == uuid ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# if ( not network [ 'multi_host' ] ) : #NEWLINE# #INDENT# host = network [ 'host' ] #NEWLINE# #UNINDENT# if ( host == None ) : #NEWLINE# #INDENT# host = rpc . call ( context , FLAGS . network_topic , { #NEWLINE# #INDENT# 'method' : 'set_network_host' , #NEWLINE# 'args' : { #NEWLINE# #INDENT# 'network_ref' : network , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if ( host != self . host ) : #NEWLINE# #INDENT# topic = self . db . queue_get_for ( context , FLAGS . network_topic , host ) #NEWLINE# args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# args [ 'instance_id' ] = instance_id #NEWLINE# args [ 'network_id' ] = network [ 'id' ] #NEWLINE# args [ 'address' ] = address #NEWLINE# args [ 'vpn' ] = vpn #NEWLINE# green_pool . spawn_n ( rpc . call , context , topic , { #NEWLINE# #INDENT# 'method' : '_rpc_allocate_fixed_ip' , #NEWLINE# 'args' : args , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . allocate_fixed_ip ( context , instance_id , network , vpn = vpn , address = address ) #NEWLINE# #UNINDENT# #UNINDENT# green_pool . waitall ( )