Add support for plugin provided API resources.
Change-Id: I201461e255edb1bc5ca35e9c8c989cb777bb2924
This commit is contained in:
parent
4be975feae
commit
5d9bcfb9a3
|
@ -14,18 +14,22 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import flask
|
||||
from moniker.api.v1.domains import blueprint as domains_blueprint
|
||||
from moniker.api.v1.records import blueprint as records_blueprint
|
||||
from moniker.api.v1.servers import blueprint as servers_blueprint
|
||||
from moniker.api.v1.tsigkeys import blueprint as tsigkeys_blueprint
|
||||
from stevedore import extension
|
||||
from moniker.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def factory(global_config, **local_conf):
|
||||
app = flask.Flask('moniker.api.v1')
|
||||
|
||||
app.register_blueprint(domains_blueprint)
|
||||
app.register_blueprint(records_blueprint)
|
||||
app.register_blueprint(servers_blueprint)
|
||||
app.register_blueprint(tsigkeys_blueprint)
|
||||
# TODO(kiall): Ideally, we want to make use of the Plugin class here.
|
||||
# This works for the moment though.
|
||||
mgr = extension.ExtensionManager('moniker.api.v1')
|
||||
|
||||
def _load_extension(ext):
|
||||
app.register_blueprint(ext.plugin)
|
||||
|
||||
mgr.map(_load_extension)
|
||||
|
||||
return app
|
||||
|
|
6
setup.py
6
setup.py
|
@ -56,6 +56,12 @@ setup(
|
|||
],
|
||||
cmdclass=common_setup.get_cmdclass(),
|
||||
entry_points=textwrap.dedent("""
|
||||
[moniker.api.v1]
|
||||
domains = moniker.api.v1.domains:blueprint
|
||||
records = moniker.api.v1.records:blueprint
|
||||
servers = moniker.api.v1.servers:blueprint
|
||||
tsigkeys = moniker.api.v1.tsigkeys:blueprint
|
||||
|
||||
[moniker.storage]
|
||||
sqlalchemy = moniker.storage.impl_sqlalchemy:SQLAlchemyStorage
|
||||
|
||||
|
|
Loading…
Reference in New Issue