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.

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 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, project_id, pool)

Gets a floating IP from the pool.

associate_floating_ip(context, floating_address, fixed_address, affect_auto_assigned=False)

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, instance=None)

Returns a fixed IP to the pool.

deallocate_floating_ip(context, address, affect_auto_assigned)

Returns a floating IP to the pool.

disassociate_floating_ip(context, address, affect_auto_assigned=False)

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
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

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, allowed_start=None, allowed_end=None, **kwargs)
deallocate_fixed_ip(context, address, host=None, teardown=True, instance=None)

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_instance_id_by_floating_address(context, address)

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

get_instance_nw_info(*args, **kwargs)
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, mac=None)

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, instance=None, teardown=False)

calls setup/teardown on network hosts for an instance.

target = <Target version=1.16>
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, instance=None)

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

Project Source

This Page