Display upgrade impact information without actually upgrading the device.

    system_image (Mandatory Option)
        Path on bootflash: to system image upgrade file.

    kickstart_image
        Path on bootflash: to kickstart image upgrade file.
        (Not required if using combined system/kickstart image file)
        Default: None

    issu
        When True: Attempt In Service Software Upgrade. (non-disruptive)
          The upgrade will abort if issu is not possible.
        When False: Force (disruptive) Upgrade/Downgrade.
        Default: True

    timeout
        Timeout in seconds for long running 'install all' impact command.
        Default: 900

    error_pattern
        Use the option to pass in a regular expression to search for in the
        output of the 'install all impact' command that indicates an error
        has occurred.  This option is only used when proxy minion connection
        type is ssh and otherwise ignored.

    .. code-block:: bash

        salt 'n9k' nxos.check_upgrade_impact system_image=nxos.9.2.1.bin
        salt 'n7k' nxos.check_upgrade_impact system_image=n7000-s2-dk9.8.1.1.bin \\
            kickstart_image=n7000-s2-kickstart.8.1.1.bin issu=False

def check_upgrade_impact(system_image, kickstart_image=None, issu=True, **kwargs):
    '''
    Display upgrade impact information without actually upgrading the device.

    system_image (Mandatory Option)
        Path on bootflash: to system image upgrade file.

    kickstart_image
        Path on bootflash: to kickstart image upgrade file.
        (Not required if using combined system/kickstart image file)
        Default: None

    issu
        When True: Attempt In Service Software Upgrade. (non-disruptive)
          The upgrade will abort if issu is not possible.
        When False: Force (disruptive) Upgrade/Downgrade.
        Default: True

    timeout
        Timeout in seconds for long running 'install all' impact command.
        Default: 900

    error_pattern
        Use the option to pass in a regular expression to search for in the
        output of the 'install all impact' command that indicates an error
        has occurred.  This option is only used when proxy minion connection
        type is ssh and otherwise ignored.

    .. code-block:: bash

        salt 'n9k' nxos.check_upgrade_impact system_image=nxos.9.2.1.bin
        salt 'n7k' nxos.check_upgrade_impact system_image=n7000-s2-dk9.8.1.1.bin \\
            kickstart_image=n7000-s2-kickstart.8.1.1.bin issu=False
    '''
    # Input Validation
    if not isinstance(issu, bool):
        return 'Input Error: The [issu] parameter must be either True or False'

    si = system_image
    ki = kickstart_image
    dev = 'bootflash'
    cmd = 'terminal dont-ask ; show install all impact'

    if ki is not None:
        cmd = cmd + ' kickstart {0}:{1} system {0}:{2}'.format(dev, ki, si)
    else:
        cmd = cmd + ' nxos {0}:{1}'.format(dev, si)

    if issu and ki is None:
        cmd = cmd + ' non-disruptive'

    log.info("Check upgrade impact using command: '%s'", cmd)
    kwargs.update({'timeout': kwargs.get('timeout', 900)})
    error_pattern_list = ['Another install procedure may be in progress',
                          'Pre-upgrade check failed']
    kwargs.update({'error_pattern': error_pattern_list})

    # Execute Upgrade Impact Check
    try:
        impact_check = __salt__['nxos.sendline'](cmd, **kwargs)
    except CommandExecutionError as e:
        impact_check = ast.literal_eval(e.message)
    return _parse_upgrade_data(impact_check)