Helper method that does the heavy lifting for upgrades.

def _upgrade(system_image, kickstart_image, issu, **kwargs):
    '''
    Helper method that does the heavy lifting for upgrades.
    '''
    si = system_image
    ki = kickstart_image
    dev = 'bootflash'
    cmd = 'terminal dont-ask ; install all'

    if ki is None:
        logmsg = 'Upgrading device using combined system/kickstart image.'
        logmsg += '\nSystem Image: {}'.format(si)
        cmd = cmd + ' nxos {0}:{1}'.format(dev, si)
        if issu:
            cmd = cmd + ' non-disruptive'
    else:
        logmsg = 'Upgrading device using separate system/kickstart images.'
        logmsg += '\nSystem Image: {}'.format(si)
        logmsg += '\nKickstart Image: {}'.format(ki)
        if not issu:
            log.info('Attempting upgrade using force option')
            cmd = cmd + ' force'
        cmd = cmd + ' kickstart {0}:{1} system {0}:{2}'.format(dev, ki, si)

    if issu:
        logmsg += '\nIn Service Software Upgrade/Downgrade (non-disruptive) requested.'
    else:
        logmsg += '\nDisruptive Upgrade/Downgrade requested.'

    log.info(logmsg)
    log.info("Begin upgrade using command: '%s'", cmd)

    kwargs.update({'timeout': kwargs.get('timeout', 900)})
    error_pattern_list = ['Another install procedure may be in progress']
    kwargs.update({'error_pattern': error_pattern_list})

    # Begin Actual Upgrade
    try:
        upgrade_result = __salt__['nxos.sendline'](cmd, **kwargs)
    except CommandExecutionError as e:
        upgrade_result = ast.literal_eval(e.message)
    except NxosError as e:
        if re.search('Code: 500', e.message):
            upgrade_result = e.message
        else:
            upgrade_result = ast.literal_eval(e.message)
    return _parse_upgrade_data(upgrade_result)