#NEWLINE# @ classmethod #NEWLINE# def update_status( cls , server ) : #NEWLINE# #INDENT# 'Check ip address is pingable and update status.' #NEWLINE# ping = ( 'ping' if ( server . ip . version == 4 ) else 'ping6' ) #NEWLINE# if sys . platform . startswith ( 'linux' ) : #NEWLINE# #INDENT# cmd = [ ping , '-c1' , '-w1' , server . ip . format ( ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cmd = [ ping , '-c1' , server . ip . format ( ) ] #NEWLINE# #UNINDENT# proc = subprocess . Popen ( cmd , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# proc . wait ( ) #NEWLINE# LOG . debug ( ( 'Host %s is ICMP %s' % ( server . ip . format ( ) , ( ( proc . returncode and 'down' ) or 'up' ) ) ) ) #NEWLINE# if ( proc . returncode == 0 ) : #NEWLINE# #INDENT# server . status = cls . ICMP_UP_STATUS #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# server . status = cls . ICMP_DOWN_STATUS #NEWLINE# #UNINDENT# return server