diff --git a/actions.yaml b/actions.yaml index 1fb080e6..30f84869 100644 --- a/actions.yaml +++ b/actions.yaml @@ -9,6 +9,9 @@ resume: Resume keystone services. If the keystone deployment is clustered using the hacluster charm, the corresponding hacluster unit on the node must be resumed as well. +get-admin-password: + description: | + Retrieve the admin password for the Keystone service. rotate-admin-password: description: | Rotate the admin user's password. @@ -22,5 +25,3 @@ security-checklist: description: | Validate the running configuration against the OpenStack security guides checklist. -get-admin-password: - description: Retrieve the admin password for the Keystone service. diff --git a/actions/actions.py b/actions/actions.py index c91dfff3..c184f5c8 100755 --- a/actions/actions.py +++ b/actions/actions.py @@ -33,21 +33,12 @@ _add_path(_root) from charmhelpers.core.hookenv import action_fail from keystone_utils import ( - rotate_admin_passwd, pause_unit_helper, resume_unit_helper, register_configs, ) -def rotate_admin_password(args): - """Rotate the admin user's password. - - @raises Exception if keystone client cannot update the password - """ - rotate_admin_passwd() - - def pause(args): """Pause all the Keystone services. @@ -67,7 +58,6 @@ def resume(args): # A dictionary of all the defined actions to callables (which take # parsed arguments). ACTIONS = { - "rotate-admin-password": rotate_admin_password, "pause": pause, "resume": resume, } diff --git a/actions/admin_password.py b/actions/admin_password.py index 339834f7..9c99b776 100755 --- a/actions/admin_password.py +++ b/actions/admin_password.py @@ -18,6 +18,7 @@ import os import sys sys.path.append('.') +sys.path.append('./hooks') from charmhelpers.core.hookenv import ( function_set, @@ -25,14 +26,25 @@ from charmhelpers.core.hookenv import ( leader_get, ) +from keystone_utils import rotate_admin_passwd + def get_admin_password(arg): """Implementation of 'get-admin-password' action.""" function_set({'admin-password': leader_get("admin_passwd")}) +def rotate_admin_password(args): + """Rotate the admin user's password. + + @raises Exception if keystone client cannot update the password + """ + rotate_admin_passwd() + + ACTIONS = { - "get-admin-password": get_admin_password + "get-admin-password": get_admin_password, + "rotate-admin-password": rotate_admin_password, } diff --git a/actions/rotate-admin-password b/actions/rotate-admin-password index 405a394e..f4617365 120000 --- a/actions/rotate-admin-password +++ b/actions/rotate-admin-password @@ -1 +1 @@ -actions.py \ No newline at end of file +admin_password.py \ No newline at end of file diff --git a/unit_tests/test_actions.py b/unit_tests/test_actions.py index 174ef121..842f8396 100644 --- a/unit_tests/test_actions.py +++ b/unit_tests/test_actions.py @@ -25,17 +25,6 @@ with patch('charmhelpers.contrib.openstack.utils.' import actions.actions -class ChangeAdminPasswordTestCase(CharmTestCase): - - def setUp(self): - super(ChangeAdminPasswordTestCase, self).setUp( - actions.actions, ["rotate_admin_passwd"]) - - def test_rotate_admin_password(self): - actions.actions.rotate_admin_password([]) - self.rotate_admin_passwd.assert_called_once() - - class PauseTestCase(CharmTestCase): def setUp(self): diff --git a/unit_tests/test_admin_password.py b/unit_tests/test_admin_password.py index 3dff3e6b..58aed360 100644 --- a/unit_tests/test_admin_password.py +++ b/unit_tests/test_admin_password.py @@ -35,6 +35,17 @@ class GetAdminPasswordTestCase(CharmTestCase): self.leader_get("admin_passwd")}) +class RotateAdminPasswordTestCase(CharmTestCase): + + def setUp(self): + super(RotateAdminPasswordTestCase, self).setUp( + admin_password, ["rotate_admin_passwd"]) + + def test_rotate_admin_password(self): + admin_password.rotate_admin_password([]) + self.rotate_admin_passwd.assert_called_once() + + class MainTestCase(CharmTestCase): def setUp(self):