summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Wendlandt <dan@nicira.com>2012-03-12 11:43:23 -0700
committerDan Wendlandt <dan@nicira.com>2012-03-12 11:44:17 -0700
commit1265104b873d4cd791cecc62134ef874b4656003 (patch)
treec443d0ac83a7455757bfe264e93900df56524142
parent5810e2062d0df0485ba0774a927ae6dfd5da2d4e (diff)
Fix linux_net.py interface-driver loading.
bug 950381 linux_net.py previously set the value of interface_driver based on a flag when the module was loaded. This breaks when nova-manage is used to invoke anything using the interface_driver, as nova-manage loads the nova.network.linux_net module before flags are properly set. This patch moves the initialization of the interface_driver variable to within a function that will only be called once flags are properly loaded. Note: this patch also fixes the unplug() action for the OVS vif-plugging code to actually remove the device created to act as the gateway device. Also tweaks the plug() to use the get_dev() method, reducing duplicate code. Change-Id: I97a17c010d4d6a67e2340a81315da00775c67eea
-rwxr-xr-xnova/network/linux_net.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index c0dbe88af..8b75635fd 100755
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -907,18 +907,26 @@ def _ip_bridge_cmd(action, params, device):
# of creating ethernet interfaces and attaching them to the network.
# In the case of a network host, these interfaces
# act as gateway/dhcp/vpn/etc. endpoints not VM interfaces.
+interface_driver = None
+
+
+def _get_interface_driver():
+ global interface_driver
+ if not interface_driver:
+ interface_driver = utils.import_object(FLAGS.linuxnet_interface_driver)
+ return interface_driver
def plug(network, mac_address, gateway=True):
- return interface_driver.plug(network, mac_address, gateway)
+ return _get_interface_driver().plug(network, mac_address, gateway)
def unplug(network):
- return interface_driver.unplug(network)
+ return _get_interface_driver().unplug(network)
def get_dev(network):
- return interface_driver.get_dev(network)
+ return _get_interface_driver().get_dev(network)
class LinuxNetInterfaceDriver(object):
@@ -1077,7 +1085,7 @@ class LinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):
class LinuxOVSInterfaceDriver(LinuxNetInterfaceDriver):
def plug(self, network, mac_address, gateway=True):
- dev = "gw-" + str(network['uuid'][0:11])
+ dev = self.get_dev(network)
if not _device_exists(dev):
bridge = FLAGS.linuxnet_ovs_integration_bridge
_execute('ovs-vsctl',
@@ -1119,7 +1127,11 @@ class LinuxOVSInterfaceDriver(LinuxNetInterfaceDriver):
return dev
def unplug(self, network):
- return self.get_dev(network)
+ dev = self.get_dev(network)
+ bridge = FLAGS.linuxnet_ovs_integration_bridge
+ _execute('ovs-vsctl', '--', '--if-exists', 'del-port',
+ bridge, dev, run_as_root=True)
+ return dev
def get_dev(self, network):
dev = "gw-" + str(network['uuid'][0:11])
@@ -1208,4 +1220,3 @@ class QuantumLinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):
return bridge
iptables_manager = IptablesManager()
-interface_driver = utils.import_object(FLAGS.linuxnet_interface_driver)