The nova.network.base_api Module

class NetworkAPI(skip_policy_check=False, **kwargs)

Bases: nova.db.base.Base

Base Network API for doing networking operations. New operations available on specific clients must be added here as well.

add_dns_entry(context, address, name, dns_type, domain)

Create specified DNS entry for address.

add_fixed_ip_to_instance(context, instance, network_id)

Adds a fixed IP to instance from specified network.

add_network_to_project(context, project_id, network_uuid=None)

Force adds another network to a project.

allocate_floating_ip(context, pool=None)

Adds (allocate) floating IP to a project from a pool.

allocate_for_instance(context, instance, vpn, requested_networks, macs=None, security_groups=None, dhcp_options=None, bind_host_id=None)

Allocates all network structures for an instance.

Parameters:
  • context – The request context.
  • instance – nova.objects.instance.Instance object.
  • vpn – A boolean, if True, indicate a vpn to access the instance.
  • requested_networks – A dictionary of requested_networks, Optional value containing network_id, fixed_ip, and port_id.
  • macs – None or a set of MAC addresses that the instance should use. macs is supplied by the hypervisor driver (contrast with requested_networks which is user supplied).
  • security_groups – None or security groups to allocate for instance.
  • dhcp_options – None or a set of key/value pairs that should determine the DHCP BOOTP response, eg. for PXE booting an instance configured with the baremetal hypervisor. It is expected that these are already formatted for the neutron v2 api. See nova/virt/driver.py:dhcp_options_for_instance for an example.
  • bind_host_id – the host ID to attach to the ports being created.
Returns:

network info as from get_instance_nw_info() below

allocate_port_for_instance(context, instance, port_id, network_id=None, requested_ip=None, bind_host_id=None)

Allocate port for instance.

associate(context, network_uuid, host=<object object at 0x7f3115424210>, project=<object object at 0x7f3115424210>)

Associate or disassociate host or project to network.

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

Associates a floating IP with a fixed IP.

cleanup_instance_network_on_host(context, instance, host)

Cleanup network for specified instance on host.

Parameters:
  • context – The request context.
  • instance – nova.objects.instance.Instance object.
  • host – The host which network should be cleanup for instance.
create(context, **kwargs)

Create a network.

create_pci_requests_for_sriov_ports(context, pci_requests, requested_networks)

Check requested networks for any SR-IOV port request.

Create a PCI request object for each SR-IOV port, and add it to the pci_requests object that contains a list of PCI request object.

create_private_dns_domain(context, domain, availability_zone)

Create a private DNS domain with nova availability zone.

create_public_dns_domain(context, domain, project=None)

Create a public DNS domain with optional nova project.

deallocate_for_instance(context, instance, requested_networks=None)

Deallocates all network structures related to instance.

deallocate_port_for_instance(context, instance, port_id)

Deallocate port for instance.

delete(context, network_uuid)

Delete a specific network.

delete_dns_domain(context, domain)

Delete the specified dns domain.

delete_dns_entry(context, name, domain)

Delete the specified dns entry.

disassociate(context, network_uuid)

Disassociate a network for client.

disassociate_and_release_floating_ip(context, instance, floating_ip)

Removes (deallocates) and deletes the floating IP.

disassociate_floating_ip(context, instance, address, affect_auto_assigned=False)

Disassociates a floating IP from fixed IP it is associated with.

get(context, network_uuid)

Get specific network for client.

get_all(context)

Get all the networks for client.

get_dns_domains(context)

Returns a list of available dns domains. These can be used to create DNS entries for floating IPs.

get_dns_entries_by_address(context, address, domain)

Get entries for address and domain.

get_dns_entries_by_name(context, name, domain)

Get entries for name and domain.

get_fixed_ip(context, id)

Get fixed IP by id.

get_fixed_ip_by_address(context, address)

Get fixed IP by address.

get_floating_ip(context, id)

Get floating IP by id.

get_floating_ip_by_address(context, address)

Get floating IP by address.

get_floating_ip_pools(context)

Get floating IP pools.

get_floating_ips_by_project(context)

Get floating IPs by project.

get_instance_id_by_floating_address(context, address)

Get instance id by floating address.

get_instance_nw_info(context, instance, **kwargs)

Returns all network info related to an instance.

get_vif_by_mac_address(context, mac_address)

Get vif mac address.

get_vifs_by_instance(context, instance)

Get vifs by instance.

Parameters:
  • context – nova.context.RequestContext
  • instance – nova.objects.instance.Instance
Returns:

nova.objects.virtual_interface.VirtualInterfaceList; the

fields address, uuid and net_uuid should be set for each VIF object in the returned list.

list_ports(*args, **kwargs)

List ports.

migrate_instance_finish(context, instance, migration)

Finish migrating the network of an instance.

migrate_instance_start(context, instance, migration)

Start to migrate the network of an instance.

modify_dns_entry(context, name, address, domain)

Create specified DNS entry for address.

release_floating_ip(context, address, affect_auto_assigned=False)

Removes (deallocates) a floating IP with address from a project.

remove_fixed_ip_from_instance(context, instance, address)

Removes a fixed IP from instance from specified network.

setup_instance_network_on_host(context, instance, host)

Setup network for specified instance on host.

Parameters:
  • context – The request context.
  • instance – nova.objects.instance.Instance object.
  • host – The host which network should be setup for instance.
setup_networks_on_host(context, instance, host=None, teardown=False)

Setup or teardown the network structures on hosts related to instance.

show_port(*args, **kwargs)

Show specific port.

update_instance_vnic_index(context, instance, vif, index)

Update instance vnic index.

When the ‘VNIC index’ extension is supported this method will update the vnic index of the instance on the port. A instance may have more than one vnic.

Parameters:
  • context – The request context.
  • instance – nova.objects.instance.Instance object.
  • vif – The VIF in question.
  • index – The index on the instance for the VIF.
validate_networks(context, requested_networks, num_instances)

validate the networks passed at the time of creating the server.

Return the number of instances that can be successfully allocated with the requested network configuration.

refresh_cache(f)

Decorator to update the instance_info_cache

Requires context and instance as function args

update_instance_cache_with_nw_info(*args, **kwargs)

Previous topic

The nova.network.api Module

Next topic

The nova.network.dns_driver Module

Project Source

This Page