Merge "Ceph-manager: Change timeout usage for ceph commands"
This commit is contained in:
commit
509afb27d4
@ -69,12 +69,13 @@ class CephClient(object):
|
|||||||
def _get_password(self):
|
def _get_password(self):
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(
|
output = subprocess.check_output(
|
||||||
('ceph restful list-keys '
|
'ceph restful list-keys',
|
||||||
'--connect-timeout {}').format(
|
timeout=CEPH_CLI_TIMEOUT_SEC,
|
||||||
CEPH_CLI_TIMEOUT_SEC),
|
|
||||||
shell=True)
|
shell=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
raise exception.CephMonRestfulListKeysError(str(e))
|
raise exception.CephMonRestfulListKeysError(str(e))
|
||||||
|
except subprocess.TimeoutExpired as e:
|
||||||
|
raise exception.CephCliTimeoutExpired(str(e))
|
||||||
try:
|
try:
|
||||||
keys = json.loads(output)
|
keys = json.loads(output)
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
@ -89,12 +90,13 @@ class CephClient(object):
|
|||||||
while attempts <= CEPH_GET_SERVICE_RETRY_COUNT:
|
while attempts <= CEPH_GET_SERVICE_RETRY_COUNT:
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(
|
output = subprocess.check_output(
|
||||||
('ceph mgr services '
|
'ceph mgr services',
|
||||||
'--connect-timeout {}').format(
|
timeout=CEPH_CLI_TIMEOUT_SEC,
|
||||||
CEPH_CLI_TIMEOUT_SEC),
|
|
||||||
shell=True)
|
shell=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
raise exception.CephMgrDumpError(str(e))
|
raise exception.CephMgrDumpError(str(e))
|
||||||
|
except subprocess.TimeoutExpired as e:
|
||||||
|
raise exception.CephCliTimeoutExpired(str(e))
|
||||||
try:
|
try:
|
||||||
status = json.loads(output)
|
status = json.loads(output)
|
||||||
if not status:
|
if not status:
|
||||||
@ -115,12 +117,13 @@ class CephClient(object):
|
|||||||
def _get_service_hostname(self):
|
def _get_service_hostname(self):
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(
|
output = subprocess.check_output(
|
||||||
('ceph mgr metadata '
|
'ceph mgr metadata',
|
||||||
'--connect-timeout {}').format(
|
timeout=CEPH_CLI_TIMEOUT_SEC,
|
||||||
CEPH_CLI_TIMEOUT_SEC),
|
|
||||||
shell=True)
|
shell=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
raise exception.CephMgrDumpError(str(e))
|
raise exception.CephMgrDumpError(str(e))
|
||||||
|
except subprocess.TimeoutExpired as e:
|
||||||
|
raise exception.CephCliTimeoutExpired(str(e))
|
||||||
try:
|
try:
|
||||||
status = json.loads(output)
|
status = json.loads(output)
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
@ -133,12 +136,11 @@ class CephClient(object):
|
|||||||
try:
|
try:
|
||||||
certificate = subprocess.check_output(
|
certificate = subprocess.check_output(
|
||||||
('ceph config-key get '
|
('ceph config-key get '
|
||||||
'--connect-timeout {} '
|
|
||||||
'mgr/restful/{}/crt').format(
|
'mgr/restful/{}/crt').format(
|
||||||
CEPH_CLI_TIMEOUT_SEC,
|
|
||||||
hostname),
|
hostname),
|
||||||
|
timeout=CEPH_CLI_TIMEOUT_SEC,
|
||||||
shell=True)
|
shell=True)
|
||||||
except subprocess.CalledProcessError:
|
except (subprocess.CalledProcessError, subprocess.TimeoutExpired):
|
||||||
return
|
return
|
||||||
with tempfile.NamedTemporaryFile(delete=False) as self.cert_file:
|
with tempfile.NamedTemporaryFile(delete=False) as self.cert_file:
|
||||||
self.cert_file.write(certificate)
|
self.cert_file.write(certificate)
|
||||||
|
@ -99,3 +99,6 @@ class CephClientNoSuchUser(CephClientException):
|
|||||||
|
|
||||||
class CephClientIncorrectPassword(CephClientException):
|
class CephClientIncorrectPassword(CephClientException):
|
||||||
message = ("Incorrect password for user '{user}'.")
|
message = ("Incorrect password for user '{user}'.")
|
||||||
|
|
||||||
|
class CephCliTimeoutExpired(CephClientException):
|
||||||
|
message = "Timeout was reached while executing the command. {}"
|
||||||
|
Loading…
Reference in New Issue
Block a user