diff --git a/nova/network/os_vif_util.py b/nova/network/os_vif_util.py index 61bc1257eddc..11a4997d0065 100644 --- a/nova/network/os_vif_util.py +++ b/nova/network/os_vif_util.py @@ -440,7 +440,11 @@ def _nova_to_osvif_vif_vhostuser(vif): _set_vhostuser_settings(vif, obj) return obj else: - raise NotImplementedError() + obj = _get_vif_instance(vif, objects.vif.VIFVHostUser, + plugin="noop", + vif_name=_get_vif_name(vif)) + _set_vhostuser_settings(vif, obj) + return obj # VIF_TYPE_IVS = 'ivs' diff --git a/nova/tests/unit/network/test_os_vif_util.py b/nova/tests/unit/network/test_os_vif_util.py index 97d0955383e1..90466e09cc40 100644 --- a/nova/tests/unit/network/test_os_vif_util.py +++ b/nova/tests/unit/network/test_os_vif_util.py @@ -802,7 +802,27 @@ class OSVIFUtilTestCase(test.NoDBTestCase): } ) - self.assertIsNone(os_vif_util.nova_to_osvif_vif(vif)) + actual = os_vif_util.nova_to_osvif_vif(vif) + + expect = osv_objects.vif.VIFVHostUser( + id="dc065497-3c8d-4f44-8fb4-e1d33c16a536", + active=False, + address="22:52:25:62:e2:aa", + plugin="noop", + vif_name="nicdc065497-3c", + path='/fake/socket', + mode='client', + has_traffic_filtering=False, + preserve_on_delete=False, + network=osv_objects.network.Network( + id="b82c1929-051e-481d-8110-4669916c7915", + bridge_interface=None, + label="Demo Net", + mtu=None, + subnets=osv_objects.subnet.SubnetList( + objects=[]))) + + self.assertObjEqual(expect, actual) def test_nova_to_osvif_vhostuser_fp_ovs_hybrid(self): vif = model.VIF( diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py index c5b5a308e1b4..7982a89c0b77 100644 --- a/nova/virt/libvirt/vif.py +++ b/nova/virt/libvirt/vif.py @@ -417,34 +417,6 @@ class LibvirtGenericVIFDriver(object): return conf - def _get_vhostuser_settings(self, vif): - vif_details = vif['details'] - mode = vif_details.get(network_model.VIF_DETAILS_VHOSTUSER_MODE, - 'server') - sock_path = vif_details.get(network_model.VIF_DETAILS_VHOSTUSER_SOCKET) - if sock_path is None: - raise exception.VifDetailsMissingVhostuserSockPath( - vif_id=vif['id']) - return mode, sock_path - - def get_config_vhostuser(self, instance, vif, image_meta, - inst_type, virt_type, host): - conf = self.get_base_config(instance, vif['address'], image_meta, - inst_type, virt_type, vif['vnic_type'], - host) - # TODO(sahid): We should never configure a driver backend for - # vhostuser interface. Specifically override driver to use - # None. This can be removed when get_base_config will be fixed - # and rewrite to set the correct backend. - conf.driver_name = None - - mode, sock_path = self._get_vhostuser_settings(vif) - rx_queue_size, tx_queue_size = self._get_virtio_queue_sizes(host) - designer.set_vif_host_backend_vhostuser_config( - conf, mode, sock_path, rx_queue_size, tx_queue_size) - - return conf - def _get_virtio_queue_sizes(self, host): """Returns rx/tx queue sizes configured or (None, None)