diff --git a/os_vif/objects/fields.py b/os_vif/objects/fields.py index bfe0a92f..1b034bf6 100644 --- a/os_vif/objects/fields.py +++ b/os_vif/objects/fields.py @@ -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() diff --git a/os_vif/objects/vif.py b/os_vif/objects/vif.py index 5b6933e7..67528293 100644 --- a/os_vif/objects/vif.py +++ b/os_vif/objects/vif.py @@ -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 + # Generic is + 'dev_type': osv_fields.VIFVIFHostDeviceDevTypeField(), + # The PCI address of the host device 'dev_address': osv_fields.PCIAddressField(), diff --git a/os_vif/tests/test_vif.py b/os_vif/tests/test_vif.py index 4bb4ab77..61679169 100644 --- a/os_vif/tests/test_vif.py +++ b/os_vif/tests/test_vif.py @@ -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(