if not matching_hosts:
return {'n/a': [{'error': True,
'message': 'No OSDSpec or matching hosts found.'}]}
- # Is any host still loading previews
+ # Is any host still loading previews or still in the queue to be previewed
pending_hosts = {h for h in self.cache.loading_osdspec_preview if h in matching_hosts}
- if pending_hosts:
+ if pending_hosts or any(item in self.cache.osdspec_previews_refresh_queue for item in matching_hosts):
# Report 'pending' when any of the matching hosts is still loading previews (flag is True)
return {'n/a': [{'error': True,
'message': 'Preview data is being generated.. '
raise OrchestratorError(f'unsupported format type: {format}')
-def generate_preview_tables(data):
+def generate_preview_tables(data, osd_only=False):
error = [x.get('error') for x in data if x.get('error')]
if error:
return json.dumps(error)
warning = [x.get('warning') for x in data if x.get('warning')]
osd_table = preview_table_osd(data)
service_table = preview_table_services(data)
- tables = f"""
+
+ if osd_only:
+ tables = f"""
+{''.join(warning)}
+
+################
+OSDSPEC PREVIEWS
+################
+{osd_table}
+"""
+ return tables
+ else:
+ tables = f"""
{''.join(warning)}
####################
################
{osd_table}
"""
- return tables
+ return tables
def preview_table_osd(data):
raise_if_exception(completion)
data = completion.result
if format == 'plain':
- out = preview_table_osd(data)
+ out = generate_preview_tables(data, True)
else:
out = to_format(data, format, many=True, cls=None)
return HandleCommandResult(stdout=out)
self._orchestrator_wait([completion])
data = completion.result
if format == 'plain':
- out = preview_table_osd(data)
+ out = generate_preview_tables(data , True)
else:
out = to_format(data, format, many=True, cls=None)
return HandleCommandResult(stdout=out)