Ensure the NX-OS system image is running on the device.

    name
        Name of the salt state task

    system_image
        Name of the system image file on bootflash:

    kickstart_image
        Name of the kickstart image file on bootflash:
        This is not needed if the system_image is a combined system and
        kickstart image
        Default: None

    issu
        Ensure the correct system is running on the device using an in service
        software upgrade, or force a disruptive upgrade by setting the option
        to False.
        Default: False

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

    Examples:

    .. code-block:: yaml

        upgrade_software_image_n9k:
          nxos.image_running:
            - name: Ensure nxos.7.0.3.I7.5a.bin is running
            - system_image: nxos.7.0.3.I7.5a.bin
            - issu: True

        upgrade_software_image_n7k:
          nxos.image_running:
            - name: Ensure n7000-s2-kickstart.8.0.1.bin is running
            - kickstart_image: n7000-s2-kickstart.8.0.1.bin
            - system_image: n7000-s2-dk9.8.0.1.bin
            - issu: False

def image_running(name, system_image, kickstart_image=None, issu=True, **kwargs):
    '''
    Ensure the NX-OS system image is running on the device.

    name
        Name of the salt state task

    system_image
        Name of the system image file on bootflash:

    kickstart_image
        Name of the kickstart image file on bootflash:
        This is not needed if the system_image is a combined system and
        kickstart image
        Default: None

    issu
        Ensure the correct system is running on the device using an in service
        software upgrade, or force a disruptive upgrade by setting the option
        to False.
        Default: False

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

    Examples:

    .. code-block:: yaml

        upgrade_software_image_n9k:
          nxos.image_running:
            - name: Ensure nxos.7.0.3.I7.5a.bin is running
            - system_image: nxos.7.0.3.I7.5a.bin
            - issu: True

        upgrade_software_image_n7k:
          nxos.image_running:
            - name: Ensure n7000-s2-kickstart.8.0.1.bin is running
            - kickstart_image: n7000-s2-kickstart.8.0.1.bin
            - system_image: n7000-s2-dk9.8.0.1.bin
            - issu: False
    '''
    ret = {'name': name,
           'result': False,
           'changes': {},
           'comment': ''}

    if kickstart_image is None:
        upgrade = __salt__['nxos.upgrade'](system_image=system_image,
                                           issu=issu, **kwargs)
    else:
        upgrade = __salt__['nxos.upgrade'](system_image=system_image,
                                           kickstart_image=kickstart_image,
                                           issu=issu, **kwargs)

    if upgrade['upgrade_in_progress']:
        ret['result'] = upgrade['upgrade_in_progress']
        ret['changes'] = upgrade['module_data']
        ret['comment'] = 'NX-OS Device Now Being Upgraded - See Change Details Below'
    elif upgrade['succeeded']:
        ret['result'] = upgrade['succeeded']
        ret['comment'] = 'NX-OS Device Running Image: {}'.format(_version_info())
    else:
        ret['comment'] = 'Upgrade Failed: {}.'.format(upgrade['error_data'])

    return ret