summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/network/linux_net.py34
-rw-r--r--nova/virt/libvirt/vif.py15
2 files changed, 18 insertions, 31 deletions
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index d849441ab..4af604fa1 100644
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -1142,6 +1142,22 @@ def delete_ovs_vif_port(bridge, dev):
run_as_root=True)
+def create_tap_dev(dev, mac_address=None):
+ if not device_exists(dev):
+ try:
+ # First, try with 'ip'
+ utils.execute('ip', 'tuntap', 'add', dev, 'mode', 'tap',
+ run_as_root=True, check_exit_code=[0, 2, 254])
+ except exception.ProcessExecutionError:
+ # Second option: tunctl
+ utils.execute('tunctl', '-b', '-t', dev, run_as_root=True)
+ if mac_address:
+ utils.execute('ip', 'link', 'set', dev, 'address', mac_address,
+ run_as_root=True, check_exit_code=[0, 2, 254])
+ utils.execute('ip', 'link', 'set', dev, 'up', run_as_root=True,
+ check_exit_code=[0, 2, 254])
+
+
# Similar to compute virt layers, the Linux network node
# code uses a flexible driver model to support different ways
# of creating ethernet interfaces and attaching them to the network.
@@ -1553,7 +1569,7 @@ class QuantumLinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):
iptables_manager.ipv4['filter'].add_rule('FORWARD',
'--out-interface %s -j ACCEPT' % bridge)
- QuantumLinuxBridgeInterfaceDriver.create_tap_dev(dev, mac_address)
+ create_tap_dev(dev, mac_address)
if not device_exists(bridge):
LOG.debug(_("Starting bridge %s "), bridge)
@@ -1588,22 +1604,6 @@ class QuantumLinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):
LOG.debug(_("Unplugged gateway interface '%s'"), dev)
return dev
- @classmethod
- def create_tap_dev(_self, dev, mac_address=None):
- if not device_exists(dev):
- try:
- # First, try with 'ip'
- utils.execute('ip', 'tuntap', 'add', dev, 'mode', 'tap',
- run_as_root=True, check_exit_code=[0, 2, 254])
- except exception.ProcessExecutionError:
- # Second option: tunctl
- utils.execute('tunctl', '-b', '-t', dev, run_as_root=True)
- if mac_address:
- utils.execute('ip', 'link', 'set', dev, 'address', mac_address,
- run_as_root=True, check_exit_code=[0, 2, 254])
- utils.execute('ip', 'link', 'set', dev, 'up', run_as_root=True,
- check_exit_code=[0, 2, 254])
-
def get_dev(self, network):
dev = self.GATEWAY_INTERFACE_PREFIX + str(network['uuid'][0:11])
return dev
diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py
index 422a8e716..d90a5e295 100644
--- a/nova/virt/libvirt/vif.py
+++ b/nova/virt/libvirt/vif.py
@@ -169,20 +169,7 @@ class LibvirtOpenVswitchDriver(LibvirtBaseVIFDriver):
network, mapping = vif
iface_id = self.get_ovs_interfaceid(mapping)
dev = self.get_vif_devname(mapping)
- if not linux_net.device_exists(dev):
- # Older version of the command 'ip' from the iproute2 package
- # don't have support for the tuntap option (lp:882568). If it
- # turns out we're on an old version we work around this by using
- # tunctl.
- try:
- # First, try with 'ip'
- utils.execute('ip', 'tuntap', 'add', dev, 'mode', 'tap',
- run_as_root=True)
- except exception.ProcessExecutionError:
- # Second option: tunctl
- utils.execute('tunctl', '-b', '-t', dev, run_as_root=True)
- utils.execute('ip', 'link', 'set', dev, 'up', run_as_root=True)
-
+ linux_net.create_tap_dev(dev)
linux_net.create_ovs_vif_port(self.get_bridge_name(network),
dev, iface_id, mapping['mac'],
instance['uuid'])