Sets the Image as persistent or not persistent.

    .. versionadded:: 2016.3.0

    name
        The name of the image to set. Can be used instead of ``image_id``.

    image_id
        The ID of the image to set. Can be used instead of ``name``.

    persist
        A boolean value to set the image as persistent or not. Set to true
        for persistent, false for non-persistent.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_persistent opennebula name=my-image persist=True
        salt-cloud --function image_persistent opennebula image_id=5 persist=False

def image_persistent(call=None, kwargs=None):
    '''
    Sets the Image as persistent or not persistent.

    .. versionadded:: 2016.3.0

    name
        The name of the image to set. Can be used instead of ``image_id``.

    image_id
        The ID of the image to set. Can be used instead of ``name``.

    persist
        A boolean value to set the image as persistent or not. Set to true
        for persistent, false for non-persistent.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_persistent opennebula name=my-image persist=True
        salt-cloud --function image_persistent opennebula image_id=5 persist=False
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The image_persistent function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    name = kwargs.get('name', None)
    persist = kwargs.get('persist', None)
    image_id = kwargs.get('image_id', None)

    if persist is None:
        raise SaltCloudSystemExit(
            'The image_persistent function requires \'persist\' to be set to \'True\' '
            'or \'False\'.'
        )

    if image_id:
        if name:
            log.warning(
                'Both the \'image_id\' and \'name\' arguments were provided. '
                '\'image_id\' will take precedence.'
            )
    elif name:
        image_id = get_image_id(kwargs={'name': name})
    else:
        raise SaltCloudSystemExit(
            'The image_persistent function requires either a \'name\' or an '
            '\'image_id\' to be provided.'
        )

    server, user, password = _get_xml_rpc()
    auth = ':'.join([user, password])
    response = server.one.image.persistent(auth, int(image_id), salt.utils.data.is_true(persist))

    data = {
        'action': 'image.persistent',
        'response': response[0],
        'image_id': response[1],
        'error_code': response[2],
    }

    return data