From e3f2f5e926810f2b2abb76f94b50837b43cc1c87 Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Thu, 6 Dec 2018 10:34:49 -0800 Subject: [PATCH] ceph_keys: pass in module for error messages fixes: #3421 Signed-off-by: Noah Watkins (cherry picked from commit 114fac15dc3200bbf9da183c75d889fd75794654) --- library/ceph_key.py | 4 ++-- library/test_ceph_key.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/library/ceph_key.py b/library/ceph_key.py index 60df45edd..9a77afa46 100644 --- a/library/ceph_key.py +++ b/library/ceph_key.py @@ -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) diff --git a/library/test_ceph_key.py b/library/test_ceph_key.py index 5edf3fab8..afcd2f580 100644 --- a/library/test_ceph_key.py +++ b/library/test_ceph_key.py @@ -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): -- 2.39.5