diff --git a/cyborg/wsgi/__init__.py b/cyborg/wsgi/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/cyborg/wsgi/api.py b/cyborg/wsgi/api.py new file mode 100644 index 00000000..34ce074b --- /dev/null +++ b/cyborg/wsgi/api.py @@ -0,0 +1,22 @@ +# 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. +"""WSGI application entry-point for Cyborg API.""" + +import threading + +from cyborg.api import wsgi_app + +application = None +lock = threading.Lock() +with lock: + if application is None: + application = wsgi_app.init_application() diff --git a/devstack/lib/cyborg b/devstack/lib/cyborg index c549ed38..631f6704 100644 --- a/devstack/lib/cyborg +++ b/devstack/lib/cyborg @@ -149,7 +149,7 @@ function configure_cyborg_api { iniset $CYBORG_CONF_FILE conductor automated_clean $CYBORG_AUTOMATED_CLEAN_ENABLED if [ "$CYBORG_USE_UWSGI" == "True" ]; then - write_uwsgi_config "$CYBORG_UWSGI_CONF" "$CYBORG_UWSGI" "/accelerator" + write_uwsgi_config "$CYBORG_UWSGI_CONF" "$CYBORG_UWSGI" "/accelerator" "" "cyborg-api" fi sudo cp -p $CYBORG_DIR/etc/cyborg/api-paste.ini $CYBORG_API_PASTE_INI } diff --git a/devstack/settings b/devstack/settings index acbf7ac1..e4f2b4b6 100644 --- a/devstack/settings +++ b/devstack/settings @@ -29,7 +29,7 @@ fi # Toggle for deploying Cyborg-API under a wsgi server CYBORG_USE_UWSGI=${CYBORG_USE_UWSGI:-True} -CYBORG_UWSGI=$CYBORG_BIN_DIR/cyborg-wsgi-api +CYBORG_UWSGI=cyborg.wsgi.api:application CYBORG_UWSGI_CONF=$CYBORG_CONF_DIR/cyborg-api-uwsgi.ini if [[ "$CYBORG_USE_UWSGI" == "True" ]]; then diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..5e862a95 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["pbr>=6.0.0", "setuptools>=64.0.0"] +build-backend = "pbr.build" diff --git a/releasenotes/notes/add-wsgi-module-supprot-e61a368fcf39a921.yaml b/releasenotes/notes/add-wsgi-module-supprot-e61a368fcf39a921.yaml new file mode 100644 index 00000000..c9c66957 --- /dev/null +++ b/releasenotes/notes/add-wsgi-module-supprot-e61a368fcf39a921.yaml @@ -0,0 +1,30 @@ +--- +features: + - | + A new module, ``cyborg.wsgi``, has been added as a place to gather WSGI + ``application`` objects. This is intended to ease deployment by providing + a consistent location for these objects. For example, if using uWSGI then + instead of: + + .. code-block:: ini + + [uwsgi] + wsgi-file = /bin/cyborg-api-wsgi + + You can now use: + + .. code-block:: ini + + [uwsgi] + module = cyborg.wsgi.api:application + + This also simplifies deployment with other WSGI servers that expect module + paths such as gunicorn. +deprecations: + - | + The cyborg-api-wsgi console script is deprecated for removal + in a future release. This artifact is generated using a setup-tools + extension that is provide by PBR which is also deprecated. + Due to the changes in python packaging this custom extensions + is planned to be removed form all OpenStack projects in a future + PBR release in favor of module based wsgi applications entry points. diff --git a/setup.cfg b/setup.cfg index 38ded6df..7decff89 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ description_file = author = OpenStack author_email = openstack-discuss@lists.openstack.org home_page = https://docs.openstack.org/cyborg/latest/ -python_requires = >=3.8 +python_requires = >=3.10 classifier = Environment :: OpenStack Intended Audience :: Information Technology @@ -17,8 +17,6 @@ classifier = Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 @@ -40,6 +38,9 @@ console_scripts = cyborg-dbsync = cyborg.cmd.dbsync:main cyborg-agent = cyborg.cmd.agent:main cyborg-status = cyborg.cmd.status:main + +# NOTE(sean-k-mooney): this should be removed in 2026.1 +# as this will eventually stop working entirely. wsgi_scripts = cyborg-wsgi-api = cyborg.api.wsgi_app:init_application diff --git a/tox.ini b/tox.ini index d7f1c5d0..2a56f650 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 3.18.0 -envlist = py38,pep8 +envlist = py3,pep8 # Automatic envs (pyXX) will only use the python version appropriate to that # env and ignore basepython inherited from [testenv] if we set # ignore_basepython_conflict.