Get certificate with mgr name instead of hostname

In bare-metal ceph, mgr's were created with the hostname,
however with rook-ceph they are created with letters.
Therefore, it is not possible to get the certificate
from restful API module because the hostname is passed
instead of the mgr name.

To fix this, the "ceph mgr metadata" command has been
replaced with "ceph mgr dump", which returns the name
of the active mgr.

Test Plan:
- PASS: Build stx-ceph-manager image
- PASS: Change the stx-ceph-manager deployment in
	the rook-ceph app to use this image
- PASS: Build rook-ceph app
- PASS: Apply app on Standard (IPV6)
- PASS: Check the pod's logs to verify that
	the certificate was obtained
- PASS: Using bare-metal ceph, check the logs in
        /var/log/ceph-manager.log for any errors.

Story: 2011066
Task: 50656

Change-Id: I4f57e1d0cc45143c1ea29c826e45bae59e27efdc
Signed-off-by: Erickson Silva de Oliveira <Erickson.SilvadeOliveira@windriver.com>
This commit is contained in:
Erickson Silva de Oliveira 2024-07-24 17:31:11 -03:00
parent 3b5d1182d4
commit 8905b49eaf

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2021 Wind River Systems, Inc.
# Copyright (c) 2019-2021,2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -114,10 +114,10 @@ class CephClient(object):
raise exception.CephMgrMissingRestfulService(
status.get('services', ''))
def _get_service_hostname(self):
def _get_service_active_mgr(self):
try:
output = subprocess.check_output(
'ceph mgr metadata',
'ceph mgr dump',
timeout=CEPH_CLI_TIMEOUT_SEC,
shell=True)
except subprocess.CalledProcessError as e:
@ -125,19 +125,19 @@ class CephClient(object):
except subprocess.TimeoutExpired as e:
raise exception.CephCliTimeoutExpired(str(e))
try:
status = json.loads(output)
dump = json.loads(output)
except (KeyError, ValueError):
raise exception.CephMgrJsonError(output)
return status[0]["hostname"]
return dump["active_name"]
def _get_certificate(self):
self._cleanup_certificate()
hostname = self._get_service_hostname()
active_mgr = self._get_service_active_mgr()
try:
certificate = subprocess.check_output(
('ceph config-key get '
'mgr/restful/{}/crt').format(
hostname),
active_mgr),
timeout=CEPH_CLI_TIMEOUT_SEC,
shell=True)
except (subprocess.CalledProcessError, subprocess.TimeoutExpired):