Adding dev_type field to VIFHostDevice

The dev_type represent the type of the host device.
Valid values are ethernet and generic.
Ethernet is <interface type='hostdev'>
Generic is <hostdev mode='subsystem' type='pci'>

The Generic type is usefully for device which is not
traditional ethernet NIC device e.g. InfiniBand

Change-Id: I3d1b782ba730ab74c627e6b8028150f9e8d15ecd
This commit is contained in:
Moshe Levi 2016-02-09 16:51:27 +02:00
parent 1ff6526c3d
commit 6a099ff741
3 changed files with 26 additions and 3 deletions

View File

@ -70,3 +70,18 @@ class VIFVHostUserModeField(fields.BaseEnumField):
class ListOfIPAddressField(fields.AutoTypedField):
AUTO_TYPE = fields.List(fields.IPAddress())
class VIFVIFHostDeviceDevType(fields.Enum):
ETHERNET = 'ethernet'
GENERIC = 'generic'
ALL = (ETHERNET, GENERIC)
def __init__(self):
super(VIFVIFHostDeviceDevType, self).__init__(
valid_values=VIFVIFHostDeviceDevType.ALL)
class VIFVIFHostDeviceDevTypeField(fields.BaseEnumField):
AUTO_TYPE = VIFVIFHostDeviceDevType()

View File

@ -132,6 +132,13 @@ class VIFHostDevice(VIFBase):
VERSION = '1.0'
fields = {
# The type of the host device.
# Valid values are ethernet and generic.
# Ethernet is <interface type='hostdev'>
# Generic is <hostdev mode='subsystem' type='pci'>
'dev_type': osv_fields.VIFVIFHostDeviceDevTypeField(),
# The PCI address of the host device
'dev_address': osv_fields.PCIAddressField(),

View File

@ -78,9 +78,10 @@ class TestVIFS(base.TestCase):
mode=objects.fields.VIFVHostUserMode.CLIENT)
def test_vif_host_dev_plain(self):
self._test_vif(objects.vif.VIFHostDevice,
dev_address="0002:24:12.3",
vlan=8)
self._test_vif(
objects.vif.VIFHostDevice,
dev_type=objects.fields.VIFVIFHostDeviceDevType.ETHERNET,
dev_address="0002:24:12.3", vlan=8)
def test_vif_host_dev_vepa_qbh(self):
prof = objects.vif.VIFPortProfile8021Qbh(