mirror of https://github.com/ceph/ceph-ansible.git
ceph_keys: pass in module for error messages
fixes: #3421 Signed-off-by: Noah Watkins <nwatkins@redhat.com>pull/3433/head
parent
5a12121cf7
commit
114fac15dc
|
@ -459,7 +459,7 @@ def exec_commands(module, cmd_list):
|
|||
return rc, cmd, out, err
|
||||
|
||||
|
||||
def lookup_ceph_initial_entities(out):
|
||||
def lookup_ceph_initial_entities(module, out):
|
||||
'''
|
||||
Lookup Ceph initial keys entries in the auth map
|
||||
'''
|
||||
|
@ -649,7 +649,7 @@ def run_module():
|
|||
result['rc'] = 0
|
||||
module.exit_json(**result)
|
||||
|
||||
entities = lookup_ceph_initial_entities(out)
|
||||
entities = lookup_ceph_initial_entities(module, out)
|
||||
if entities is None:
|
||||
fatal("Failed to find some of the initial entities", module)
|
||||
|
||||
|
|
|
@ -536,13 +536,12 @@ class TestCephKeyModule(object):
|
|||
assert result == expected_command_list
|
||||
|
||||
def test_lookup_ceph_initial_entities(self):
|
||||
|
||||
# fake_module = MagicMock()
|
||||
fake_module = "fake"
|
||||
fake_ceph_dict = { "auth_dump":[ { "entity":"osd.0", "key":"AQAJkMhbszeBBBAA4/V1tDFXGlft1GnHJS5wWg==", "caps":{ "mgr":"allow profile osd", "mon":"allow profile osd", "osd":"allow *" } }, { "entity":"osd.1", "key":"AQAjkMhbshueAhAAjZec50aBgd1NObLz57SQvg==", "caps":{ "mgr":"allow profile osd", "mon":"allow profile osd", "osd":"allow *" } }, { "entity":"client.admin", "key":"AQDZjshbrJv6EhAAY9v6LzLYNDpPdlC3HD5KHA==", "auid":0, "caps":{ "mds":"allow", "mgr":"allow *", "mon":"allow *", "osd":"allow *" } }, { "entity":"client.bootstrap-mds", "key":"AQDojshbc4QCHhAA1ZTrkt9dbSZRVU2GzI6U4A==", "caps":{ "mon":"allow profile bootstrap-mds" } }, { "entity":"client.bootstrap-mgr", "key":"AQBfiu5bAAAAABAARcNG24hUMlk4AdstVA5MVQ==", "caps":{ "mon":"allow profile bootstrap-mgr" } }, { "entity":"client.bootstrap-osd", "key":"AQDjjshbYW+uGxAAyHcPCXXmVoL8VsTBI8z1Ng==", "caps":{ "mon":"allow profile bootstrap-osd" } }, { "entity":"client.bootstrap-rbd", "key":"AQDyjshb522eIhAAtAz6nUPMOdG4H9u0NgpXhA==", "caps":{ "mon":"allow profile bootstrap-rbd" } }, { "entity":"client.bootstrap-rbd-mirror", "key":"AQDfh+5bAAAAABAAEGBD59Lj2vAKIdN8pq4lbQ==", "caps":{ "mon":"allow profile bootstrap-rbd-mirror" } }, { "entity":"client.bootstrap-rgw", "key":"AQDtjshbDl8oIBAAq1SfSYQKDR49hJNWJVwDQw==", "caps":{ "mon":"allow profile bootstrap-rgw" } }, { "entity":"mgr.mon0", "key":"AQA0j8hbgGapORAAoDkyAvXVkM5ej4wNn4cwTQ==", "caps":{ "mds":"allow *", "mon":"allow profile mgr", "osd":"allow *" } } ] } # noqa E501
|
||||
fake_ceph_dict_str = json.dumps(fake_ceph_dict) # convert to string
|
||||
expected_entity_list = ['client.admin', 'client.bootstrap-mds', 'client.bootstrap-mgr', # noqa E501
|
||||
'client.bootstrap-osd', 'client.bootstrap-rbd', 'client.bootstrap-rbd-mirror', 'client.bootstrap-rgw'] # noqa E501
|
||||
result = ceph_key.lookup_ceph_initial_entities(fake_ceph_dict_str)
|
||||
result = ceph_key.lookup_ceph_initial_entities(fake_module, fake_ceph_dict_str)
|
||||
assert result == expected_entity_list
|
||||
|
||||
def test_build_key_path_admin(self):
|
||||
|
|
Loading…
Reference in New Issue