Merge "Add new VIF type VIF_TYPE_TAP"
This commit is contained in:
commit
6b4146e944
@ -42,6 +42,7 @@ VIF_TYPE_MIDONET = 'midonet'
|
||||
VIF_TYPE_VHOSTUSER = 'vhostuser'
|
||||
VIF_TYPE_VROUTER = 'vrouter'
|
||||
VIF_TYPE_OTHER = 'other'
|
||||
VIF_TYPE_TAP = 'tap'
|
||||
|
||||
# Constants for dictionary keys in the 'vif_details' field in the VIF
|
||||
# class
|
||||
@ -65,6 +66,10 @@ VIF_DETAILS_VHOSTUSER_SOCKET = 'vhostuser_socket'
|
||||
# into ovs bridge. Valid values are True and False
|
||||
VIF_DETAILS_VHOSTUSER_OVS_PLUG = 'vhostuser_ovs_plug'
|
||||
|
||||
# Constants for dictionary keys in the 'vif_details' field that are
|
||||
# valid for VIF_TYPE_TAP.
|
||||
VIF_DETAILS_TAP_MAC_ADDRESS = 'mac_address'
|
||||
|
||||
# Define supported virtual NIC types. VNIC_TYPE_DIRECT and VNIC_TYPE_MACVTAP
|
||||
# are used for SR-IOV ports
|
||||
VNIC_TYPE_NORMAL = 'normal'
|
||||
|
@ -2394,6 +2394,12 @@ class TestNeutronv2(TestNeutronv2Base):
|
||||
self.assertTrue(net['should_create_bridge'])
|
||||
self.assertIsNone(iid)
|
||||
|
||||
def test_nw_info_build_network_tap(self):
|
||||
net, iid = self._test_nw_info_build_network(model.VIF_TYPE_TAP)
|
||||
self.assertIsNone(net['bridge'])
|
||||
self.assertNotIn('should_create_bridge', net)
|
||||
self.assertIsNone(iid)
|
||||
|
||||
def test_nw_info_build_network_other(self):
|
||||
net, iid = self._test_nw_info_build_network(None)
|
||||
self.assertIsNone(net['bridge'])
|
||||
|
@ -268,6 +268,11 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||
type=network_model.VIF_TYPE_MIDONET,
|
||||
devname='tap-xxx-yyy-zzz')
|
||||
|
||||
vif_tap = network_model.VIF(id='vif-xxx-yyy-zzz',
|
||||
address='ca:fe:de:ad:be:ef',
|
||||
type=network_model.VIF_TYPE_TAP,
|
||||
devname='tap-xxx-yyy-zzz')
|
||||
|
||||
vif_iovisor = network_model.VIF(id='vif-xxx-yyy-zzz',
|
||||
address='ca:fe:de:ad:be:ef',
|
||||
network=network_bridge,
|
||||
@ -1000,6 +1005,24 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||
self._assertTypeAndMacEquals(node, "ethernet", "target", "dev",
|
||||
self.vif_midonet, br_want)
|
||||
|
||||
def test_tap_ethernet_vif_driver(self):
|
||||
d = vif.LibvirtGenericVIFDriver()
|
||||
br_want = self.vif_tap['devname']
|
||||
xml = self._get_instance_xml(d, self.vif_tap)
|
||||
node = self._get_node(xml)
|
||||
self._assertTypeAndMacEquals(node, "ethernet", "target", "dev",
|
||||
self.vif_tap, br_want)
|
||||
|
||||
@mock.patch('nova.network.linux_net.device_exists')
|
||||
def test_plug_tap(self, device_exists):
|
||||
device_exists.return_value = True
|
||||
d = vif.LibvirtGenericVIFDriver()
|
||||
d.plug_tap(None, self.vif_tap)
|
||||
|
||||
def test_unplug_tap(self):
|
||||
d = vif.LibvirtGenericVIFDriver()
|
||||
d.unplug_tap(None, self.vif_tap)
|
||||
|
||||
def test_generic_8021qbh_driver(self):
|
||||
d = vif.LibvirtGenericVIFDriver()
|
||||
xml = self._get_instance_xml(d, self.vif_8021qbh)
|
||||
|
@ -318,6 +318,16 @@ class LibvirtGenericVIFDriver(object):
|
||||
|
||||
return conf
|
||||
|
||||
def get_config_tap(self, instance, vif, image_meta,
|
||||
inst_type, virt_type):
|
||||
conf = self.get_base_config(instance, vif, image_meta,
|
||||
inst_type, virt_type)
|
||||
|
||||
dev = self.get_vif_devname(vif)
|
||||
designer.set_vif_host_backend_ethernet_config(conf, dev)
|
||||
|
||||
return conf
|
||||
|
||||
def get_config_mlnx_direct(self, instance, vif, image_meta,
|
||||
inst_type, virt_type):
|
||||
conf = self.get_base_config(instance, vif, image_meta,
|
||||
@ -535,6 +545,13 @@ class LibvirtGenericVIFDriver(object):
|
||||
except processutils.ProcessExecutionError:
|
||||
LOG.exception(_LE("Failed while plugging vif"), instance=instance)
|
||||
|
||||
def plug_tap(self, instance, vif):
|
||||
"""Plug a VIF_TYPE_TAP virtual interface."""
|
||||
dev = self.get_vif_devname(vif)
|
||||
mac = vif['details'].get(network_model.VIF_DETAILS_TAP_MAC_ADDRESS)
|
||||
linux_net.create_tap_dev(dev, mac)
|
||||
linux_net._set_device_mtu(dev)
|
||||
|
||||
def plug_vhostuser(self, instance, vif):
|
||||
ovs_plug = vif['details'].get(
|
||||
network_model.VIF_DETAILS_VHOSTUSER_OVS_PLUG,
|
||||
@ -721,6 +738,15 @@ class LibvirtGenericVIFDriver(object):
|
||||
LOG.exception(_LE("Failed while unplugging vif"),
|
||||
instance=instance)
|
||||
|
||||
def unplug_tap(self, instance, vif):
|
||||
"""Unplug a VIF_TYPE_TAP virtual interface."""
|
||||
dev = self.get_vif_devname(vif)
|
||||
try:
|
||||
linux_net.delete_net_dev(dev)
|
||||
except processutils.ProcessExecutionError:
|
||||
LOG.exception(_LE("Failed while unplugging vif"),
|
||||
instance=instance)
|
||||
|
||||
def unplug_iovisor(self, instance, vif):
|
||||
"""Unplug using PLUMgrid IO Visor Driver
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user