#NEWLINE# def check_server_console( nova_client , server_id , len_limit = 100 ) : #NEWLINE# #INDENT# console = nova_client . servers . get ( server_id ) . get_console_output ( len_limit ) #NEWLINE# for line in console . splitlines ( ) : #NEWLINE# #INDENT# if ( re . search ( '\\[critical\\]' , line , flags = re . IGNORECASE ) or re . search ( 'Cloud-init.*Datasource DataSourceNone\\.' , line ) ) : #NEWLINE# #INDENT# message = ( 'Instance %(id)s has critical cloud-init error: %(msg)s. Check metadata service availability' % dict ( id = server_id , msg = line ) ) #NEWLINE# LOG . error ( line ) #NEWLINE# return message #NEWLINE# #UNINDENT# if re . search ( '\\[error' , line , flags = re . IGNORECASE ) : #NEWLINE# #INDENT# LOG . error ( 'Error message in instance %(id)s console: %(msg)s' , dict ( id = server_id , msg = line ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if re . search ( 'warn' , line , flags = re . IGNORECASE ) : #NEWLINE# #INDENT# LOG . info ( 'Warning message in instance %(id)s console: %(msg)s' , dict ( id = server_id , msg = line ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return None