From 6a099ff74104e81d74d76f0a061f7c7df7c12c8b Mon Sep 17 00:00:00 2001 From: Moshe Levi Date: Tue, 9 Feb 2016 16:51:27 +0200 Subject: [PATCH] Adding dev_type field to VIFHostDevice The dev_type represent the type of the host device. Valid values are ethernet and generic. Ethernet is Generic is The Generic type is usefully for device which is not traditional ethernet NIC device e.g. InfiniBand Change-Id: I3d1b782ba730ab74c627e6b8028150f9e8d15ecd --- os_vif/objects/fields.py | 15 +++++++++++++++ os_vif/objects/vif.py | 7 +++++++ os_vif/tests/test_vif.py | 7 ++++--- 3 files changed, 26 insertions(+), 3 deletions(-) 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(