diff --git a/doc/source/mod_wsgi.rst b/doc/source/mod_wsgi.rst new file mode 100644 index 00000000..d38bcdc2 --- /dev/null +++ b/doc/source/mod_wsgi.rst @@ -0,0 +1,49 @@ +.. + Except where otherwise noted, this document is licensed under Creative + Commons Attribution 3.0 License. You can view the license at: + + https://creativecommons.org/licenses/by/3.0/ + + +Installing Karbor API with mod_wsgi +===================================== + +#. Install the Apache Service:: + + Fedora 21/RHEL7/CentOS7: + sudo yum install httpd + + Fedora 22 (or higher): + sudo dnf install httpd + + Debian/Ubuntu: + apt-get install apache2 + +#. Copy ``etc/apache2/apache-karbor-api.conf`` under the apache sites:: + + Fedora/RHEL7/CentOS7: + sudo cp etc/apache2/apache-karbor-api.conf /etc/httpd/conf.d/apache-karbor-api.conf + + Debian/Ubuntu: + sudo cp etc/apache2/apache-karbor-api.conf /etc/apache2/sites-available/apache-karbor-api.conf + +#. Edit ``apache-karbor-api.conf`` according to installtion + and environment. + + * Modify the ``WSGIDaemonProcess`` directive to set the ``user`` and + ``group`` values to appropriate user on your server. + * Modify the ``WSGIScriptAlias`` directive to point to the + watcher/api/app.wsgi script. + * Modify the ``Directory`` directive to set the path to the Watcher API + code. + * Modify the ``ErrorLog and CustomLog`` to redirect the logs to the right + directory. + +#. Enable the apache watcher site and reload:: + + Fedora/RHEL7/CentOS7: + sudo systemctl reload httpd + + Debian/Ubuntu: + sudo a2ensite apache-karbor-api + sudo apache2ctl -k restart diff --git a/etc/apache2/apache-karbor-api.conf b/etc/apache2/apache-karbor-api.conf new file mode 100644 index 00000000..69ae3b89 --- /dev/null +++ b/etc/apache2/apache-karbor-api.conf @@ -0,0 +1,37 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This is an example Apache2 configuration file for using +# karbor API through mod_wsgi +Listen 8799 + + + WSGIDaemonProcess osapi_karbor user=stack group=stack processes=2 threads=2 display-name=%{GROUP} + WSGIProcessGroup osapi_karbor + WSGIScriptAlias / /usr/local/bin/karbor-wsgi + WSGIApplicationGroup %{GLOBAL} + WSGIPassAuthorization On + + SetEnv APACHE_RUN_USER stack + SetEnv APACHE_RUN_GROUP stack + + ErrorLogFormat "%M" + + ErrorLog /var/log/apache2/karbor_api.log + CustomLog /var/log/apache2/karbor_api_access.log combined + + + Require all granted + + + + diff --git a/karbor/wsgi/wsgi.py b/karbor/wsgi/wsgi.py new file mode 100644 index 00000000..37537eb4 --- /dev/null +++ b/karbor/wsgi/wsgi.py @@ -0,0 +1,45 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Cinder OS API WSGI application.""" + + +import sys +import warnings + +from karbor import objects + +warnings.simplefilter('once', DeprecationWarning) + +from oslo_config import cfg +from oslo_log import log as logging +from oslo_service import wsgi + +from karbor import i18n +i18n.enable_lazy() + +# Need to register global_opts +from karbor.common import config # noqa +from karbor import rpc +from karbor import version + +CONF = cfg.CONF + + +def initialize_application(): + objects.register_all() + CONF(sys.argv[1:], project='karbor', + version=version.version_string()) + logging.setup(CONF, "karbor") + + rpc.init(CONF) + return wsgi.Loader(CONF).load_app(name='osapi_karbor') diff --git a/setup.cfg b/setup.cfg index b9423613..d6e2aa22 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,6 +35,8 @@ console_scripts = karbor-manage = karbor.cmd.manage:main karbor-operationengine = karbor.cmd.operationengine:main karbor-protection = karbor.cmd.protection:main +wsgi_scripts = + karbor-wsgi = karbor.wsgi.wsgi:initialize_application karbor.database.migration_backend = sqlalchemy = oslo_db.sqlalchemy.migration karbor.protections =