Use hostname on restful service certificate
Force the use of hostname on getting the certificates for restful service, instead of the IP address. This is necessary due to the update of the Ceph version in rook-ceph app. New Ceph version started to store the IP number instead of the hostname in restful service infos. We need a new function to return the hostname in order to get the key and certificate files. Story: 2009138 Task: 46735 Test Plan: PASS: AIO-SX - created an image with this version of code and use it to get service certificate Signed-off-by: Daian Cardoso Sganderlla <Daian.CardosoSganderlla@windriver.com> Change-Id: I06ac2b40662ef1df4b86d82d2cdf298d746d886b
This commit is contained in:
parent
3599e8e456
commit
2617f00165
@ -102,16 +102,31 @@ class CephClient(object):
|
|||||||
raise exception.CephMgrMissingRestfulService(
|
raise exception.CephMgrMissingRestfulService(
|
||||||
status.get('services', ''))
|
status.get('services', ''))
|
||||||
|
|
||||||
|
def _get_service_hostname(self):
|
||||||
|
try:
|
||||||
|
output = subprocess.check_output(
|
||||||
|
('ceph mgr metadata '
|
||||||
|
'--connect-timeout {}').format(
|
||||||
|
CEPH_CLI_TIMEOUT_SEC),
|
||||||
|
shell=True)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
raise exception.CephMgrDumpError(str(e))
|
||||||
|
try:
|
||||||
|
status = json.loads(output)
|
||||||
|
except (KeyError, ValueError):
|
||||||
|
raise exception.CephMgrJsonError(output)
|
||||||
|
return status[0]["hostname"]
|
||||||
|
|
||||||
def _get_certificate(self):
|
def _get_certificate(self):
|
||||||
self._cleanup_certificate()
|
self._cleanup_certificate()
|
||||||
url = urlparse(self.service_url)
|
hostname = self._get_service_hostname()
|
||||||
try:
|
try:
|
||||||
certificate = subprocess.check_output(
|
certificate = subprocess.check_output(
|
||||||
('ceph config-key get '
|
('ceph config-key get '
|
||||||
'--connect-timeout {} '
|
'--connect-timeout {} '
|
||||||
'mgr/restful/{}/crt').format(
|
'mgr/restful/{}/crt').format(
|
||||||
CEPH_CLI_TIMEOUT_SEC,
|
CEPH_CLI_TIMEOUT_SEC,
|
||||||
url.hostname),
|
hostname),
|
||||||
shell=True)
|
shell=True)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user