diff --git a/charms/keystone-k8s/actions.yaml b/charms/keystone-k8s/actions.yaml index 7cfa4340..dde89496 100644 --- a/charms/keystone-k8s/actions.yaml +++ b/charms/keystone-k8s/actions.yaml @@ -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 diff --git a/charms/keystone-k8s/src/charm.py b/charms/keystone-k8s/src/charm.py index a014822e..d833f7a4 100755 --- a/charms/keystone-k8s/src/charm.py +++ b/charms/keystone-k8s/src/charm.py @@ -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): diff --git a/charms/keystone-k8s/test-requirements.txt b/charms/keystone-k8s/test-requirements.txt index 8febe61e..510cf577 100644 --- a/charms/keystone-k8s/test-requirements.txt +++ b/charms/keystone-k8s/test-requirements.txt @@ -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 diff --git a/charms/keystone-k8s/tests/actions.yaml b/charms/keystone-k8s/tests/actions.yaml new file mode 120000 index 00000000..9adaf92e --- /dev/null +++ b/charms/keystone-k8s/tests/actions.yaml @@ -0,0 +1 @@ +../actions.yaml \ No newline at end of file