Clones an existing image.

    .. versionadded:: 2016.3.0

    name
        The name of the new image.

    image_id
        The ID of the image to be cloned. Can be used instead of ``image_name``.

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

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_clone opennebula name=my-new-image image_id=10
        salt-cloud -f image_clone opennebula name=my-new-image image_name=my-image-to-clone

def image_clone(call=None, kwargs=None):
    '''
    Clones an existing image.

    .. versionadded:: 2016.3.0

    name
        The name of the new image.

    image_id
        The ID of the image to be cloned. Can be used instead of ``image_name``.

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

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_clone opennebula name=my-new-image image_id=10
        salt-cloud -f image_clone opennebula name=my-new-image image_name=my-image-to-clone
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The image_clone function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

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

    if name is None:
        raise SaltCloudSystemExit(
            'The image_clone function requires a \'name\' to be provided.'
        )

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

    server, user, password = _get_xml_rpc()
    auth = ':'.join([user, password])
    response = server.one.image.clone(auth, int(image_id), name)

    data = {
        'action': 'image.clone',
        'cloned': response[0],
        'cloned_image_id': response[1],
        'cloned_image_name': name,
        'error_code': response[2],
    }

    return data