From: Sage Weil Date: Tue, 14 Mar 2017 02:07:01 +0000 (-0400) Subject: gatherkeys: gather bootstrap-mgr key too X-Git-Tag: v1.5.38~5^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fd671b435f5960843cc53140ef0971b1e826ed98;p=ceph-deploy.git gatherkeys: gather bootstrap-mgr key too Signed-off-by: Sage Weil --- diff --git a/ceph_deploy/gatherkeys.py b/ceph_deploy/gatherkeys.py index 046e92b..ebd4158 100644 --- a/ceph_deploy/gatherkeys.py +++ b/ceph_deploy/gatherkeys.py @@ -62,6 +62,7 @@ def keytype_identity(keytype): ident_dict = { 'admin' : 'client.admin', 'mds' : 'client.bootstrap-mds', + 'mgr' : 'client.bootstrap-mgr', 'osd' : 'client.bootstrap-osd', 'rgw' : 'client.bootstrap-rgw', 'mon' : 'mon.' @@ -83,6 +84,9 @@ def keytype_capabilities(keytype): 'mds' : [ 'mon', 'allow profile bootstrap-mds' ], + 'mgr' : [ + 'mon', 'allow profile bootstrap-mgr' + ], 'osd' : [ 'mon', 'allow profile bootstrap-osd' ], @@ -208,7 +212,7 @@ def gatherkeys_with_mon(args, host, dest_dir): if not mon_number in mon_quorum: rlogger.error("Not yet quorum for '%s'", host) return False - for keytype in ["admin", "mds", "osd", "rgw"]: + for keytype in ["admin", "mds", "mgr", "osd", "rgw"]: if not gatherkeys_missing(args, distro, rlogger, path_keytype_mon, keytype, dest_dir): # We will return failure if we fail to gather any key rlogger.error("Failed to return '%s' key from host %s", keytype, host) @@ -237,7 +241,7 @@ def gatherkeys(args): raise RuntimeError('Failed to connect any mon') had_error = False date_string = time.strftime("%Y%m%d%H%M%S") - for keytype in ["admin", "mds", "mon", "osd", "rgw"]: + for keytype in ["admin", "mds", "mgr", "mon", "osd", "rgw"]: filename = keytype_path_to(args, keytype) tmp_path = os.path.join(tmpd, filename) if not os.path.exists(tmp_path): diff --git a/ceph_deploy/tests/test_gather_keys.py b/ceph_deploy/tests/test_gather_keys.py index 917889b..37f5b1c 100644 --- a/ceph_deploy/tests/test_gather_keys.py +++ b/ceph_deploy/tests/test_gather_keys.py @@ -28,7 +28,7 @@ def mock_get_keys_fail(args, host, dest_dir): def mock_get_keys_sucess_static(args, host, dest_dir): - for keytype in ["admin", "mon", "osd", "mds", "rgw"]: + for keytype in ["admin", "mon", "osd", "mds", "mgr", "rgw"]: keypath = gatherkeys.keytype_path_to(args, keytype) path = "%s/%s" % (dest_dir, keypath) get_key_static(keytype, path) @@ -36,7 +36,7 @@ def mock_get_keys_sucess_static(args, host, dest_dir): def mock_get_keys_sucess_dynamic(args, host, dest_dir): - for keytype in ["admin", "mon", "osd", "mds", "rgw"]: + for keytype in ["admin", "mon", "osd", "mds", "mgr", "rgw"]: keypath = gatherkeys.keytype_path_to(args, keytype) path = "%s/%s" % (dest_dir, keypath) get_key_dynamic(keytype, path) @@ -91,21 +91,22 @@ class TestGatherKeys(object): dir_content = os.listdir(self.test_dir) assert "ceph.client.admin.keyring" in dir_content assert "ceph.bootstrap-mds.keyring" in dir_content + assert "ceph.bootstrap-mgr.keyring" in dir_content assert "ceph.mon.keyring" in dir_content assert "ceph.bootstrap-osd.keyring" in dir_content assert "ceph.bootstrap-rgw.keyring" in dir_content - assert len(dir_content) == 5 + assert len(dir_content) == 6 # Now we repeat as no new keys are generated gatherkeys.gatherkeys(args) dir_content = os.listdir(self.test_dir) - assert len(dir_content) == 5 + assert len(dir_content) == 6 @mock.patch('ceph_deploy.gatherkeys.time.strftime', mock_time_strftime) @mock.patch('ceph_deploy.gatherkeys.gatherkeys_with_mon', mock_get_keys_sucess_dynamic) def test_gatherkeys_backs_up(self): """ - Test 'gatherkeys' succeeds when getinig keys that are always different. + Test 'gatherkeys' succeeds when getting keys that are always different. Test 'gatherkeys' does backup keys that are not identical. """ args = mock.Mock() @@ -115,10 +116,11 @@ class TestGatherKeys(object): dir_content = os.listdir(self.test_dir) assert "ceph.client.admin.keyring" in dir_content assert "ceph.bootstrap-mds.keyring" in dir_content + assert "ceph.bootstrap-mgr.keyring" in dir_content assert "ceph.mon.keyring" in dir_content assert "ceph.bootstrap-osd.keyring" in dir_content assert "ceph.bootstrap-rgw.keyring" in dir_content - assert len(dir_content) == 5 + assert len(dir_content) == 6 # Now we repeat as new keys are generated and old # are backed up gatherkeys.gatherkeys(args) @@ -126,12 +128,14 @@ class TestGatherKeys(object): mocked_time = mock_time_strftime(None) assert "ceph.client.admin.keyring" in dir_content assert "ceph.bootstrap-mds.keyring" in dir_content + assert "ceph.bootstrap-mgr.keyring" in dir_content assert "ceph.mon.keyring" in dir_content assert "ceph.bootstrap-osd.keyring" in dir_content assert "ceph.bootstrap-rgw.keyring" in dir_content assert "ceph.client.admin.keyring-%s" % (mocked_time) in dir_content assert "ceph.bootstrap-mds.keyring-%s" % (mocked_time) in dir_content + assert "ceph.bootstrap-mgr.keyring-%s" % (mocked_time) in dir_content assert "ceph.mon.keyring-%s" % (mocked_time) in dir_content assert "ceph.bootstrap-osd.keyring-%s" % (mocked_time) in dir_content assert "ceph.bootstrap-rgw.keyring-%s" % (mocked_time) in dir_content - assert len(dir_content) == 10 + assert len(dir_content) == 12 diff --git a/ceph_deploy/tests/test_gather_keys_missing.py b/ceph_deploy/tests/test_gather_keys_missing.py index 523d187..0369aa8 100644 --- a/ceph_deploy/tests/test_gather_keys_missing.py +++ b/ceph_deploy/tests/test_gather_keys_missing.py @@ -87,6 +87,22 @@ class TestGatherKeysMissing(object): keypath_gen = os.path.join(self.test_dir, keyname) assert os.path.isfile(keypath_gen) + @mock.patch('ceph_deploy.lib.remoto.process.check', mock_remoto_process_check_success) + def test_success_mgr(self): + keytype = 'mgr' + rc = gatherkeys.gatherkeys_missing( + self.args, + self.distro, + self.rlogger, + self.keypath_remote, + keytype, + self.test_dir + ) + assert rc is True + keyname = gatherkeys.keytype_path_to(self.args, keytype) + keypath_gen = os.path.join(self.test_dir, keyname) + assert os.path.isfile(keypath_gen) + @mock.patch('ceph_deploy.lib.remoto.process.check', mock_remoto_process_check_success) def test_success_osd(self): keytype = 'osd'