#NEWLINE# def agent_get_clean_steps( task , interface = None , override_priorities = None ) : #NEWLINE# #INDENT# "Get the list of cached clean steps from the agent.\n\n    #TODO(JoshNang) move to BootInterface\n\n    The clean steps cache is updated at the beginning of cleaning.\n\n    :param task: a TaskManager object containing the node\n    :param interface: The interface for which clean steps\n        are to be returned. If this is not provided, it returns the\n        clean steps for all interfaces.\n    :param override_priorities: a dictionary with keys being step names and\n        values being new priorities for them. If a step isn't in this\n        dictionary, the step's original priority is used.\n    :raises NodeCleaningFailure: if the clean steps are not yet cached,\n        for example, when a node has just been enrolled and has not been\n        cleaned yet.\n    :returns: A list of clean step dictionaries\n    " #NEWLINE# node = task . node #NEWLINE# try : #NEWLINE# #INDENT# all_steps = node . driver_internal_info [ 'agent_cached_clean_steps' ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise exception . NodeCleaningFailure ( ( _ ( 'Cleaning steps are not yet available for node %(node)s' ) % { #NEWLINE# #INDENT# 'node' : node . uuid , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# if interface : #NEWLINE# #INDENT# steps = [ step . copy ( ) for step in all_steps . get ( interface , [ ] ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# steps = [ step . copy ( ) for step_list in all_steps . values ( ) for step in step_list ] #NEWLINE# #UNINDENT# if ( ( not steps ) or ( not override_priorities ) ) : #NEWLINE# #INDENT# return steps #NEWLINE# #UNINDENT# for step in steps : #NEWLINE# #INDENT# new_priority = override_priorities . get ( step . get ( 'step' ) ) #NEWLINE# if ( new_priority is not None ) : #NEWLINE# #INDENT# step [ 'priority' ] = new_priority #NEWLINE# #UNINDENT# #UNINDENT# return steps