]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
gatherkeys: gather bootstrap-mgr key too
authorSage Weil <sage@redhat.com>
Tue, 14 Mar 2017 02:07:01 +0000 (22:07 -0400)
committerSage Weil <sage@redhat.com>
Fri, 17 Mar 2017 15:33:03 +0000 (11:33 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
ceph_deploy/gatherkeys.py
ceph_deploy/tests/test_gather_keys.py
ceph_deploy/tests/test_gather_keys_missing.py

index 046e92b8c026a7acee1969de10780ec3dd0d27d7..ebd415890b88bee680523e93be096ab2570050e6 100644 (file)
@@ -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):
index 917889bb67b5b31a01054bff42e5a4af99f1a13a..37f5b1c10af63c675771a28a65abc1bf08a9a9f9 100644 (file)
@@ -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
index 523d187fed317c89427cd530799617a5a750376b..0369aa8431a30aecd1c74d86d2d828effb0574ee 100644 (file)
@@ -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'