The nova.network.manager Module

Component Diagram
Overview:



While this diagram may not make this entirely clear, nodes and controllers communicate exclusively across the message bus (AMQP, currently).



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
flat_network_dhcp_start:
Dhcp start for FlatDhcp
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
exception nova.network.manager.AddressAlreadyAllocated(message=None)
Address was already allocated.
class nova.network.manager.FlatDHCPManager(network_driver=None*args**kwargs)
Flat networking with dhcp.
FlatDHCPManager will start up one dhcp server to give out addresses. It never injects network settings into the guest. Otherwise it behaves like FlatDHCPManager.
FlatDHCPManager.allocate_fixed_ip(contextinstance_id*args**kwargs)
Setup dhcp for this network.
FlatDHCPManager.deallocate_fixed_ip(contextaddress*args**kwargs)
Returns a fixed ip to the pool.
FlatDHCPManager.init_host()
Do any initialization that needs to be run if this is a standalone service.
FlatDHCPManager.setup_compute_network(contextinstance_id)
Sets up matching network for compute hosts.
class nova.network.manager.FlatManager(network_driver=None*args**kwargs)
Basic network where no vlans are used.
FlatManager does not do any bridge or vlan creation. The user is responsible for setting up whatever bridge is specified in flat_network_bridge (br100 by default). 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.
FlatManager.allocate_floating_ip(contextproject_id)
FlatManager.associate_floating_ip(contextfloating_addressfixed_address)
FlatManager.deallocate_floating_ip(contextfloating_address)
FlatManager.disassociate_floating_ip(contextfloating_address)
FlatManager.init_host()
Do any initialization that needs to be run if this is a standalone service.
FlatManager.setup_compute_network(contextinstance_id)
Network is created manually.
class nova.network.manager.NetworkManager(network_driver=None*args**kwargs)
Implements common network manager functionality.
This class must be subclassed to support specific topologies.
NetworkManager.allocate_fixed_ip(contextinstance_id*args**kwargs)
Gets a fixed ip from the pool.
NetworkManager.allocate_floating_ip(contextproject_id)
Gets an floating ip from the pool.
NetworkManager.associate_floating_ip(contextfloating_addressfixed_address)
Associates an floating ip to a fixed ip.
NetworkManager.create_networks(contextcidrnum_networksnetwork_sizecidr_v6label*args**kwargs)
Create networks based on parameters.
NetworkManager.deallocate_fixed_ip(contextaddress*args**kwargs)
Returns a fixed ip to the pool.
NetworkManager.deallocate_floating_ip(contextfloating_address)
Returns an floating ip to the pool.
NetworkManager.disassociate_floating_ip(contextfloating_address)
Disassociates a floating ip.
NetworkManager.get_network_host(context)
Get the network host for the current context.
NetworkManager.init_host()
Do any initialization that needs to be run if this is a standalone service.
NetworkManager.lease_fixed_ip(contextmacaddress)
Called by dhcp-bridge when ip is leased.
NetworkManager.periodic_tasks(context=None)
Tasks to be run at a periodic interval.
NetworkManager.release_fixed_ip(contextmacaddress)
Called by dhcp-bridge when ip is released.
NetworkManager.set_network_host(contextnetwork_id)
Safely sets the host of the network.
NetworkManager.setup_compute_network(contextinstance_id)
Sets up matching network for compute hosts.
NetworkManager.setup_fixed_ip(contextaddress)
Sets up rules for fixed ip.
class nova.network.manager.VlanManager(network_driver=None*args**kwargs)
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.
VlanManager.allocate_fixed_ip(contextinstance_id*args**kwargs)
Gets a fixed ip from the pool.
VlanManager.create_networks(contextcidrnum_networksnetwork_sizecidr_v6vlan_startvpn_start**kwargs)
Create networks based on parameters.
VlanManager.deallocate_fixed_ip(contextaddress*args**kwargs)
Returns a fixed ip to the pool.
VlanManager.get_network_host(context)
Get the network for the current context.
VlanManager.init_host()
Do any initialization that needs to be run if this is a standalone service.
VlanManager.setup_compute_network(contextinstance_id)
Sets up matching network for compute hosts.

The nova.network.linux_net Driver

Implements vlans, bridges, and iptables rules using linux utilities.
nova.network.linux_net.bind_floating_ip(floating_ipcheck_exit_code=True)
Bind ip to public interface
nova.network.linux_net.ensure_bridge(bridgeinterfacenet_attrs=None)
Create a bridge unless it already exists.
Parameters:
  • interface – the interface to create the bridge on.
  • net_attrs – dictionary with attributes used to create the bridge.
If net_attrs is set, it will add the net_attrs[‘gateway’] to the bridge using net_attrs[‘broadcast’] and net_attrs[‘cidr’]. It will also add the ip_v6 address specified in net_attrs[‘cidr_v6’] if use_ipv6 is set.
The code will attempt to move any ips that already exist on the interface onto the bridge and reset the default gateway if necessary.
nova.network.linux_net.ensure_floating_forward(floating_ipfixed_ip)
Ensure floating ip forwarding rule
nova.network.linux_net.ensure_vlan(vlan_num)
Create a vlan unless it already exists
nova.network.linux_net.ensure_vlan_bridge(vlan_numbridgenet_attrs=None)
Create a vlan and bridge unless they already exist
nova.network.linux_net.ensure_vlan_forward(public_ipportprivate_ip)
Sets up forwarding rules for vlan
nova.network.linux_net.get_dhcp_hosts(contextnetwork_id)
Get a string containing a network’s hosts config in dnsmasq format
nova.network.linux_net.init_host()
Basic networking setup goes here
nova.network.linux_net.metadata_forward()
Create forwarding rule for metadata
nova.network.linux_net.remove_floating_forward(floating_ipfixed_ip)
Remove forwarding for floating ip
nova.network.linux_net.unbind_floating_ip(floating_ip)
Unbind a public ip from public interface
nova.network.linux_net.update_dhcp(contextnetwork_id)
(Re)starts a dnsmasq server for a given network
if a dnsmasq instance is already running then send a HUP signal causing it to reload, otherwise spawn a new instance
nova.network.linux_net.update_ra(contextnetwork_id)



Reference http://nova.openstack.org/devref/network.html#index-0
 

Comments

Popular posts from this blog