Change: compact analyze output, minor refactor
Change-Id: If29463ac4d349dffa0dd6817fdace2795ffc6f9a
This commit is contained in:
parent
c3c0182c72
commit
9169d0cd13
@ -4,7 +4,7 @@
|
|||||||
%global pypi_name timmy
|
%global pypi_name timmy
|
||||||
|
|
||||||
Name: python-%{pypi_name}
|
Name: python-%{pypi_name}
|
||||||
Version: 1.25.3
|
Version: 1.25.4
|
||||||
Release: 1%{?dist}~mos0
|
Release: 1%{?dist}~mos0
|
||||||
Summary: Log collector tool for OpenStack Fuel
|
Summary: Log collector tool for OpenStack Fuel
|
||||||
|
|
||||||
@ -107,6 +107,9 @@ popd
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Dec 12 2016 Dmitry Sutyagin <dsutyagin@mirantis.com> - 1.25.4
|
||||||
|
- Change: compact analyze output, minor refactor
|
||||||
|
|
||||||
* Mon Dec 12 2016 Dmitry Sutyagin <dsutyagin@mirantis.com> - 1.25.3
|
* Mon Dec 12 2016 Dmitry Sutyagin <dsutyagin@mirantis.com> - 1.25.3
|
||||||
- Add: dynamic import of analyze modules
|
- Add: dynamic import of analyze modules
|
||||||
|
|
||||||
|
@ -48,50 +48,47 @@ def analyze(node_manager):
|
|||||||
for script, param in node.mapscr.items():
|
for script, param in node.mapscr.items():
|
||||||
if script in fn_mapping:
|
if script in fn_mapping:
|
||||||
if not os.path.exists(param['output_path']):
|
if not os.path.exists(param['output_path']):
|
||||||
logger.warning("File %s does not exist"
|
logger.warning('File %s does not exist'
|
||||||
% param['output_path'])
|
% param['output_path'])
|
||||||
continue
|
continue
|
||||||
with open(param['output_path'], "r") as f:
|
with open(param['output_path'], 'r') as f:
|
||||||
data = [l.rstrip() for l in f.readlines()]
|
data = [l.rstrip() for l in f.readlines()]
|
||||||
health, details = fn_mapping[script](data, script, node)
|
health, details = fn_mapping[script](data, script, node)
|
||||||
if node.repr not in results:
|
if node.repr not in results:
|
||||||
results[node.repr] = []
|
results[node.repr] = []
|
||||||
results[node.repr].append({"script": script,
|
results[node.repr].append({'script': script,
|
||||||
"output_file": param['output_path'],
|
'output_file': param['output_path'],
|
||||||
"health": health,
|
'health': health,
|
||||||
"details": details})
|
'details': details})
|
||||||
node_manager.analyze_results = results
|
node_manager.analyze_results = results
|
||||||
|
|
||||||
|
|
||||||
def analyze_print_results(node_manager):
|
def analyze_print_results(node_manager):
|
||||||
code_colors = {GREEN: ["GREEN", "\033[92m"],
|
code_colors = {GREEN: ['GREEN', '\033[92m'],
|
||||||
UNKNOWN: ["UNKNOWN", "\033[94m"],
|
UNKNOWN: ['UNKNOWN', '\033[94m'],
|
||||||
YELLOW: ["YELLOW", "\033[93m"],
|
YELLOW: ['YELLOW', '\033[93m'],
|
||||||
RED: ["RED", "\033[91m"]}
|
RED: ['RED', '\033[91m']}
|
||||||
color_end = "\033[0m"
|
color_end = '\033[0m'
|
||||||
print("Nodes health analysis:")
|
print('Nodes health analysis:')
|
||||||
for node, result in node_manager.analyze_results.items():
|
for node, result in node_manager.analyze_results.items():
|
||||||
node_health = max([x["health"] for x in result])
|
node_health = max([x['health'] for x in result])
|
||||||
node_color = code_colors[node_health][1]
|
node_color = code_colors[node_health][1]
|
||||||
health_repr = code_colors[node_health][0]
|
health_repr = code_colors[node_health][0]
|
||||||
print(" %s%s: %s%s" % (node_color, node, health_repr, color_end))
|
print(' %s%s: %s%s' % (node_color, node, health_repr, color_end))
|
||||||
if node_health == 0:
|
if node_health == 0:
|
||||||
continue
|
continue
|
||||||
for r in result:
|
for r in result:
|
||||||
if r['health'] == 0:
|
if r['health'] == 0:
|
||||||
continue
|
continue
|
||||||
color = code_colors[r["health"]][1]
|
color = code_colors[r['health']][1]
|
||||||
sys.stdout.write(color)
|
sys.stdout.write(color)
|
||||||
for key, value in r.items():
|
health_repr = code_colors[r['health']][0]
|
||||||
if key == "health":
|
print(' %s: %s' % (r['script'], health_repr))
|
||||||
value = code_colors[value][0]
|
print(' %s: %s' % ('output_file', r['output_file']))
|
||||||
if key == "details" and len(value) > 0:
|
if len(r['details']) > 1:
|
||||||
if len(value) > 1:
|
print(' details:')
|
||||||
print(" details:")
|
for d in r['details']:
|
||||||
for d in value:
|
print(' - %s' % d)
|
||||||
print(" - %s" % d)
|
|
||||||
else:
|
else:
|
||||||
print(" details: %s" % value[0])
|
print(' details: %s' % r['details'][0])
|
||||||
elif key != "details":
|
|
||||||
print(" %s: %s" % (key, value))
|
|
||||||
sys.stdout.write(color_end)
|
sys.stdout.write(color_end)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
project_name = 'timmy'
|
project_name = 'timmy'
|
||||||
version = '1.25.3'
|
version = '1.25.4'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
|
Loading…
Reference in New Issue
Block a user