Skip to content

Commit

Permalink
I'm taking Thierry at his word that I should merge early and merge of…
Browse files Browse the repository at this point in the history
…ten :)

In Diablo-3 we introduced "vif-plugging" to the hypervisor "virt" layer, allowing flexibility in how vNICs are attached to the network switch. This allowed non-linux bridge switch technologies (e.g., Open vSwitch, 802.1qbh) to be used with nova.

This blueprint adds a similar capability to linux_net.py, allowing the L3/DHCP capabilities to be "plugged" into Quantum networks.  Like in the virt layer, we created a vif driver that represents the behavior of Nova prior to the change (LinuxBridgeInterfaceDriver) and make it the default.  We also add a new driver for Open Vswitch that can be enabled using a flag (LinuxOVSInterfaceDriver).  The code is designed to support other drivers as well.  

Most of the interesting code is at the bottom of linux_net.py, where the drivers are defined.  I had to pull some common code related to setting IPs on devices out of ensure_bridge() so it could be used by either approach.  The driver's plug() method is invoked by the VlanManager's _setup_network() method.  Currently unplug() is unused, which seems to be inline with how the existing nova code works. 

In many places in linux_net.py, I had to tweak functions to accept the name of the linux device to configure, rather than just assuming it was the 'bridge' field in the network object, since with OVS it could be any linux device.  The code I am least sure about are the changes to bin/nova-dhcpbridge.  I changed to this key off of the network ID, rather than the bridge name.  

I've tested this with the linux bridge and with the OVS vif-plugging driver.  I was able to confirm that L3 forwarding and DHCP were operating correctly.
  • Loading branch information
Dan Wendlandt authored and Tarmac committed Aug 16, 2011
2 parents a6a6f81 + 53ca062 commit 6dbcc60
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 151 deletions.
12 changes: 6 additions & 6 deletions bin/nova-dhcpbridge
Expand Up @@ -48,7 +48,6 @@ flags.DECLARE('auth_driver', 'nova.auth.manager')
flags.DECLARE('network_size', 'nova.network.manager')
flags.DECLARE('num_networks', 'nova.network.manager')
flags.DECLARE('update_dhcp_on_disassociate', 'nova.network.manager')
flags.DEFINE_string('dnsmasq_interface', 'br0', 'Default Dnsmasq interface')

LOG = logging.getLogger('nova.dhcpbridge')

Expand Down Expand Up @@ -87,10 +86,10 @@ def del_lease(mac, ip_address, _interface):
"args": {"address": ip_address}})


def init_leases(interface):
"""Get the list of hosts for an interface."""
def init_leases(network_id):
"""Get the list of hosts for a network."""
ctxt = context.get_admin_context()
network_ref = db.network_get_by_bridge(ctxt, interface)
network_ref = db.network_get(ctxt, network_id)
return linux_net.get_dhcp_leases(ctxt, network_ref)


Expand All @@ -101,7 +100,8 @@ def main():
argv = FLAGS(sys.argv)
logging.setup()
# check ENV first so we don't break any older deploys
interface = os.environ.get('DNSMASQ_INTERFACE', FLAGS.dnsmasq_interface)
network_id = int(os.environ.get('NETWORK_ID'))

if int(os.environ.get('TESTING', '0')):
from nova.tests import fake_flags

Expand All @@ -120,7 +120,7 @@ def main():
LOG.debug(msg)
globals()[action + '_lease'](mac, ip, interface)
else:
print init_leases(interface)
print init_leases(network_id)

if __name__ == "__main__":
main()

0 comments on commit 6dbcc60

Please sign in to comment.