A function to connect to a bigip device and add a new member to an existing pool.

    hostname
        The host/address of the bigip device
    username
        The iControl REST username
    password
        The iControl REST password
    name
        The name of the pool to modify
    member
        The member to add to the pool

def add_pool_member(hostname, username, password, name, member):
    '''
    A function to connect to a bigip device and add a new member to an existing pool.

    hostname
        The host/address of the bigip device
    username
        The iControl REST username
    password
        The iControl REST password
    name
        The name of the pool to modify
    member
        The member to add to the pool
    '''

    ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}

    if __opts__['test']:
        return _test_output(ret, 'add', params={
            'hostname': hostname,
            'username': username,
            'password': password,
            'name': name,
            'members': member
        }
        )

    #is this pool member currently configured?
    existing_pool = __salt__['bigip.list_pool'](hostname, username, password, name)

    if existing_pool['code'] == 200:

        # for some reason iControl REST doesn't support listing a single pool member.
        # the response from GET for listing a member will return 200 even if it doesn't exists.
        # because of this we have to do some rather "unnecessary" searching within a pool.

        #what are the current members?
        current_members = existing_pool['content']['membersReference']['items']

        #loop through them
        exists = False
        for current_member in current_members:
            if current_member['name'] == member['name']:
                exists = True
                break

        if exists:
            ret['result'] = True
            ret['comment'] = 'Member: {name} already exists within this pool.  No changes made.'.format(name=member['name'])
            ret['changes']['old'] = {}
            ret['changes']['new'] = {}
        else:
            new_member = __salt__['bigip.add_pool_member'](hostname, username, password, name, member)

            if new_member['code'] == 200:
                ret['result'] = True
                ret['comment'] = 'Member: {name} has been successfully added to the pool.'.format(name=member['name'])
                ret['changes']['old'] = {}

                #look up the member again...
                pool_listing = __salt__['bigip.list_pool'](hostname, username, password, name)

                if pool_listing['code'] != 200:
                    ret = _load_result(new_member, ret)
                    return ret

                members = pool_listing['content']['membersReference']['items']
                #loop through them
                for current_member in members:
                    if current_member['name'] == member['name']:
                        added_member = current_member
                        break

                ret['changes']['new'] = added_member

            # member wasn't added
            else:
                ret = _load_result(new_member, ret)

    #pool does not exists
    elif existing_pool['code'] == 404:
        ret['comment'] = 'A pool with this name was not found.'
    else:
        ret = _load_result(existing_pool, ret)

    return ret