Returns a host's ID from the given host name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_host_id opennebula name=my-host-name

def get_host_id(kwargs=None, call=None):
    '''
    Returns a host's ID from the given host name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_host_id opennebula name=my-host-name
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The get_host_id function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    name = kwargs.get('name', None)
    if name is None:
        raise SaltCloudSystemExit(
            'The get_host_id function requires a name.'
        )

    try:
        ret = avail_locations()[name]['id']
    except KeyError:
        raise SaltCloudSystemExit(
            'The host \'{0}\' could not be found'.format(name)
        )

    return ret