This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

The nova.network.manager Module

Network Hosts are responsible for allocating ips and setting up network.

There are multiple backend drivers that handle specific types of networking topologies. All of the network commands are issued to a subclass of NetworkManager.

Related Flags

network_driver:Driver to use for network creation
flat_network_bridge:
 Bridge device for simple network instances
flat_interface:FlatDhcp will bridge into this interface if set
flat_network_dns:
 Dns for simple network
vlan_start:First VLAN for private networks
vpn_ip:Public IP for the cloudpipe VPN servers
vpn_start:First Vpn port for private networks
cnt_vpn_clients:
 Number of addresses reserved for vpn clients
network_size:Number of addresses in each private subnet
floating_range:Floating IP address block
fixed_range:Fixed IP address block
date_dhcp_on_disassociate:
 Whether to update dhcp when fixed_ip is disassociated
fixed_ip_disassociate_timeout:
 Seconds after which a deallocated ip is disassociated
create_unique_mac_address_attempts:
 Number of times to attempt creating a unique mac address
exception nova.network.manager.AddressAlreadyAllocated(message=None)

Bases: nova.exception.Error

Address was already allocated.

class nova.network.manager.FlatDHCPManager(network_driver=None, *args, **kwargs)

Bases: nova.network.manager.FloatingIP, nova.network.manager.RPCAllocateFixedIP, nova.network.manager.NetworkManager

Flat networking with dhcp.

FlatDHCPManager will start up one dhcp server to give out addresses. It never injects network settings into the guest. It also manages bridges. Otherwise it behaves like FlatManager.

init_host()

Do any initialization that needs to be run if this is a standalone service.

class nova.network.manager.FlatManager(network_driver=None, *args, **kwargs)

Bases: nova.network.manager.NetworkManager

Basic network where no vlans are used.

FlatManager does not do any bridge or vlan creation. The user is responsible for setting up whatever bridges are specified when creating networks through nova-manage. This bridge needs to be created on all compute hosts.

The idea is to create a single network for the host with a command like: nova-manage network create 192.168.0.0/24 1 256. Creating multiple networks for for one manager is currently not supported, but could be added by modifying allocate_fixed_ip and get_network to get the a network with new logic instead of network_get_by_bridge. Arbitrary lists of addresses in a single network can be accomplished with manual db editing.

If flat_injected is True, the compute host will attempt to inject network config into the guest. It attempts to modify /etc/network/interfaces and currently only works on debian based systems. To support a wider range of OSes, some other method may need to be devised to let the guest know which ip it should be using so that it can configure itself. Perhaps an attached disk or serial device with configuration info.

Metadata forwarding must be handled by the gateway, and since nova does not do any setup in this mode, it must be done manually. Requests to 169.254.169.254 port 80 will need to be forwarded to the api server.

deallocate_fixed_ip(context, address, **kwargs)

Returns a fixed ip to the pool.

class nova.network.manager.FloatingIP

Bases: object

Mixin class for adding floating IP functionality to a manager.

allocate_floating_ip(context, project_id)

Gets an floating ip from the pool.

allocate_for_instance(context, **kwargs)

Handles allocating the floating IP resources for an instance.

calls super class allocate_for_instance() as well

rpc.called by network_api

associate_floating_ip(context, floating_address, fixed_address)

Associates an floating ip to a fixed ip.

deallocate_floating_ip(context, floating_address)

Returns an floating ip to the pool.

deallocate_for_instance(context, **kwargs)

Handles deallocating floating IP resources for an instance.

calls super class deallocate_for_instance() as well.

rpc.called by network_api

disassociate_floating_ip(context, floating_address)

Disassociates a floating ip.

init_host_floating_ips()

Configures floating ips owned by host.

class nova.network.manager.NetworkManager(network_driver=None, *args, **kwargs)

Bases: nova.manager.SchedulerDependentManager

Implements common network manager functionality.

This class must be subclassed to support specific topologies.

host management:
hosts configure themselves for networks they are assigned to in the table upon startup. If there are networks in the table which do not have hosts, those will be filled in and have hosts configured as the hosts pick them up one at time during their periodic task. The one at a time part is to flatten the layout to help scale
add_fixed_ip_to_instance(context, instance_id, host, network_id)

Adds a fixed ip to an instance from specified network.

add_virtual_interface(context, instance_id, network_id)
allocate_fixed_ip(context, instance_id, network, **kwargs)

Gets a fixed ip from the pool.

allocate_for_instance(context, **kwargs)

Handles allocating the various network resources for an instance.

rpc.called by network_api

create_networks(context, label, cidr, multi_host, num_networks, network_size, cidr_v6, gateway_v6, bridge, bridge_interface, dns1=None, dns2=None, **kwargs)

Create networks based on parameters.

deallocate_fixed_ip(context, address, **kwargs)

Returns a fixed ip to the pool.

deallocate_for_instance(context, **kwargs)

Handles deallocating various network resources for an instance.

rpc.called by network_api kwargs can contain fixed_ips to circumvent another db lookup

delete_network(context, fixed_range, require_disassociated=True)
generate_mac_address()

Generate an Ethernet MAC address.

get_instance_nw_info(context, instance_id, instance_type_id, host)

Creates network info list for instance.

called by allocate_for_instance and netowrk_api context needs to be elevated :returns: network info list [(network,info),(network,info)...] where network = dict containing pertinent data from a network db object and info = dict containing pertinent networking data

init_host()

Do any initialization that needs to be run if this is a standalone service.

lease_fixed_ip(context, address)

Called by dhcp-bridge when ip is leased.

periodic_tasks(context=None)

Tasks to be run at a periodic interval.

release_fixed_ip(context, address)

Called by dhcp-bridge when ip is released.

remove_fixed_ip_from_instance(context, instance_id, address)

Removes a fixed ip from an instance from specified network.

set_network_host(context, network_ref)

Safely sets the host of the network.

validate_networks(context, networks)

check if the networks exists and host is set to each network.

class nova.network.manager.RPCAllocateFixedIP

Bases: object

Mixin class originally for FlatDCHP and VLAN network managers.

used since they share code to RPC.call allocate_fixed_ip on the correct network host to configure dnsmasq

class nova.network.manager.VlanManager(network_driver=None, *args, **kwargs)

Bases: nova.network.manager.RPCAllocateFixedIP, nova.network.manager.FloatingIP, nova.network.manager.NetworkManager

Vlan network with dhcp.

VlanManager is the most complicated. It will create a host-managed vlan for each project. Each project gets its own subnet. The networks and associated subnets are created with nova-manage using a command like: nova-manage network create 10.0.0.0/8 3 16. This will create 3 networks of 16 addresses from the beginning of the 10.0.0.0 range.

A dhcp server is run for each subnet, so each project will have its own. For this mode to be useful, each project will need a vpn to access the instances in its subnet.

add_network_to_project(context, project_id)

Force adds another network to a project.

allocate_fixed_ip(context, instance_id, network, **kwargs)

Gets a fixed ip from the pool.

create_networks(context, **kwargs)

Create networks based on parameters.

init_host()

Do any initialization that needs to be run if this is a standalone service.