Browse Source

Merge "Allow off-host access to horizon dashboard by default."

changes/35/693035/8
Zuul 11 months ago
committed by Gerrit Code Review
parent
commit
2f5847d6ad
4 changed files with 28 additions and 17 deletions
  1. +1
    -0
      snap/hooks/install
  2. +0
    -17
      tests/test_basic.py
  3. +1
    -0
      tools/init/init/main.py
  4. +26
    -0
      tools/init/init/questions/__init__.py

+ 1
- 0
snap/hooks/install 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.


+ 0
- 17
tests/test_basic.py 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))


+ 1
- 0
tools/init/init/main.py 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(),


+ 26
- 0
tools/init/init/questions/__init__.py 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."""



Loading…
Cancel
Save