State to update the firmware on host
        using the ``racadm`` command

        firmwarefile
            filename (string) starting with ``salt://``
        host
            string representing the hostname
            supplied to the ``racadm`` command
        directory
            Directory name where firmwarefile
            will be downloaded

    .. code-block:: yaml

        dell-chassis-firmware-update:
          dellchassis.firmware_update:
            hosts:
              cmc:
                salt://firmware_cmc.exe
              server-1:
                salt://firmware.exe
            directory: /opt/firmwares

def firmware_update(hosts=None, directory=''):
    '''
        State to update the firmware on host
        using the ``racadm`` command

        firmwarefile
            filename (string) starting with ``salt://``
        host
            string representing the hostname
            supplied to the ``racadm`` command
        directory
            Directory name where firmwarefile
            will be downloaded

    .. code-block:: yaml

        dell-chassis-firmware-update:
          dellchassis.firmware_update:
            hosts:
              cmc:
                salt://firmware_cmc.exe
              server-1:
                salt://firmware.exe
            directory: /opt/firmwares
    '''
    ret = {}
    ret.changes = {}
    success = True
    for host, firmwarefile in hosts:
        try:
            _firmware_update(firmwarefile, host, directory)
            ret['changes'].update({
                'host': {
                    'comment': 'Firmware update submitted for {0}'.format(host),
                    'success': True,
                }
            })
        except CommandExecutionError as err:
            success = False
            ret['changes'].update({
                'host': {
                    'comment': 'FAILED to update firmware for {0}'.format(host),
                    'success': False,
                    'reason': six.text_type(err),
                }
            })
    ret['result'] = success
    return ret