diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-04-08 22:41:02 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-04-08 22:41:02 +0000 |
commit | 60d11845ce0175a662082a94245c7685da0e2136 (patch) | |
tree | 82a4927234cb9bbdeab7cf7b8f063ebc33c6ebaa /openstack_dashboard | |
parent | 4cbfe55c7e366a5a099d2f0e8d5e66b5849bb162 (diff) | |
parent | 42bc31b38687ff8c41319d0e9384e628adbb0a21 (diff) | |
download | horizon-60d11845ce0175a662082a94245c7685da0e2136.tar.gz |
Merge "Detect apache version"
Diffstat (limited to 'openstack_dashboard')
-rw-r--r-- | openstack_dashboard/management/commands/apache_vhost.conf.template | 8 | ||||
-rw-r--r-- | openstack_dashboard/management/commands/make_web_conf.py | 43 |
2 files changed, 49 insertions, 2 deletions
diff --git a/openstack_dashboard/management/commands/apache_vhost.conf.template b/openstack_dashboard/management/commands/apache_vhost.conf.template index 5db931852..06fe27fd6 100644 --- a/openstack_dashboard/management/commands/apache_vhost.conf.template +++ b/openstack_dashboard/management/commands/apache_vhost.conf.template @@ -24,12 +24,16 @@ WSGIPassAuthorization On WSGIScriptAlias / {{ WSGI_FILE }} - +{% if APACHE2_VERSION >= 2.4 %} + <Location "/"> + Require all granted + </Location> +{% else %} <Location "/"> Order Allow,Deny Allow from all </Location> - +{% endif %} Alias /static {{ STATIC_PATH }} <Location "/static"> SetHandler None diff --git a/openstack_dashboard/management/commands/make_web_conf.py b/openstack_dashboard/management/commands/make_web_conf.py index 38d1de887..9cbfe61d4 100644 --- a/openstack_dashboard/management/commands/make_web_conf.py +++ b/openstack_dashboard/management/commands/make_web_conf.py @@ -15,7 +15,9 @@ from __future__ import print_function from optparse import make_option # noqa import os +import re import socket +import subprocess import sys import warnings @@ -33,6 +35,14 @@ CURDIR = os.path.realpath(os.path.dirname(__file__)) PROJECT_PATH = os.path.realpath(os.path.join(CURDIR, '../..')) STATIC_PATH = os.path.realpath(os.path.join(PROJECT_PATH, '../static')) +# Known apache regular expression to retrieve it's version +APACHE_VERSION_REG = r'Apache/(?P<version>[\d.]*)' +# Known apache commands to retrieve it's version +APACHE2_VERSION_CMDS = ( + (('/usr/sbin/apache2ctl', '-V'), APACHE_VERSION_REG), + (('/usr/sbin/apache2', '-v'), APACHE_VERSION_REG), +) + # Known apache log directory locations APACHE_LOG_DIRS = ( '/var/log/httpd', # RHEL / Red Hat / CentOS / Fedora Linux @@ -94,6 +104,29 @@ if virtualenv: if os.path.exists(activate_this): context['ACTIVATE_THIS'] = activate_this +# Try to detect apache's version +# We fallback on 2.4. +context['APACHE2_VERSION'] = 2.4 +APACHE2_VERSION = None +for cmd in APACHE2_VERSION_CMDS: + if os.path.exists(cmd[0][0]): + try: + reg = re.compile(cmd[1]) + res = reg.search( + subprocess.check_output(cmd[0], stderr=subprocess.STDOUT)) + if res: + APACHE2_VERSION = res.group('version') + break + except subprocess.CalledProcessError: + pass +if APACHE2_VERSION: + ver_nums = APACHE2_VERSION.split('.') + if len(ver_nums) >= 2: + try: + context['APACHE2_VERSION'] = float('.'.join(ver_nums[:2])) + except ValueError: + pass + def find_apache_log_dir(): for log_dir in APACHE_LOG_DIRS: @@ -190,6 +223,14 @@ location you desire, e.g.:: "the path to the SSLCertificateKeyFile " "(default : %s)") % context['SSLKEY'], metavar="SSLKEY"), + make_option("--apache-version", + dest="apache_version", + type="float", + help=("Use with the --apache option to define the apache " + "major (as a floating point number) version " + "(default : %s)." + % context['APACHE2_VERSION']), + metavar="APACHE_VERSION"), make_option("-w", "--wsgi", default=False, action="store_true", dest="wsgi", help="generate the horizon.wsgi file"), @@ -213,6 +254,8 @@ location you desire, e.g.:: context['SSLCERT'] = options['sslcert'] if options.get('sslkey'): context['SSLKEY'] = options['sslkey'] + if options.get('apache_version'): + context['APACHE2_VERSION'] = options['apache_version'] if options.get('namedhost'): context['NAMEDHOST'] = context['VHOSTNAME'] |