Ensures that a distinguished name list exists with the items provided.

    name: The name of the module function to execute.

    name(str): The name of the distinguished names list.

    items(list): A list of items to ensure exist on the distinguished names list.

    SLS Example:

    .. code-block:: yaml

        MyDistinguishedNameList:
          bluecoat_sslv.distinguished_name_list_exists:
            items:
              - cn=test.com
              - cn=othersite.com

def distinguished_name_list_exists(name, items):
    '''
    Ensures that a distinguished name list exists with the items provided.

    name: The name of the module function to execute.

    name(str): The name of the distinguished names list.

    items(list): A list of items to ensure exist on the distinguished names list.

    SLS Example:

    .. code-block:: yaml

        MyDistinguishedNameList:
          bluecoat_sslv.distinguished_name_list_exists:
            items:
              - cn=test.com
              - cn=othersite.com

    '''
    ret = _default_ret(name)
    req_change = False
    try:
        existing_lists = __salt__['bluecoat_sslv.get_distinguished_name_lists']()
        if name not in existing_lists:
            __salt__['bluecoat_sslv.add_distinguished_name_list'](name)
            req_change = True
        list_members = __salt__['bluecoat_sslv.get_distinguished_name_list'](name)
        for item in items:
            if item not in list_members:
                __salt__['bluecoat_sslv.add_distinguished_name'](name, item)
                req_change = True
        if req_change:
            ret['changes']['before'] = list_members
            ret['changes']['after'] = __salt__['bluecoat_sslv.get_distinguished_name_list'](name)
            ret['comment'] = "Updated distinguished name list."
        else:
            ret['comment'] = "No changes required."
    except salt.exceptions.CommandExecutionError as err:
        ret['result'] = False
        ret['comment'] = err
        log.error(err)
        return ret
    ret['result'] = True
    return ret