Use generated passwords for admin and charm users

Hard coded defaults are not good; switch to using generated
passwords for core admin and charm users.

Change-Id: Ic2933966ab81d68e320556df2bcac5329ccc9c8d
This commit is contained in:
James Page 2022-10-10 14:57:35 +01:00
parent 8db5069062
commit c91175597f
4 changed files with 19 additions and 8 deletions

View File

@ -1,3 +1,5 @@
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
{ }
get-admin-password:
description: Get the password for the Keystone Admin user

View File

@ -293,6 +293,14 @@ class KeystoneOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
self.framework.observe(self.on.heartbeat, self._on_heartbeat)
self._launch_heartbeat()
self.framework.observe(
self.on.get_admin_password_action,
self._get_admin_password_action
)
def _get_admin_password_action(self, event):
event.set_results({"password": self.admin_password})
def _launch_heartbeat(self):
"""
Launch another process that will wake up the charm every 5 minutes.
@ -584,9 +592,9 @@ class KeystoneOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
return self._state.admin_domain_id
@property
def admin_password(self):
# TODO(wolsen) password stuff
return 'abc123'
def admin_password(self) -> str:
"""Retrieve the password for the Admin user."""
return self._retrieve_or_set_password(self.admin_user)
@property
def admin_user(self):
@ -606,9 +614,9 @@ class KeystoneOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
return '_charm-keystone-admin'
@property
def charm_password(self):
# TODO
return 'abc123'
def charm_password(self) -> str:
"""The password for the charm admin user."""
return self._retrieve_or_set_password(self.charm_user)
@property
def service_project(self):

View File

@ -9,6 +9,6 @@ mock
flake8
stestr
git+https://github.com/openstack-charmers/zaza.git#egg=zaza
git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack
git+https://github.com/javacruft/zaza-openstack-tests.git@get-admin-passwords-k8s#egg=zaza.openstack
git+https://opendev.org/openstack/tempest.git#egg=tempest
ops

View File

@ -0,0 +1 @@
../actions.yaml