Merge "add noop plugin"

This commit is contained in:
Zuul 2018-07-10 13:12:18 +00:00 committed by Gerrit Code Review
commit d9d8da32e2
12 changed files with 141 additions and 20 deletions

View File

@ -25,8 +25,9 @@ Usage Guide
user/usage
user/vif-types
user/host-info
user/plugins/ovs
user/plugins/linux-bridge
user/plugins/noop
user/plugins/ovs
Reference
---------

View File

@ -3,8 +3,8 @@ Linux Bridge
============
The Linux Bridge plugin, ``vif_plug_linux_bridge``, is an `os-vif` VIF plugin
for the Linux Bridge network backend. It is one of two plugins provided as part
of `os-vif` itself, the other being :doc:`ovs`.
for the Linux Bridge network backend. It is one of three plugins provided as part
of `os-vif` itself, the others being :doc:`ovs` and :doc:`noop`.
Supported VIF Types
===================

View File

@ -0,0 +1,23 @@
=====
no-op
=====
The no-op plugin, ``vif_plug_noop``, is an `os-vif` VIF plugin
for use with network backends that do not require pluging of network interfaces.
It is one of three plugins provided as part of `os-vif` itself, the others
being :doc:`ovs` and :doc:`linux-bridge`.
Supported VIF Types
===================
The no-op plugin provides support for the following VIF types:
`VIFVHostUser`
Configuration where a guest exposes a UNIX socket for its control plane. This
configuration is used with a userspace dataplane such as vpp or snabb switch.
Refer to :ref:`vif-vhostuser` for more information.
For information on the VIF type objects, refer to :doc:`/user/vif-types`. Note
that only the above VIF types are supported by this plugin.

View File

@ -3,8 +3,8 @@ Open vSwitch
============
The Open vSwitch plugin, `vif_plug_ovs`, is an `os-vif` VIF plugin for the Open
vSwitch network backend. It is one of two plugins provided as part of `os-vif`
itself, the other being :doc:`linux-bridge`.
vSwitch network backend. It is one of three plugins provided as part of `os-vif`
itself, the others being :doc:`linux-bridge` and :doc:`noop`.
Supported VIF Types
-------------------

View File

@ -14,8 +14,6 @@ import mock
from oslo_config import cfg
from stevedore import extension
from vif_plug_linux_bridge import constants as lb_constants
import os_vif
from os_vif import exception
from os_vif import objects
@ -138,22 +136,28 @@ class TestOSVIF(base.TestCase):
def test_host_info_all(self):
os_vif.initialize()
info = os_vif.host_info()
# NOTE(sean-k-mooney): as out of tree plugins could be
# visable in path assert only at at least all the in
# intree plugins are loaded instead of an exact match.
self.assertTrue(len(info.plugin_info) >= 3)
self.assertEqual(len(info.plugin_info), 2)
plugins = {p.plugin_name: p for p in info.plugin_info}
in_tree_plugin_names = ("linux_bridge", "ovs", "noop")
self.assertTrue(all(name in plugins for name in in_tree_plugin_names))
lb = plugins["linux_bridge"]
self.assertTrue(any("VIFBridge" == vif.vif_object_name
for vif in lb.vif_info))
self.assertEqual(info.plugin_info[0].plugin_name,
lb_constants.PLUGIN_NAME)
vif_info = info.plugin_info[0].vif_info
self.assertEqual(len(vif_info), 1)
self.assertEqual(vif_info[0].vif_object_name, "VIFBridge")
ovs = plugins["ovs"]
self.assertTrue(len(ovs.vif_info) >= 4)
vif_names = (vif.vif_object_name for vif in ovs.vif_info)
ovs_vifs = ("VIFBridge", "VIFOpenVSwitch",
"VIFVHostUser", "VIFHostDevice")
self.assertTrue(all(name in ovs_vifs for name in vif_names))
self.assertEqual(info.plugin_info[1].plugin_name, "ovs")
vif_info = info.plugin_info[1].vif_info
self.assertEqual(len(vif_info), 4)
self.assertEqual(vif_info[0].vif_object_name, "VIFBridge")
self.assertEqual(vif_info[1].vif_object_name, "VIFOpenVSwitch")
self.assertEqual(vif_info[2].vif_object_name, "VIFVHostUser")
self.assertEqual(vif_info[3].vif_object_name, "VIFHostDevice")
noop = plugins["noop"]
self.assertTrue(any("VIFVHostUser" == vif.vif_object_name
for vif in noop.vif_info))
def test_host_info_filtered(self):
os_vif.initialize()

View File

@ -0,0 +1,7 @@
---
features:
- |
A new VIF plugin, ``vif_plug_noop``, has been added which can be used with
network backends that do not require any action to be performed when a
network interface is plugged. This plugin allow for use of, for example,
the generic vhost user VIF type without OVS.

View File

@ -60,3 +60,4 @@ output_file = os_vif/locale/os-vif.pot
os_vif =
linux_bridge = vif_plug_linux_bridge.linux_bridge:LinuxBridgePlugin
ovs = vif_plug_ovs.ovs:OvsPlugin
noop = vif_plug_noop.noop:NoOpPlugin

View File

48
vif_plug_noop/noop.py Normal file
View File

@ -0,0 +1,48 @@
# Copyright (C) 2011 Midokura KK
# Copyright (C) 2011 Nicira, Inc
# Copyright 2011 OpenStack Foundation
# Copyright 2018 Intel Corporation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from os_vif import objects
from os_vif import plugin
class NoOpPlugin(plugin.PluginBase):
"""A no op plugin
The no op plugin can be used for any vif type that requires
no action to be performed on the backend network when a vif
is plugged. Currently only the VIFVHostUser VIF type is supported.
This pluggin allows for the use of generic vhost user without ovs.
"""
def describe(self):
return objects.host_info.HostPluginInfo(
plugin_name="noop",
vif_info=[
objects.host_info.HostVIFInfo(
vif_object_name=objects.vif.VIFVHostUser.__name__,
min_version="1.0",
max_version="1.0",
supported_port_profiles=[])
])
def plug(self, vif, instance_info):
pass
def unplug(self, vif, instance_info):
pass

View File

View File

View File

@ -0,0 +1,37 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import testtools
from os_vif import objects
from vif_plug_noop import noop
class PluginTest(testtools.TestCase):
def __init__(self, *args, **kwargs):
super(PluginTest, self).__init__(*args, **kwargs)
objects.register_all()
self.plugin = noop.NoOpPlugin.load("noop")
def test_plug_noop(self):
self.assertIn("plug", dir(self.plugin))
self.plugin.plug(None, None)
def test_unplug_noop(self):
self.assertIn("unplug", dir(self.plugin))
self.plugin.unplug(None, None)
def test_describe_noop(self):
self.assertIn("describe", dir(self.plugin))
self.assertTrue(len(self.plugin.describe().vif_info) > 0)