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
fixed_range:Fixed IP address block
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
class FlatDHCPManager(network_driver=None, *args, **kwargs)

Bases: nova.network.manager.RPCAllocateFixedIP, nova.network.floating_ips.FloatingIP, 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.

DHCP = True
SHOULD_CREATE_BRIDGE = True
init_host()

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

required_create_args = ['bridge']
class 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 network with new logic. 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.

allocate_floating_ip(context, *args, **kwargs)

Gets a floating ip from the pool.

associate_floating_ip(context, *args, **kwargs)

Associates a floating ip with a fixed ip.

Makes sure everything makes sense then calls _associate_floating_ip, rpc’ing to correct host if i’m not it.

deallocate_fixed_ip(context, address, host=None, teardown=True)

Returns a fixed ip to the pool.

deallocate_floating_ip(context, *args, **kwargs)

Returns a floating ip to the pool.

disassociate_floating_ip(context, *args, **kwargs)

Disassociates a floating ip from its fixed ip.

Makes sure everything makes sense then calls _disassociate_floating_ip, rpc’ing to correct host if i’m not it.

get_floating_ip(context, id)

Returns a floating IP as a dict.

get_floating_ip_by_address(context, address)

Returns a floating IP as a dict.

get_floating_ip_pools(context)

Returns list of floating ip pools.

get_floating_ips_by_fixed_address(context, fixed_address)

Returns the floating IPs associated with a fixed_address.

get_floating_ips_by_project(context)

Returns the floating IPs allocated to a project.

get_floating_pools(context)

Returns list of floating pools.

migrate_instance_finish(context, instance_uuid, floating_addresses, host=None, rxtx_factor=None, project_id=None, source=None, dest=None)
migrate_instance_start(context, instance_uuid, floating_addresses, rxtx_factor=None, project_id=None, source=None, dest=None)
required_create_args = ['bridge']
timeout_fixed_ips = False
update_dns(context, network_ids)

Called when fixed IP is allocated or deallocated.

class NetworkManager(network_driver=None, *args, **kwargs)

Bases: nova.manager.Manager

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
DHCP = False
RPC_API_VERSION = '1.9'
SHOULD_CREATE_BRIDGE = False
SHOULD_CREATE_VLAN = False
add_fixed_ip_to_instance(context, instance_id, host, network_id, rxtx_factor=None)

Adds a fixed ip to an instance from specified network.

add_network_to_project(ctxt, project_id, network_uuid)
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

build_network_info_model(context, vifs, networks, rxtx_factor, instance_host)

Builds a NetworkInfo object containing all network information for an instance

create_networks(context, label, cidr=None, multi_host=None, num_networks=None, network_size=None, cidr_v6=None, gateway=None, gateway_v6=None, bridge=None, bridge_interface=None, dns1=None, dns2=None, fixed_cidr=None, **kwargs)
deallocate_fixed_ip(context, address, host=None, teardown=True)

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, uuid, require_disassociated=True)
disassociate_network(context, network_uuid)
get_all_networks(context)
get_backdoor_port(context)

Return backdoor port for eventlet_backdoor.

get_dhcp_leases(ctxt, network_ref)

Broker the request to the driver to fetch the dhcp leases.

get_fixed_ip(context, id)

Return a fixed ip.

get_fixed_ip_by_address(context, address)
get_floating_ips_by_fixed_address(context, fixed_address)
get_instance_id_by_floating_address(context, address)

Returns the instance id a floating ip’s fixed ip is allocated to.

get_instance_nw_info(context, instance_id, rxtx_factor, host, instance_uuid=None, **kwargs)

Creates network info list for instance.

called by allocate_for_instance and network_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

get_instance_uuids_by_ip_filter(context, filters)
get_network(context, network_uuid)
get_vif_by_mac_address(context, mac_address)

Returns the vifs record for the mac_address.

get_vifs_by_instance(context, instance_id)

Returns the vifs associated with an instance.

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.

release_fixed_ip(context, address)

Called by dhcp-bridge when ip is released.

remove_fixed_ip_from_instance(context, instance_id, host, address, rxtx_factor=None)

Removes a fixed ip from an instance from specified network.

required_create_args = []
rpc_setup_network_on_host(context, network_id, teardown)
set_network_host(context, network_ref)

Safely sets the host of the network.

setup_networks_on_host(context, instance_id, host, teardown=False)

calls setup/teardown on network hosts for an instance.

timeout_fixed_ips = True
update_dns(context, network_ids)

Called when fixed IP is allocated or deallocated.

validate_networks(context, networks)

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

class 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

deallocate_fixed_ip(context, address, host=None, teardown=True)

Call the superclass deallocate_fixed_ip if i’m the correct host otherwise call to the correct host

servicegroup_api = None
class VlanManager(network_driver=None, *args, **kwargs)

Bases: nova.network.manager.RPCAllocateFixedIP, nova.network.floating_ips.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.

DHCP = True
SHOULD_CREATE_BRIDGE = True
SHOULD_CREATE_VLAN = True
add_network_to_project(context, project_id, network_uuid=None)

Force adds another network to a project.

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

Gets a fixed ip from the pool.

associate(context, network_uuid, associations)

Associate or disassociate host or project to network.

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.

required_create_args = ['bridge_interface']

Previous topic

The nova.network.linux_net Module

Next topic

The nova.network.minidns Module

This Page