#NEWLINE# def annotate_instances( instances ) : #NEWLINE# #INDENT# 'loops through the instances and adds exclusion, age and timeout' #NEWLINE# for inst in instances : #NEWLINE# #INDENT# excluded = False #NEWLINE# tags = inst . get ( 'tags' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( 'items' , [ ] ) #NEWLINE# inst [ '_tags' ] = tags #NEWLINE# for tag in tags : #NEWLINE# #INDENT# if ( tag . lower ( ) in CONFIG [ 'SAFE_TAGS' ] ) : #NEWLINE# #INDENT# excluded = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# inst [ '_excluded' ] = excluded #NEWLINE# creation = parse_iso8601tz ( inst [ 'creationTimestamp' ] ) #NEWLINE# now = datetime . datetime . now ( ) #NEWLINE# delta = ( now - creation ) #NEWLINE# age_minutes = ( ( ( delta . days * 24 ) * 60 ) + ( delta . seconds / 60 ) ) #NEWLINE# inst [ '_age_minutes' ] = age_minutes #NEWLINE# if ( ( not inst [ '_excluded' ] ) and ( age_minutes >= CONFIG [ 'TIMEOUT' ] ) ) : #NEWLINE# #INDENT# inst [ '_timeout_expired' ] = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# inst [ '_timeout_expired' ] = False