[openstack-dev] in which function does neutronv2 assign IP address for instance?

Ihar Hrachyshka ihrachys at redhat.com
Wed Jan 6 11:44:40 UTC 2016

张晨 <zhangchen9211 at 126.com> wrote:

> hi everyone,
> i have a question for the neutron code in liberty: how does neutron  
> assign IP address for instance?
> in nova.network, it seems that neutron sever gets a feasible ip from the  
> DB pool, which looks like this:
> nova.compute.manager.ComputeVirtAPI._allocate_network_async() ->  
> nova.network.api.API.allocate_for_instance() ->  
> nova.network.manager.NetworkManager.allocate_for_instance() ->  
> nova.network..manager.NetworkManager_allocate_fixed_ips()
> but in nova.network.neutronv2.0, It looks like this:
> nova.compute.manager.ComputeVirtAPI._allocate_network_async() ->  
> neutronv2.api.allocate_for_instance()
> and it seems that  in neutronv2.api.allocate_for_instance(), it doesn't  
> fetch IP address from DB if the para "fixed_ip" == none in  
> allocate_for_instance, but directly calls "_create_port" for a REST API.
> so my question is whether neutron server will surely assign a fixed IP  
> from DB for instance? Or else, it allows the DHCP agent to take over the  
> IP-MAC selection?

Neutron will always pre-allocate a specific address for a port. DHCP  
service does not work with ranges that it manages, but relies on Neutron to  
provide specific mac-to-IP mappings for each port.

Specific IP addresses are allocated for ports by calling to IPAM driver:  


More information about the OpenStack-dev mailing list