module KubeAutoAnalyzer
def self.json_report
require 'json'
@log.debug("Starting Report")
@json_report_file.puts JSON.generate(@results)
end
def self.html_report
logo_path = File.join(__dir__, "data-logo.b64")
logo = File.open(logo_path).read
@log.debug("Starting HTML Report")
@html_report_file << '
Master Node Results
'
#Charting setup counts for the passes and fails
api_server_pass = 0
api_server_fail = 0
@results[@options.target_server]['api_server'].each do |test, result|
if result == "Pass"
api_server_pass = api_server_pass + 1
elsif result == "Fail"
api_server_fail = api_server_fail + 1
end
end
#Not a lot of point in scheduler when there's only one check...
#scheduler_pass = 0
#scheduler_fail = 0
#@results[@options.target_server]['scheduler'].each do |test, result|
# if result == "Pass"
# scheduler_pass = scheduler_pass + 1
# elsif result == "Fail"
# scheduler_fail = scheduler_fail + 1
# end
#end
controller_manager_pass = 0
controller_manager_fail = 0
@results[@options.target_server]['controller_manager'].each do |test, result|
if result == "Pass"
controller_manager_pass = controller_manager_pass + 1
elsif result == "Fail"
controller_manager_fail = controller_manager_fail + 1
end
end
etcd_pass = 0
etcd_fail = 0
@results[@options.target_server]['etcd'].each do |test, result|
if result == "Pass"
etcd_pass = etcd_pass + 1
elsif result == "Fail"
etcd_fail = etcd_fail + 1
end
end
#Start of Chart Divs
@html_report_file.puts '
'
#API Server Chart
@html_report_file.puts '
'
@html_report_file.puts ''
#Scheduler Chart
#@html_report_file.puts '
'
#@html_report_file.puts ''
#Controller Manager Chart
@html_report_file.puts '
'
@html_report_file.puts ''
#etcd Chart
@html_report_file.puts '
'
@html_report_file.puts ''
#End of Chart Divs
@html_report_file.puts '
'
@html_report_file.puts "
API Server
"
@html_report_file.puts "
Check | result |
"
@results[@options.target_server]['api_server'].each do |test, result|
if result == "Fail"
result = 'Fail'
elsif result == "Pass"
result = 'Pass'
end
@html_report_file.puts "#{test} | #{result} |
"
end
@html_report_file.puts "
"
@html_report_file.puts "
"
@html_report_file.puts "
Scheduler
"
@html_report_file.puts "
Check | result |
"
@results[@options.target_server]['scheduler'].each do |test, result|
if result == "Fail"
result = 'Fail'
elsif result == "Pass"
result = 'Pass'
end
@html_report_file.puts "#{test} | #{result} |
"
end
@html_report_file.puts "
"
@html_report_file.puts "
"
@html_report_file.puts "
Controller Manager
"
@html_report_file.puts "
Check | result |
"
@results[@options.target_server]['controller_manager'].each do |test, result|
if result == "Fail"
result = 'Fail'
elsif result == "Pass"
result = 'Pass'
end
@html_report_file.puts "#{test} | #{result} |
"
end
@html_report_file.puts "
"
@html_report_file.puts "
"
@html_report_file.puts "
etcd
"
@html_report_file.puts "
Check | result |
"
@results[@options.target_server]['etcd'].each do |test, result|
if result == "Fail"
result = 'Fail'
elsif result == "Pass"
result = 'Pass'
end
@html_report_file.puts "#{test} | #{result} |
"
end
@html_report_file.puts "
"
#Close the master Node Div
@html_report_file.puts "
"
end
if @options.agent_checks
@html_report_file.puts 'Worker Node Results
'
#Start of Chart Divs
@html_report_file.puts '
'
@results[@options.target_server]['kubelet_checks'].each do |node, results|
node_kubelet_pass = 0
node_kubelet_fail = 0
results.each do |test, result|
if result == "Fail"
node_kubelet_fail = node_kubelet_fail + 1
elsif result == "Pass"
node_kubelet_pass = node_kubelet_pass + 1
end
end
#Create the Chart
@html_report_file.puts '
'
@html_report_file.puts ''
end
#End of Chart Divs
@html_report_file.puts '
'
@results[@options.target_server]['kubelet_checks'].each do |node, results|
@html_report_file.puts "
#{node} Kubelet Checks"
@html_report_file.puts "
Check | result |
"
results.each do |test, result|
if result == "Fail"
result = 'Fail'
elsif result == "Pass"
result = 'Pass'
end
@html_report_file.puts "#{test} | #{result} |
"
end
@html_report_file.puts "
"
end
@html_report_file.puts "
Evidence
"
@html_report_file.puts "
Host | Area | Output |
"
@results[@options.target_server]['node_evidence'].each do |node, evidence|
evidence.each do |area, data|
@html_report_file.puts "#{node} | #{area} | #{data} |
"
end
end
@html_report_file.puts "
"
end
#Close the Worker Node Div
@html_report_file.puts '
'
if @options.agent_checks
@html_report_file.puts '