4) Launch the Quantum Service, and your plug-in is configured and ready to
manage a Cloud Networking Fabric.
-
+# -- Extensions
+
+1) Creating Extensions:
+ An example extension exists in ./tests/unit/extensions/foxinsocks.py
+ The unit tests in ./tests/unit/test_extensions.py document the complete
+ set of extension features supported
+2) Loading Extension:
+ a) The extension file should have a class with same name as the filename.
+ This class should implement the contract required by the extension framework.
+ See ExtensionDescriptor class in ./quantum/common/extensions.py for details
+ For an example look at Foxinsocks class in foxinsocks.py
+ b) The extension file should be deployed in the ./extensions folder.
+ If the filename starts with an "_", it will not be treated as an extension.
+3) Plugins advertizing extension support:
+ A Plugin can advertize all the extensions it supports through the
+ 'supported_extension_aliases' attribute. Eg:
+
+ class SomePlugin:
+ ...
+ supported_extension_aliases = ['extension1_alias',
+ 'extension2_alias',
+ 'extension3_alias']
+4) Standardizing extensions:
+ An extension might be supported by multiple plugins. In such cases, the extension
+ can mandate an interface that all plugins have to support for that extension.
+ For an example see the FoxInSocksPluginInterface in foxinsocks.py and the QuantumEchoPlugin
import webob.dec
import webob.exc
from gettext import gettext as _
-from abc import ABCMeta, abstractmethod
+from abc import ABCMeta
from quantum.manager import QuantumManager
from quantum.common import exceptions
"""
print("unplug_interface() called\n")
+ supported_extension_aliases = ["FOXNSOX"]
+
+ def method_to_support_foxnsox_extension(self):
+ print("method_to_support_foxnsox_extension() called\n")
+
class DummyDataPlugin(object):
db.configure_db({'sql_connection': 'sqlite:///:memory:'})
FakePlugin._net_counter = 0
- supported_extension_aliases = ["FOXNSOX"]
-
def _get_network(self, tenant_id, network_id):
try:
network = db.network_get(network_id)
from quantum.common import wsgi
from quantum.common import extensions
+from abc import abstractmethod
class FoxInSocksController(wsgi.Controller):
return "Try to say this Mr. Knox, sir..."
+class FoxInSocksPluginInterface(extensions.PluginInterface):
+
+ @abstractmethod
+ def method_to_support_foxnsox_extension(self):
+ pass
+
+
class Foxinsocks(object):
def __init__(self):
pass
+ def get_plugin_interface(self):
+ return FoxInSocksPluginInterface
+
def get_name(self):
return "Fox In Socks"
from quantum.common.extensions import (ExtensionManager,
PluginAwareExtensionManager,
ExtensionMiddleware)
+from quantum.plugins.SamplePlugin import QuantumEchoPlugin
test_conf_file = os.path.join(os.path.dirname(__file__), os.pardir,
os.pardir, 'etc', 'quantum.conf.test')
-
-plugin_options = {'plugin_provider': "quantum.plugins.SamplePlugin.FakePlugin"}
+extensions_path = os.path.join(os.path.dirname(__file__), "extensions")
class StubExtension(object):
def setup_extensions_middleware(extension_manager=None):
+ extension_manager = (extension_manager or
+ PluginAwareExtensionManager(extensions_path,
+ QuantumEchoPlugin()))
options = {'config_file': test_conf_file}
conf, app = config.load_paste_app('extensions_test_app', options, None)
return ExtensionMiddleware(app, conf, ext_mgr=extension_manager)