Use stevedore to load API handler

Updates controller base to load handler via stevedore
Updates setup.cfg with entry point
Updates octavia.conf for api_handler default example
Updates config.py for api_handler
Updates requirements.txt for stevedore

Change-Id: I67e3da376fad1d48cec7f56f990c4b13ac7f4b83
This commit is contained in:
ptoohill1
2015-04-16 18:47:28 -05:00
parent fc5eb91a68
commit 6c85431e53
5 changed files with 18 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
# debug = False
# bind_host = 0.0.0.0
# bind_port = 9876
# api_handler = simulated_handler
[database]
# This line MUST be changed to actually run the plugin.

View File

@@ -12,19 +12,26 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from pecan import rest
from stevedore import driver as stevedore_driver
from octavia.api.v1.handlers.controller_simulator import handler
from octavia.api.v1.types import load_balancer as lb_types
from octavia.api.v1.types import pool as pool_types
from octavia.db import repositories
CONF = cfg.CONF
class BaseController(rest.RestController):
def __init__(self):
self.handler = handler.SimulatedControllerHandler()
self.repositories = repositories.Repositories()
self.handler = stevedore_driver.DriverManager(
namespace='octavia.api.handlers',
name=CONF.api_handler,
invoke_on_load=True
).driver
def _convert_db_to_type(self, db_entity, to_type):
"""Converts a data model into a Octavia WSME type

View File

@@ -34,6 +34,8 @@ core_opts = [
help=_("The host IP to bind to")),
cfg.IntOpt('bind_port', default=9876,
help=_("The port to bind to")),
cfg.StrOpt('api_handler', default='simulated_handler',
help=_("The handler that the API communicates with")),
cfg.StrOpt('api_paste_config', default="api-paste.ini",
help=_("The API paste config file to use")),
cfg.StrOpt('api_extensions_path', default="",

View File

@@ -15,6 +15,7 @@ netaddr>=0.7.12
python-neutronclient>=2.3.11,<3
WebOb>=1.2.3
six>=1.9.0
stevedore>=1.3.0,<1.4.0 # Apache-2.0
oslo.config>=1.9.3,<1.10.0 # Apache-2.0
oslo.context>=0.2.0,<0.3.0 # Apache-2.0
oslo.db>=1.7.0,<1.8.0 # Apache-2.0

View File

@@ -28,3 +28,8 @@ warnerrors = True
[wheel]
universal = 1
[entry_points]
octavia.api.handlers =
simulated_handler = octavia.api.v1.handlers.controller_simulator.handler:SimulatedControllerHandler
queue_producer = octavia.api.v1.handlers.queue.producer:ProducerHandler