#NEWLINE# @ classmethod #NEWLINE# def _DeleteResource( cls , filter_string , list_method , delete_method , get_method ) : #NEWLINE# #INDENT# 'Deletes Compute Engine resources that match the filter.\n\n    Args:\n      filter_string: Filter string of the resource.\n      list_method: Method to list the resources.\n      delete_method: Method to delete the single resource.\n      get_method: Method to get the status of the single resource.\n    Raises:\n      ClusterDeletionTimeout: the resource deletion times out.\n    ' #NEWLINE# while True : #NEWLINE# #INDENT# list_of_resources = list_method ( filter_string ) #NEWLINE# resource_names = [ i [ 'name' ] for i in list_of_resources ] #NEWLINE# if ( not resource_names ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# for name in resource_names : #NEWLINE# #INDENT# logging . info ( '  %s' , name ) #NEWLINE# delete_method ( name ) #NEWLINE# #UNINDENT# for _ in xrange ( cls . DELETION_MAX_CHECK_TIMES ) : #NEWLINE# #INDENT# still_alive = [ ] #NEWLINE# for name in resource_names : #NEWLINE# #INDENT# if get_method ( name ) : #NEWLINE# #INDENT# still_alive . append ( name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logging . info ( 'Deletion complete: %s' , name ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not still_alive ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# resource_names = still_alive #NEWLINE# time . sleep ( cls . DELETION_CHECK_INTERVAL ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ClusterDeletionTimeout ( 'Resource deletion time out' )