diff --git a/etc/octavia.conf b/etc/octavia.conf index b61b8fd7d5..367ab9e6bd 100644 --- a/etc/octavia.conf +++ b/etc/octavia.conf @@ -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. diff --git a/octavia/api/v1/controllers/base.py b/octavia/api/v1/controllers/base.py index 5c374f94a2..78457cea63 100644 --- a/octavia/api/v1/controllers/base.py +++ b/octavia/api/v1/controllers/base.py @@ -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 diff --git a/octavia/common/config.py b/octavia/common/config.py index 443def26f0..b5ba32466a 100644 --- a/octavia/common/config.py +++ b/octavia/common/config.py @@ -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="", diff --git a/requirements.txt b/requirements.txt index 2b929fa907..da906a5196 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.cfg b/setup.cfg index 2bb59668a5..25d186a961 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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