Allow off-host access to horizon dashboard by default.

Added a question which allows off host access to horizon
dashboard. Activated it by default, as that's probably what people are
going to actually want.

Change-Id: I0d5bccb3b2eb2b409072d8ae5f8b923942386119
This commit is contained in:
Pete Vander Giessen 2019-10-29 20:13:29 +00:00
parent a89cb36883
commit 9e6b8c1e21
4 changed files with 28 additions and 17 deletions

View File

@ -18,6 +18,7 @@ snapctl set \
config.network.compute-ip=10.20.20.1 \
config.network.ext-cidr=10.20.20.1/24 \
config.network.security-rules=true \
config.network.dashboard-allowed-hosts="*" \
;
# Passwords, certs, etc.

View File

@ -117,23 +117,6 @@ class TestBasics(Framework):
# TODO: get rid of this, when we drop the ping tests back int.
time.sleep(10)
if 'multipass' in self.PREFIX:
print("Opening {}:80 up to the outside world".format(
self.HORIZON_IP))
with open('/tmp/_10_hosts.py', 'w') as hosts:
hosts.write("""\
# Allow all hosts to connect to this machine
ALLOWED_HOSTS = ['*',]
""")
check('multipass', 'copy-files', '/tmp/_10_hosts.py',
'{}:/tmp/_10_hosts.py'.format(self.MACHINE))
check(
*self.PREFIX, 'sudo', 'cp', '/tmp/_10_hosts.py',
'/var/snap/microstack/common/etc/horizon/local_settings.d/'
)
check(*self.PREFIX, 'sudo', 'snap', 'restart', 'microstack')
print('Verifying GUI for (IP: {})'.format(self.HORIZON_IP))
# Verify that our GUI is working properly
self.driver.get("http://{}/".format(self.HORIZON_IP))

View File

@ -103,6 +103,7 @@ def main() -> None:
# The following are not yet implemented:
# questions.VmSwappiness(),
# questions.FileHandleLimits(),
questions.DashboardAccess(),
questions.RabbitMq(),
questions.DatabaseSetup(),
questions.NovaHypervisor(),

View File

@ -275,6 +275,32 @@ class FileHandleLimits(Question):
pass
class DashboardAccess(Question):
_type = 'string'
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."""