Previous topic

The nova.network.quantum.fake_client Module

Next topic

The nova.network.quantum.melange_connection Module

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.quantum.manager Module

class QuantumManager(q_conn=None, ipam_lib=None, *args, **kwargs)

Bases: nova.network.manager.FloatingIP, nova.network.manager.FlatManager

NetworkManager class that communicates with a Quantum service via a web services API to provision VM network connectivity.

For IP Address management, QuantumManager can be configured to use either Nova’s local DB or the Melange IPAM service.

DHCP = False
add_virtual_interface(context, instance_id, network_id, net_tenant_id)
allocate_for_instance(context, **kwargs)

Called by compute when it is creating a new VM.

There are three key tasks:
  • Determine the number and order of vNICs to create
  • Allocate IP addresses
  • Create ports on a Quantum network and attach vNICs.
We support two approaches to determining vNICs:
  • By default, a VM gets a vNIC for any network belonging to the VM’s project, and a vNIC for any “global” network that has a NULL project_id. vNIC order is determined by the network’s ‘priority’ field.
  • If the ‘os-create-server-ext’ was used to create the VM, only the networks in ‘requested_networks’ are used to create vNICs, and the vNIC order is determiend by the order in the requested_networks array.

For each vNIC, use the FlatManager to create the entries in the virtual_interfaces table, contact Quantum to create a port and attachment the vNIC, and use the IPAM lib to allocate IP addresses.

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

Unlike other NetworkManagers, with QuantumManager, each create_networks calls should create only a single network.

Two scenarios exist:
  • no ‘uuid’ is specified, in which case we contact Quantum and create a new network.
  • an existing ‘uuid’ is specified, corresponding to a Quantum network created out of band.

In both cases, we initialize a subnet using the IPAM lib.

deallocate_for_instance(context, **kwargs)

Called when a VM is terminated. Loop through each virtual interface in the Nova DB and remove the Quantum port and clear the IP allocation using the IPAM. Finally, remove the virtual interfaces from the Nova DB.

deallocate_ip_address(context, net_id, project_id, vif_ref, instance_id)
deallocate_port(interface_id, net_id, q_tenant_id, instance_id)
delete_network(context, fixed_range, uuid)

Lookup network by uuid, delete both the IPAM subnet and the corresponding Quantum network.

The fixed_range parameter is kept here for interface compatibility but is not used.

enable_dhcp(*args, **kwargs)
get_all_networks(context)
get_dhcp_hosts_text(context, subnet_id, project_id=None)
get_dhcp_leases(context, network_ref)

Return a network’s hosts config in dnsmasq leasefile format.

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

This method is used by compute to fetch all network data that should be used when creating the VM.

The method simply loops through all virtual interfaces stored in the nova DB and queries the IPAM lib to get the associated IP data.

The format of returned data is ‘defined’ by the initial set of NetworkManagers found in nova/network/manager.py . Ideally this ‘interface’ will be more formally defined in the future.

get_network(context, proj_pair)
init_host()
release_fixed_ip(context, address)
setup_networks_on_host(*args, **kwargs)
update_dhcp(context, ipam_tenant_id, network_ref, vif_ref, project_id)
validate_networks(context, networks)

Validates that this tenant has quantum networks with the associated UUIDs. This is called by the ‘os-create-server-ext’ API extension code so that we can return an API error code to the caller if they request an invalid network.