put create_keyrings as a public method

This method should be call after the quorum has been done. The right
pattern would be:

  ceph.wait_quorum()
  ceph.create_keyrings()

Change-Id: I6c754cb2d1de57a59416e96aa6ab5cfcaec5df44
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
This commit is contained in:
Sahid Orentino Ferdjaoui 2019-10-22 15:30:50 +00:00
parent 727a9dd156
commit 7839ca39bf
2 changed files with 4 additions and 8 deletions

View File

@ -29,7 +29,6 @@ from datetime import datetime
from charmhelpers.core import hookenv
from charmhelpers.core import templating
from charmhelpers.core.decorators import retry_on_exception
from charmhelpers.core.host import (
chownr,
cmp_pkgrevno,
@ -1295,7 +1294,6 @@ def bootstrap_monitor_cluster(secret):
path,
done,
init_marker)
_create_keyrings()
except:
raise
finally:
@ -1343,10 +1341,11 @@ def _create_monitor(keyring, secret, hostname, path, done, init_marker):
service_restart('ceph-mon-all')
@retry_on_exception(3, base_delay=5)
def _create_keyrings():
def create_keyrings():
"""Create keyrings for operation of ceph-mon units
NOTE: The quorum should be done before to execute this function.
:raises: Exception if keyrings cannot be created
"""
if cmp_pkgrevno('ceph', '14.0.0') >= 0:

View File

@ -661,7 +661,6 @@ class CephTestCase(unittest.TestCase):
utils.determine_packages())
@patch.object(utils, '_create_monitor')
@patch.object(utils, '_create_keyrings')
@patch.object(utils, 'ceph_user')
@patch.object(utils, 'os')
@patch.object(utils, 'systemd')
@ -672,7 +671,6 @@ class CephTestCase(unittest.TestCase):
mock_systemd,
mock_os,
mock_ceph_user,
mock_create_keyrings,
mock_create_monitor):
test_hostname = utils.socket.gethostname()
test_secret = 'mysecret'
@ -701,7 +699,6 @@ class CephTestCase(unittest.TestCase):
test_done,
test_init_marker,
)
mock_create_keyrings.assert_called_once_with()
mock_os.unlink.assert_called_with(test_keyring)
@patch.object(utils, 'systemd')
@ -810,7 +807,7 @@ class CephTestCase(unittest.TestCase):
call(['ceph-create-keys', '--id', test_hostname])
)
utils._create_keyrings()
utils.create_keyrings()
mock_check_call.assert_has_calls(test_calls)