pybind/mgr/cephadm/serve: add assert to appease mypy

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2021-01-20 01:26:06 +08:00
parent 2fd0a03192
commit 2a5a50f3ba

View File

@ -401,13 +401,17 @@ class CephadmServe:
daemon_detail = [] # type: List[str]
for item in ls:
host = item.get('hostname')
assert isinstance(host, str)
daemons = item.get('services') # misnomer!
assert isinstance(daemons, list)
missing_names = []
for s in daemons:
name = '%s.%s' % (s.get('type'), s.get('id'))
daemon_id = s.get('id')
assert daemon_id
name = '%s.%s' % (s.get('type'), daemon_id)
if s.get('type') == 'rbd-mirror':
metadata = self.mgr.get_metadata(
"rbd-mirror", s.get('id'))
"rbd-mirror", daemon_id)
try:
name = '%s.%s' % (s.get('type'), metadata['id'])
except (KeyError, TypeError):