Continue working on getting horizon back in shape
This commit is contained in:
@@ -37,7 +37,7 @@ DASH_NAME = 'dashboard'
|
|||||||
|
|
||||||
# Config files messed with
|
# Config files messed with
|
||||||
HORIZON_PY_CONF = "horizon_settings.py"
|
HORIZON_PY_CONF = "horizon_settings.py"
|
||||||
HORIZON_APACHE_CONF = '000-default'
|
HORIZON_APACHE_CONF = 'horizon.conf'
|
||||||
CONFIGS = [HORIZON_PY_CONF, HORIZON_APACHE_CONF]
|
CONFIGS = [HORIZON_PY_CONF, HORIZON_APACHE_CONF]
|
||||||
|
|
||||||
# DB sync that needs to happen for horizon
|
# DB sync that needs to happen for horizon
|
||||||
@@ -58,7 +58,13 @@ class HorizonUninstaller(comp.PythonUninstallComponent):
|
|||||||
class HorizonInstaller(comp.PythonInstallComponent):
|
class HorizonInstaller(comp.PythonInstallComponent):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.PythonInstallComponent.__init__(self, *args, **kargs)
|
comp.PythonInstallComponent.__init__(self, *args, **kargs)
|
||||||
self.log_dir = sh.joinpths(self.get_option('component_dir'), 'logs')
|
self.blackhole_dir = sh.joinpths(self.get_option('app_dir'), '.blackhole')
|
||||||
|
self.access_log = sh.joinpths('/var/log/',
|
||||||
|
self.distro.get_command_config('apache', 'name'),
|
||||||
|
'horizon_access.log')
|
||||||
|
self.error_log = sh.joinpths('/var/log/',
|
||||||
|
self.distro.get_command_config('apache', 'name'),
|
||||||
|
'horizon_error.log')
|
||||||
|
|
||||||
def _filter_pip_requires_line(self, line):
|
def _filter_pip_requires_line(self, line):
|
||||||
# Knock off all nova, quantum, swift, keystone, cinder
|
# Knock off all nova, quantum, swift, keystone, cinder
|
||||||
@@ -75,14 +81,8 @@ class HorizonInstaller(comp.PythonInstallComponent):
|
|||||||
@property
|
@property
|
||||||
def symlinks(self):
|
def symlinks(self):
|
||||||
links = super(HorizonInstaller, self).symlinks
|
links = super(HorizonInstaller, self).symlinks
|
||||||
tgt = self.distro.get_command_config('apache', 'settings', 'conf-link-target', quiet=True)
|
links[self.access_log] = [sh.joinpths(self.link_dir, 'access.log')]
|
||||||
if not tgt:
|
links[self.error_log] = [sh.joinpths(self.link_dir, 'error.log')]
|
||||||
return links
|
|
||||||
src = self.target_config(HORIZON_APACHE_CONF)
|
|
||||||
if src in links:
|
|
||||||
links[src].append(tgt)
|
|
||||||
else:
|
|
||||||
links[src] = [tgt]
|
|
||||||
return links
|
return links
|
||||||
|
|
||||||
def _check_ug(self):
|
def _check_ug(self):
|
||||||
@@ -102,8 +102,7 @@ class HorizonInstaller(comp.PythonInstallComponent):
|
|||||||
def target_config(self, config_name):
|
def target_config(self, config_name):
|
||||||
if config_name == HORIZON_PY_CONF:
|
if config_name == HORIZON_PY_CONF:
|
||||||
# FIXME(harlowja) don't write to checked out locations...
|
# FIXME(harlowja) don't write to checked out locations...
|
||||||
dash_dir = sh.joinpths(self.get_option('app_dir'), ROOT_DASH)
|
return sh.joinpths(self.get_option('app_dir'), ROOT_DASH, 'local', 'local_settings.py')
|
||||||
return sh.joinpths(dash_dir, 'local', 'local_settings.py')
|
|
||||||
else:
|
else:
|
||||||
return comp.PythonInstallComponent.target_config(self, config_name)
|
return comp.PythonInstallComponent.target_config(self, config_name)
|
||||||
|
|
||||||
@@ -113,8 +112,20 @@ class HorizonInstaller(comp.PythonInstallComponent):
|
|||||||
|
|
||||||
def _setup_blackhole(self):
|
def _setup_blackhole(self):
|
||||||
# Create an empty directory that apache uses as docroot
|
# Create an empty directory that apache uses as docroot
|
||||||
black_hole_dir = sh.joinpths(self.get_option('app_dir'), '.blackhole')
|
self.tracewriter.dirs_made(*sh.mkdirslist(self.blackhole_dir))
|
||||||
self.tracewriter.dirs_made(*sh.mkdirslist(black_hole_dir))
|
|
||||||
|
def _setup_logs(self, clear):
|
||||||
|
log_fns = [self.access_log, self.error_log]
|
||||||
|
utils.log_iterable(log_fns, logger=LOG,
|
||||||
|
header="Adjusting %s log files" % (len(log_fns)))
|
||||||
|
for fn in log_fns:
|
||||||
|
with sh.Rooted(True):
|
||||||
|
if clear:
|
||||||
|
sh.unlink(fn, True)
|
||||||
|
sh.touch_file(fn, die_if_there=False)
|
||||||
|
sh.chmod(fn, 0666)
|
||||||
|
self.tracewriter.file_touched(fn)
|
||||||
|
return len(log_fns)
|
||||||
|
|
||||||
def _sync_db(self):
|
def _sync_db(self):
|
||||||
# Initialize the horizon database (it stores sessions and notices shown to users).
|
# Initialize the horizon database (it stores sessions and notices shown to users).
|
||||||
@@ -134,12 +145,10 @@ class HorizonInstaller(comp.PythonInstallComponent):
|
|||||||
**utils.merge_dicts(self.get_option('db'),
|
**utils.merge_dicts(self.get_option('db'),
|
||||||
dbhelper.get_shared_passwords(self)))
|
dbhelper.get_shared_passwords(self)))
|
||||||
|
|
||||||
def pre_install(self):
|
def _configure_files(self):
|
||||||
comp.PythonInstallComponent.pre_install(self)
|
am = comp.PythonInstallComponent._configure_files(self)
|
||||||
self.tracewriter.dirs_made(*sh.mkdirslist(self.log_dir))
|
am += self._setup_logs(self.get_bool_option('clear-logs'))
|
||||||
|
return am
|
||||||
def _config_fixups(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def post_install(self):
|
def post_install(self):
|
||||||
comp.PythonInstallComponent.post_install(self)
|
comp.PythonInstallComponent.post_install(self)
|
||||||
@@ -148,7 +157,6 @@ class HorizonInstaller(comp.PythonInstallComponent):
|
|||||||
self._sync_db()
|
self._sync_db()
|
||||||
if self.get_bool_option('make-blackhole'):
|
if self.get_bool_option('make-blackhole'):
|
||||||
self._setup_blackhole()
|
self._setup_blackhole()
|
||||||
self._config_fixups()
|
|
||||||
|
|
||||||
def _get_apache_user_group(self):
|
def _get_apache_user_group(self):
|
||||||
return (self.get_option('apache_user'), self.get_option('apache_group'))
|
return (self.get_option('apache_user'), self.get_option('apache_group'))
|
||||||
@@ -164,6 +172,9 @@ class HorizonInstaller(comp.PythonInstallComponent):
|
|||||||
mp['HORIZON_DIR'] = self.get_option('app_dir')
|
mp['HORIZON_DIR'] = self.get_option('app_dir')
|
||||||
mp['HORIZON_PORT'] = self.get_int_option('port', default_value=80)
|
mp['HORIZON_PORT'] = self.get_int_option('port', default_value=80)
|
||||||
mp['APACHE_NAME'] = self.distro.get_command_config('apache', 'name')
|
mp['APACHE_NAME'] = self.distro.get_command_config('apache', 'name')
|
||||||
|
mp['ERROR_LOG'] = self.error_log
|
||||||
|
mp['ACCESS_LOG'] = self.access_log
|
||||||
|
mp['BLACK_HOLE_DIR'] = self.blackhole_dir
|
||||||
else:
|
else:
|
||||||
mp['OPENSTACK_HOST'] = self.get_option('ip')
|
mp['OPENSTACK_HOST'] = self.get_option('ip')
|
||||||
mp['DB_NAME'] = DB_NAME
|
mp['DB_NAME'] = DB_NAME
|
||||||
|
|||||||
@@ -54,37 +54,32 @@ DEF_IDENT = 'unix-group:libvirtd'
|
|||||||
|
|
||||||
class DBInstaller(db.DBInstaller):
|
class DBInstaller(db.DBInstaller):
|
||||||
|
|
||||||
|
MYSQL_CONF = '/etc/my.cnf'
|
||||||
|
|
||||||
def _configure_db_confs(self):
|
def _configure_db_confs(self):
|
||||||
LOG.info("Fixing up %s mysql configs.", colorizer.quote(self.distro.name))
|
LOG.info("Fixing up %s mysql configs.", colorizer.quote(self.distro.name))
|
||||||
fc = sh.load_file('/etc/my.cnf')
|
|
||||||
lines = fc.splitlines()
|
|
||||||
new_lines = []
|
new_lines = []
|
||||||
for line in lines:
|
for line in sh.load_file(DBInstaller.MYSQL_CONF).splitlines():
|
||||||
if line.startswith('skip-grant-tables'):
|
if line.startswith('skip-grant-tables'):
|
||||||
line = '#' + line
|
new_lines.append('#' + line)
|
||||||
new_lines.append(line)
|
elif line.startswith('bind-address'):
|
||||||
fc = utils.joinlinesep(*new_lines)
|
new_lines.append('#' + line)
|
||||||
|
new_lines.append('bind-address = 0.0.0.0')
|
||||||
|
else:
|
||||||
|
new_lines.append(line)
|
||||||
with sh.Rooted(True):
|
with sh.Rooted(True):
|
||||||
sh.write_file('/etc/my.cnf', fc)
|
sh.write_file_and_backup(DBInstaller.MYSQL_CONF, utils.joinlinesep(*new_lines))
|
||||||
|
|
||||||
|
|
||||||
class HorizonInstaller(horizon.HorizonInstaller):
|
class HorizonInstaller(horizon.HorizonInstaller):
|
||||||
|
|
||||||
def _config_fix_wsgi(self):
|
HTTPD_CONF = '/etc/httpd/conf/httpd.conf'
|
||||||
# This is recorded so it gets cleaned up during uninstall
|
|
||||||
self.tracewriter.file_touched("/etc/httpd/conf.d/wsgi-socket-prefix.conf")
|
|
||||||
LOG.info("Fixing up: %s", colorizer.quote("/etc/httpd/conf.d/wsgi-socket-prefix.conf"))
|
|
||||||
contents = "WSGISocketPrefix %s" % (sh.joinpths(self.log_dir, "wsgi-socket"))
|
|
||||||
with sh.Rooted(True):
|
|
||||||
# The name seems to need to come after wsgi.conf (so thats what we are doing)
|
|
||||||
sh.write_file("/etc/httpd/conf.d/wsgi-socket-prefix.conf", contents)
|
|
||||||
|
|
||||||
def _config_fix_httpd(self):
|
def _config_fix_httpd(self):
|
||||||
LOG.info("Fixing up: %s", colorizer.quote('/etc/httpd/conf/httpd.conf'))
|
LOG.info("Fixing up: %s", colorizer.quote(HorizonInstaller.HTTPD_CONF))
|
||||||
(user, group) = self._get_apache_user_group()
|
(user, group) = self._get_apache_user_group()
|
||||||
old_lines = sh.load_file('/etc/httpd/conf/httpd.conf').splitlines()
|
new_lines = []
|
||||||
new_lines = list()
|
for line in sh.load_file(HorizonInstaller.HTTPD_CONF).splitlines():
|
||||||
for line in old_lines:
|
|
||||||
# Directives in the configuration files are case-insensitive,
|
# Directives in the configuration files are case-insensitive,
|
||||||
# but arguments to directives are often case sensitive...
|
# but arguments to directives are often case sensitive...
|
||||||
# NOTE(harlowja): we aren't handling multi-line fixups...
|
# NOTE(harlowja): we aren't handling multi-line fixups...
|
||||||
@@ -95,14 +90,26 @@ class HorizonInstaller(horizon.HorizonInstaller):
|
|||||||
if re.match("^\s*Listen\s+(.*)$", line, re.I):
|
if re.match("^\s*Listen\s+(.*)$", line, re.I):
|
||||||
line = "Listen 0.0.0.0:80"
|
line = "Listen 0.0.0.0:80"
|
||||||
new_lines.append(line)
|
new_lines.append(line)
|
||||||
contents = utils.joinlinesep(*new_lines)
|
|
||||||
with sh.Rooted(True):
|
with sh.Rooted(True):
|
||||||
sh.write_file('/etc/httpd/conf/httpd.conf', contents)
|
sh.write_file_and_backup(HorizonInstaller.HTTPD_CONF, utils.joinlinesep(*new_lines))
|
||||||
|
|
||||||
def _config_fixups(self):
|
def _config_fixups(self):
|
||||||
self._config_fix_wsgi()
|
|
||||||
self._config_fix_httpd()
|
self._config_fix_httpd()
|
||||||
|
|
||||||
|
def post_install(self):
|
||||||
|
horizon.HorizonInstaller.post_install(self)
|
||||||
|
self._config_fixups()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def symlinks(self):
|
||||||
|
links = super(HorizonInstaller, self).symlinks
|
||||||
|
links[self.target_config(horizon.HORIZON_APACHE_CONF)].append(sh.joinpths('/etc/',
|
||||||
|
self.distro.get_command_config('apache', 'name'),
|
||||||
|
'conf.d',
|
||||||
|
horizon.HORIZON_APACHE_CONF))
|
||||||
|
return links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RabbitRuntime(rabbit.RabbitRuntime):
|
class RabbitRuntime(rabbit.RabbitRuntime):
|
||||||
|
|
||||||
|
|||||||
@@ -250,6 +250,10 @@ def shellquote(text):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
def fileperms(path):
|
||||||
|
return (os.stat(path).st_mode & 0777)
|
||||||
|
|
||||||
|
|
||||||
def listdir(path):
|
def listdir(path):
|
||||||
return os.listdir(path)
|
return os.listdir(path)
|
||||||
|
|
||||||
@@ -655,6 +659,23 @@ def move(src, dst):
|
|||||||
return dst
|
return dst
|
||||||
|
|
||||||
|
|
||||||
|
def write_file_and_backup(path, contents, bk_ext='org'):
|
||||||
|
perms = None
|
||||||
|
backup_path = None
|
||||||
|
if isfile(path):
|
||||||
|
perms = fileperms(path)
|
||||||
|
backup_path = "%s.%s" % (path, bk_ext)
|
||||||
|
if not isfile(backup_path):
|
||||||
|
LOG.debug("Backing up %s => %s", path, backup_path)
|
||||||
|
move(path, backup_path)
|
||||||
|
else:
|
||||||
|
LOG.debug("Leaving original backup of %s at %s", path, backup_path)
|
||||||
|
write_file(path, contents)
|
||||||
|
if perms is not None:
|
||||||
|
chmod(path, perms)
|
||||||
|
return backup_path
|
||||||
|
|
||||||
|
|
||||||
def chmod(fname, mode):
|
def chmod(fname, mode):
|
||||||
LOG.debug("Applying chmod: %r to %o" % (fname, mode))
|
LOG.debug("Applying chmod: %r to %o" % (fname, mode))
|
||||||
if not is_dry_run():
|
if not is_dry_run():
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ commands:
|
|||||||
apache:
|
apache:
|
||||||
name: httpd
|
name: httpd
|
||||||
restart: service httpd restart
|
restart: service httpd restart
|
||||||
settings:
|
|
||||||
conf-link-target: /etc/httpd/conf.d/horizon.conf
|
|
||||||
start: service httpd start
|
start: service httpd start
|
||||||
status: service httpd status
|
status: service httpd status
|
||||||
stop: service httpd stop
|
stop: service httpd stop
|
||||||
|
|||||||
@@ -2,14 +2,17 @@
|
|||||||
This is a cheetah template!
|
This is a cheetah template!
|
||||||
*#
|
*#
|
||||||
<VirtualHost *:$HORIZON_PORT>
|
<VirtualHost *:$HORIZON_PORT>
|
||||||
WSGIScriptAlias / $HORIZON_DIR/openstack_dashboard/wsgi/django.wsgi
|
WSGIScriptAlias / ${HORIZON_DIR}/openstack_dashboard/wsgi/django.wsgi
|
||||||
WSGIDaemonProcess horizon user=$USER group=$GROUP processes=3 threads=10 home=$HORIZON_DIR
|
WSGIDaemonProcess horizon user=$USER group=$GROUP processes=3 threads=10 home=$HORIZON_DIR
|
||||||
|
WSGIApplicationGroup %{GLOBAL}
|
||||||
|
|
||||||
SetEnv APACHE_RUN_USER $USER
|
SetEnv APACHE_RUN_USER $USER
|
||||||
SetEnv APACHE_RUN_GROUP $GROUP
|
SetEnv APACHE_RUN_GROUP $GROUP
|
||||||
WSGIProcessGroup horizon
|
WSGIProcessGroup horizon
|
||||||
|
|
||||||
DocumentRoot $HORIZON_DIR/.blackhole/
|
#if $BLACK_HOLE_DIR
|
||||||
|
DocumentRoot $BLACK_HOLE_DIR
|
||||||
|
#end if
|
||||||
Alias /media $HORIZON_DIR/openstack_dashboard/static
|
Alias /media $HORIZON_DIR/openstack_dashboard/static
|
||||||
|
|
||||||
<Directory />
|
<Directory />
|
||||||
@@ -17,15 +20,15 @@
|
|||||||
AllowOverride None
|
AllowOverride None
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<Directory $HORIZON_DIR/>
|
<Directory ${HORIZON_DIR}>
|
||||||
Options Indexes FollowSymLinks MultiViews
|
Options Indexes FollowSymLinks MultiViews
|
||||||
AllowOverride None
|
AllowOverride None
|
||||||
Order allow,deny
|
Order allow,deny
|
||||||
allow from all
|
allow from all
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
ErrorLog /var/log/$APACHE_NAME/horizon_error.log
|
ErrorLog ${ERROR_LOG}
|
||||||
CustomLog /var/log/$APACHE_NAME/horizon_access.log combined
|
CustomLog ${ACCESS_LOG} combined
|
||||||
LogLevel warn
|
LogLevel warn
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|
||||||
Reference in New Issue
Block a user