#NEWLINE# def firmware_update( hosts = None , directory = '' ) : #NEWLINE# #INDENT# '\n        State to update the firmware on host\n        using the ``racadm`` command\n\n        firmwarefile\n            filename (string) starting with ``salt://``\n        host\n            string representing the hostname\n            supplied to the ``racadm`` command\n        directory\n            Directory name where firmwarefile\n            will be downloaded\n\n    .. code-block:: yaml\n\n        dell-chassis-firmware-update:\n          dellchassis.firmware_update:\n            hosts:\n              cmc:\n                salt://firmware_cmc.exe\n              server-1:\n                salt://firmware.exe\n            directory: /opt/firmwares\n    ' #NEWLINE# ret = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# ret . changes = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# success = True #NEWLINE# for ( host , firmwarefile ) in hosts : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# _firmware_update ( firmwarefile , host , directory ) #NEWLINE# ret [ 'changes' ] . update ( { #NEWLINE# #INDENT# 'host' : { #NEWLINE# #INDENT# 'comment' : 'Firmware update submitted for {0}' . format ( host ) , #NEWLINE# 'success' : True , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except CommandExecutionError as err : #NEWLINE# #INDENT# success = False #NEWLINE# ret [ 'changes' ] . update ( { #NEWLINE# #INDENT# 'host' : { #NEWLINE# #INDENT# 'comment' : 'FAILED to update firmware for {0}' . format ( success ) , #NEWLINE# 'success' : False , #NEWLINE# 'reason' : str ( err ) , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# ret [ 'result' ] = success #NEWLINE# return ret