Fixed dashboard_allowed_hosts config setting.

Now happens in a template, just like all the other values, which fixes
an issue where it doesn't get overridden during an upgrade.

Change-Id: Ied84ddc0282c77de6797f90efc8923ae66a9d59e
This commit is contained in:
Pete Vander Giessen 2019-11-20 15:48:33 +00:00 committed by Frode Nordahl
parent 590a7bc3d5
commit 2915caf98e
3 changed files with 4 additions and 18 deletions

View File

@ -68,6 +68,7 @@ setup:
extgateway: 'config.network.ext-gateway'
extcidr: 'config.network.ext-cidr'
dns: 'config.network.dns'
dashboard_allowed_hosts: 'config.network.dashboard-allowed-hosts'
entry_points:
keystone-manage:
binary: "{snap}/bin/keystone-manage"

View File

@ -28,7 +28,7 @@ OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_"
# Turn off external access for now. (This should be turned on once we
# have hooks for setting a non default password.)
ALLOWED_HOSTS = ['10.20.20.1', 'localhost', '127.0.0.1']
ALLOWED_HOSTS = "{{ dashboard_allowed_hosts }}".split(",")
# Use memcached as our caching backend.
CACHES = {

View File

@ -249,31 +249,16 @@ class FileHandleLimits(Question):
pass
class DashboardAccess(Question):
class DashboardAccess(ConfigQuestion):
_type = 'string'
_question = 'Dashboard allowed hosts.'
config_key = 'config.network.dashboard-allowed-hosts'
def yes(self, answer):
log.info("Opening horizon dashboard up to {hosts}".format(
hosts=answer))
path_ = ('{SNAP_COMMON}/etc/horizon/local_settings.d'
'/_10_hosts.py'.format(**_env))
allowed_hosts = answer.split(',')
# TODO: move to template.
# TODO: sanitize (since we're writing to executable Python!)
with open(path_, 'w') as hosts:
hosts.write("""\
ALLOWED_HOSTS = {hosts}
""".format(hosts=allowed_hosts))
# Restart if needed.
if check_output('snapctl', 'get', 'initialized'):
check('snapctl', 'restart', 'microstack.horizon-uwsgi')
class RabbitMq(Question):
"""Wait for Rabbit to start, then setup permissions."""