ceph_keys: pass in module for error messages

fixes: #3421

Signed-off-by: Noah Watkins <nwatkins@redhat.com>
(cherry picked from commit 114fac15dc)
pull/3458/head
Noah Watkins 2018-12-06 10:34:49 -08:00 committed by mergify[bot]
parent e7a85d301d
commit e3f2f5e926
2 changed files with 4 additions and 5 deletions

View File

@ -436,7 +436,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
'''
@ -623,7 +623,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)

View File

@ -478,12 +478,11 @@ 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-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-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-osd', 'client.bootstrap-rbd', '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):