Rajaram/Santhosh|Added plugin interface in foxinsox and Updated README

This commit is contained in:
Rajaram Mallya 2011-07-26 10:57:24 +05:30
parent 7118905054
commit 01eafb56be
5 changed files with 47 additions and 5 deletions

25
README
View File

@ -105,4 +105,29 @@ There are a few requirements to writing your own plugin:
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

View File

@ -24,7 +24,7 @@ import logging
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

View File

@ -119,6 +119,11 @@ class QuantumEchoPlugin(object):
"""
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):
@ -237,8 +242,6 @@ class FakePlugin(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)

View File

@ -19,6 +19,7 @@ import json
from quantum.common import wsgi
from quantum.common import extensions
from abc import abstractmethod
class FoxInSocksController(wsgi.Controller):
@ -27,11 +28,21 @@ 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"

View File

@ -27,11 +27,11 @@ from quantum.common import config
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):
@ -409,6 +409,9 @@ def setup_base_app():
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)