summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Turjak <adriant@catalyst.net.nz>2018-04-17 18:27:27 +1200
committerAdrian Turjak <adriant@catalyst.net.nz>2018-05-15 01:41:01 +0000
commit0ca736e5da47413db6749053e6083b82cbb24825 (patch)
treef20dbf95b8ba1c6998e43449f7cb3c5fc3c44ef7
parent0080405eb56fc1a27775188ab09457ae8c993add (diff)
downloadhorizon-0ca736e5da47413db6749053e6083b82cbb24825.tar.gz
Create new wsgi.py file and deprecate old file
Django 1.4 stopped creating django.wsgi files and the common practice now for a while has been a wsgi.py since it is actually python code, and should actually be importable. Right now someone has to copy and rename the existing file if they want to use it with a server like gunicorn. This patch adds a new file in location that is importable via python and adds a deprecation log to the old one. This also updates the wsgi generation commands to instead create 'horizon_wsgi.py' and have the apache conf generation also use that or the default wsgi file. Change-Id: I0f8bd16c8973ad23bcd8f73b54584dc69e5aed0c Closes-Bug: #1763204
-rw-r--r--.gitignore1
-rw-r--r--doc/source/admin/customize-configure.rst8
-rw-r--r--doc/source/install/from-source.rst9
-rw-r--r--openstack_dashboard/management/commands/make_web_conf.py8
-rw-r--r--openstack_dashboard/wsgi.py29
-rw-r--r--openstack_dashboard/wsgi/django.wsgi9
-rw-r--r--releasenotes/notes/deprecation-of-old-wsgi-file-7ffdeae78698ff93.yaml9
7 files changed, 63 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 71262df06..90a371676 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ openstack_dashboard/test/.secret_key_store
openstack_dashboard/test/integration_tests/local-horizon.conf
openstack_dashboard/test/integration_tests/test_reports/
openstack_dashboard/wsgi/horizon.wsgi
+openstack_dashboard/horizon_wsgi.py
doc/build/
/static/
integration_tests_screenshots/
diff --git a/doc/source/admin/customize-configure.rst b/doc/source/admin/customize-configure.rst
index 1ba7890f1..26bc9d0e3 100644
--- a/doc/source/admin/customize-configure.rst
+++ b/doc/source/admin/customize-configure.rst
@@ -341,10 +341,10 @@ Use a domain that fits your current setup.
.. code-block:: apacheconf
- WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
+ WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi.py
WSGIDaemonProcess horizon user=www-data group=www-data processes=3 threads=10
Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
- <Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
+ <Directory /usr/share/openstack-dashboard/openstack_dashboard>
# For Apache http server 2.2 and earlier:
Order allow,deny
Allow from all
@@ -385,10 +385,10 @@ Use a domain that fits your current setup.
# wire
Header add Strict-Transport-Security "max-age=15768000"
- WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
+ WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi.py
WSGIDaemonProcess horizon user=www-data group=www-data processes=3 threads=10
Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
- <Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
+ <Directory /usr/share/openstack-dashboard/openstack_dashboard>
# For Apache http server 2.2 and earlier:
<ifVersion <2.4>
Order allow,deny
diff --git a/doc/source/install/from-source.rst b/doc/source/install/from-source.rst
index 815d06e0e..cacc40527 100644
--- a/doc/source/install/from-source.rst
+++ b/doc/source/install/from-source.rst
@@ -170,8 +170,8 @@ Deployment
$ sudo apt-get install apache2 libapache2-mod-wsgi
- You can either use the provided ``openstack_dashboard/wsgi/django.wsgi`` or
- generate a ``openstack_dashboard/wsgi/horizon.wsgi`` file with the following
+ You can either use the provided ``openstack_dashboard/wsgi.py`` or
+ generate a ``openstack_dashboard/horizon_wsgi.py`` file with the following
command (which detects if you use a virtual environment or not to
automatically build an adapted WSGI file)
@@ -184,8 +184,9 @@ Deployment
``/etc/apache2/sites-available/horizon.conf``.
The template in DevStack is a good example of the file.
http://git.openstack.org/cgit/openstack-dev/devstack/tree/files/apache-horizon.template
- Or, if you previously generated an ``openstack_dashboard/wsgi/horizon.wsgi``
- you can automatically generate an apache configuration file
+ Or you can automatically generate an apache configuration file. If you
+ previously generated an ``openstack_dashboard/horizon_wsgi.py`` file it will
+ use that, otherwise will default to using ``openstack_dashboard/wsgi.py``
.. code-block:: console
diff --git a/openstack_dashboard/management/commands/make_web_conf.py b/openstack_dashboard/management/commands/make_web_conf.py
index f663ccfa4..080e88f59 100644
--- a/openstack_dashboard/management/commands/make_web_conf.py
+++ b/openstack_dashboard/management/commands/make_web_conf.py
@@ -85,8 +85,10 @@ context['PROJECT_DIR_NAME'] = os.path.basename(
context['PROJECT_PATH'].split(context['PROJECT_ROOT'])[1])
context['PROJECT_NAME'] = context['PROJECT_DIR_NAME']
+context['DEFAULT_WSGI_FILE'] = os.path.join(
+ context['PROJECT_PATH'], 'wsgi.py')
context['WSGI_FILE'] = os.path.join(
- context['PROJECT_PATH'], 'wsgi/horizon.wsgi')
+ context['PROJECT_PATH'], 'horizon_wsgi.py')
VHOSTNAME = context['HOSTNAME'].split('.')
VHOSTNAME[0] = context['PROJECT_NAME']
@@ -316,6 +318,10 @@ location you desire, e.g.::
# Generate the apache configuration.
elif options.get('apache'):
+ # first check if custom wsgi file exists, if not, use default:
+ if not os.path.exists(context['WSGI_FILE']):
+ context['WSGI_FILE'] = context['DEFAULT_WSGI_FILE']
+
with open(
os.path.join(CURDIR, 'apache_vhost.conf.template'), 'r'
) as fp:
diff --git a/openstack_dashboard/wsgi.py b/openstack_dashboard/wsgi.py
new file mode 100644
index 000000000..59f75dd68
--- /dev/null
+++ b/openstack_dashboard/wsgi.py
@@ -0,0 +1,29 @@
+# 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 config for openstack_dashboard project.
+"""
+
+import os
+import sys
+
+from django.core.wsgi import get_wsgi_application
+
+# Add this file path to sys.path in order to import settings
+sys.path.insert(0, os.path.normpath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '../..')))
+os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'
+sys.stdout = sys.stderr
+
+application = get_wsgi_application()
diff --git a/openstack_dashboard/wsgi/django.wsgi b/openstack_dashboard/wsgi/django.wsgi
index fae25b374..89fda5688 100644
--- a/openstack_dashboard/wsgi/django.wsgi
+++ b/openstack_dashboard/wsgi/django.wsgi
@@ -17,6 +17,7 @@
WSGI config for openstack_dashboard project.
"""
+import logging
import os
import sys
@@ -28,6 +29,12 @@ sys.path.insert(0, os.path.normpath(os.path.join(
os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'
sys.stdout = sys.stderr
-DEBUG = False
+logging.warning(
+ "Use of this 'djano.wsgi' file has been deprecated since the Rocky "
+ "release in favor of 'wsgi.py' in the 'openstack_dashboard' module. This "
+ "file is a legacy naming from before Django 1.4 and an importable "
+ "'wsgi.py' is now the default. This file will be removed in the T release "
+ "cycle."
+)
application = get_wsgi_application()
diff --git a/releasenotes/notes/deprecation-of-old-wsgi-file-7ffdeae78698ff93.yaml b/releasenotes/notes/deprecation-of-old-wsgi-file-7ffdeae78698ff93.yaml
new file mode 100644
index 000000000..20a8ca453
--- /dev/null
+++ b/releasenotes/notes/deprecation-of-old-wsgi-file-7ffdeae78698ff93.yaml
@@ -0,0 +1,9 @@
+---
+deprecations:
+ - |
+ [:bug:`1763204`]
+ Use of this 'djano.wsgi' file has been deprecated since the Rocky
+ release in favor of 'wsgi.py' in the 'openstack_dashboard' module. This
+ file is a legacy naming from before Django 1.4 and an importable
+ 'wsgi.py' is now the default. This file will be removed in the T release
+ cycle.