@@ -360,7 +360,7 @@ def cmd(self, command, **kargs):
360360 time .sleep (self .force_wait )
361361
362362 result = self .__expect (matches , timeout )
363- self .output = "%s%s" % (self .child .before , self .child .after )
363+ self .output = "%s%s" % (self .child .before . decode ( "utf-8" ) , self .child .after . decode ( "utf-8" ) )
364364 if result == "eof" or result == "timeout" :
365365 logging .warning ("unexpected %s occurred" % result )
366366 return result
@@ -1958,6 +1958,7 @@ def apic_ssd_check(index, total_checks, cversion, **kwargs):
19581958 recommended_action = "Contact TAC for replacement"
19591959 print_title (title , index , total_checks )
19601960
1961+ has_error = False
19611962 dn_regex = node_regex + r'/.+p-\[(?P<storage>.+)\]-f'
19621963 faultInsts = icurl ('class' , 'faultInst.json?query-target-filter=eq(faultInst.code,"F2731")' )
19631964 adjust_title = False
@@ -1988,13 +1989,15 @@ def apic_ssd_check(index, total_checks, cversion, **kwargs):
19881989 except Exception as e :
19891990 data .append ([attr ['id' ], attr ['name' ], '-' , '-' , '-' , e ])
19901991 print_result (node_title , ERROR )
1992+ has_error = True
19911993 continue
19921994 try :
19931995 c .cmd (
19941996 'grep -oE "SSD Wearout Indicator is [0-9]+" /var/log/dme/log/svc_ifc_ae.bin.log | tail -1' )
19951997 except Exception as e :
19961998 data .append ([attr ['id' ], attr ['name' ], '-' , '-' , '-' , e ])
19971999 print_result (node_title , ERROR )
2000+ has_error = True
19982001 continue
19992002
20002003 wearout_ind = re .search (r'SSD Wearout Indicator is (?P<wearout>[0-9]+)' , c .output )
@@ -2023,7 +2026,9 @@ def apic_ssd_check(index, total_checks, cversion, **kwargs):
20232026 else :
20242027 unformatted_data .append (
20252028 ['F2731' , faultInst ['faultInst' ]['attributes' ]['dn' ], lifetime_remaining , recommended_action ])
2026- if not data and not unformatted_data :
2029+ if has_error :
2030+ result = ERROR
2031+ elif not data and not unformatted_data :
20272032 result = PASS
20282033 print_result (title , result , msg , headers , data , unformatted_headers , unformatted_data , adjust_title = adjust_title )
20292034 return result
@@ -2591,7 +2596,6 @@ def lldp_with_infra_vlan_mismatch_check(index, total_checks, **kwargs):
25912596
25922597
25932598def apic_version_md5_check (index , total_checks , tversion , username , password , ** kwargs ):
2594- # TODO: 'unexpected output when checking md5sum file' may be cuasing stdout print issue
25952599 title = 'APIC Target version image and MD5 hash'
25962600 result = FAIL_UF
25972601 msg = ''
@@ -2621,6 +2625,7 @@ def apic_version_md5_check(index, total_checks, tversion, username, password, **
26212625 md5s = []
26222626 md5_names = []
26232627
2628+ has_error = False
26242629 prints ('' )
26252630 nodes_response_json = icurl ('class' , 'topSystem.json' )
26262631 for node in nodes_response_json :
@@ -2638,6 +2643,7 @@ def apic_version_md5_check(index, total_checks, tversion, username, password, **
26382643 except Exception as e :
26392644 data .append ([apic_name , '-' , '-' , e , '-' ])
26402645 print_result (node_title , ERROR )
2646+ has_error = True
26412647 continue
26422648
26432649 try :
@@ -2647,6 +2653,7 @@ def apic_version_md5_check(index, total_checks, tversion, username, password, **
26472653 data .append ([apic_name , '-' , '-' ,
26482654 'ls command via ssh failed due to:{}' .format (e ), '-' ])
26492655 print_result (node_title , ERROR )
2656+ has_error = True
26502657 continue
26512658 if "No such file or directory" in c .output :
26522659 data .append ([apic_name , str (tversion ), '-' , 'image not found' , recommended_action ])
@@ -2660,6 +2667,7 @@ def apic_version_md5_check(index, total_checks, tversion, username, password, **
26602667 data .append ([apic_name , str (tversion ), '-' ,
26612668 'failed to check md5sum via ssh due to:{}' .format (e ), '-' ])
26622669 print_result (node_title , ERROR )
2670+ has_error = True
26632671 continue
26642672 if "No such file or directory" in c .output :
26652673 data .append ([apic_name , str (tversion ), '-' , 'md5sum file not found' , recommended_action ])
@@ -2677,13 +2685,16 @@ def apic_version_md5_check(index, total_checks, tversion, username, password, **
26772685 else :
26782686 data .append ([apic_name , str (tversion ), '-' , 'unexpected output when checking md5sum file' , recommended_action ])
26792687 print_result (node_title , ERROR )
2688+ has_error = True
26802689 continue
26812690
26822691 print_result (node_title , DONE )
26832692 if len (set (md5s )) > 1 :
26842693 for name , md5 in zip (md5_names , md5s ):
26852694 data .append ([name , str (tversion ), md5 , 'md5sum do not match on all APICs' , recommended_action ])
2686- if not data :
2695+ if has_error :
2696+ result = ERROR
2697+ elif not data :
26872698 result = PASS
26882699 print_result (title , result , msg , headers , data , adjust_title = True )
26892700 return result
@@ -2699,6 +2710,7 @@ def standby_apic_disk_space_check(index, total_checks, **kwargs):
26992710 threshold = 75 # usage (%)
27002711 print_title (title , index , total_checks )
27012712
2713+ has_error = False
27022714 checked_stby = []
27032715 infraSnNodes = icurl ('class' , 'infraSnNode.json?query-target-filter=eq(infraSnNode.cntrlSbstState,"approved")' )
27042716 for stby_apic in infraSnNodes :
@@ -2713,12 +2725,14 @@ def standby_apic_disk_space_check(index, total_checks, **kwargs):
27132725 c .connect ()
27142726 except Exception as e :
27152727 data .append ([stb ['mbSn' ], stb ['oobIpAddr' ], '-' , '-' , e ])
2728+ has_error = True
27162729 continue
27172730
27182731 try :
27192732 c .cmd ("df -h" )
27202733 except Exception as e :
27212734 data .append ([stb ['mbSn' ], stb ['oobIpAddr' ], '-' , '-' , e ])
2735+ has_error = True
27222736 continue
27232737
27242738 for line in c .output .split ("\n " ):
@@ -2733,6 +2747,8 @@ def standby_apic_disk_space_check(index, total_checks, **kwargs):
27332747 if not infraSnNodes :
27342748 result = NA
27352749 msg = 'No standby APIC found'
2750+ elif has_error :
2751+ result = ERROR
27362752 elif not data :
27372753 result = PASS
27382754 msg = 'all below {}%' .format (threshold )
@@ -4999,6 +5015,7 @@ def observer_db_size_check(index, total_checks, username, password, **kwargs):
49995015 if not controllers :
50005016 print_result (title , ERROR , 'topSystem response empty. Is the cluster healthy?' )
50015017 return ERROR
5018+ has_error = False
50025019 prints ('' )
50035020 for apic in controllers :
50045021 attr = apic ['topSystem' ]['attributes' ]
@@ -5013,13 +5030,15 @@ def observer_db_size_check(index, total_checks, username, password, **kwargs):
50135030 except Exception as e :
50145031 data .append ([attr ['id' ], attr ['name' ], e ])
50155032 print_result (node_title , ERROR )
5033+ has_error = True
50165034 continue
50175035 try :
50185036 cmd = r"ls -lh /data2/dbstats | awk '{print $5, $9}'"
50195037 c .cmd (cmd )
50205038 if "No such file or directory" in c .output :
50215039 data .append ([attr ['id' ], '/data2/dbstats/ not found' , "Check user permissions or retry as 'apic#fallback\\ \\ admin'" ])
5022- print_result (node_title , FAIL_UF )
5040+ print_result (node_title , ERROR )
5041+ has_error = True
50235042 continue
50245043 dbstats = c .output .split ("\n " )
50255044 for line in dbstats :
@@ -5033,8 +5052,11 @@ def observer_db_size_check(index, total_checks, username, password, **kwargs):
50335052 except Exception as e :
50345053 data .append ([attr ['id' ], attr ['name' ], e ])
50355054 print_result (node_title , ERROR )
5055+ has_error = True
50365056 continue
5037- if data :
5057+ if has_error :
5058+ result = ERROR
5059+ elif data :
50385060 result = FAIL_UF
50395061 print_result (title , result , msg , headers , data , recommended_action = recommended_action , doc_url = doc_url , adjust_title = True )
50405062 return result
0 commit comments