Create a new pool if it does not already exist. Pool members are managed separately. Only the
    parameters specified are enforced.

    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 create
    allow_nat
        [yes | no]
    allow_snat
        [yes | no]
    description
        [string]
    gateway_failsafe_device
        [string]
    ignore_persisted_weight
        [enabled | disabled]
    ip_tos_to_client
        [pass-through | [integer]]
    ip_tos_to_server
        [pass-through | [integer]]
    link_qos_to_client
        [pass-through | [integer]]
    link_qos_to_server
        [pass-through | [integer]]
    load_balancing_mode
        [dynamic-ratio-member | dynamic-ratio-node |
        fastest-app-response | fastest-node |
        least-connections-members |
        least-connections-node |
        least-sessions |
        observed-member | observed-node |
        predictive-member | predictive-node |
        ratio-least-connections-member |
        ratio-least-connections-node |
        ratio-member | ratio-node | ratio-session |
        round-robin | weighted-least-connections-member |
        weighted-least-connections-node]
    min_active_members
        [integer]
    min_up_members
        [integer]
    min_up_members_action
        [failover | reboot | restart-all]
    min_up_members_checking
        [enabled | disabled]
    monitor
        [name]
    profiles
        [none | profile_name]
    queue_depth_limit
        [integer]
    queue_on_connection_limit
        [enabled | disabled]
    queue_time_limit
        [integer]
    reselect_tries
        [integer]
    service_down_action
        [drop | none | reselect | reset]
    slow_ramp_time
        [integer]

def manage_pool(hostname, username, password, name,
                allow_nat=None,
                allow_snat=None,
                description=None,
                gateway_failsafe_device=None,
                ignore_persisted_weight=None,
                ip_tos_to_client=None,
                ip_tos_to_server=None,
                link_qos_to_client=None,
                link_qos_to_server=None,
                load_balancing_mode=None,
                min_active_members=None,
                min_up_members=None,
                min_up_members_action=None,
                min_up_members_checking=None,
                monitor=None,
                profiles=None,
                queue_depth_limit=None,
                queue_on_connection_limit=None,
                queue_time_limit=None,
                reselect_tries=None,
                service_down_action=None,
                slow_ramp_time=None):
    '''
    Create a new pool if it does not already exist. Pool members are managed separately. Only the
    parameters specified are enforced.

    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 create
    allow_nat
        [yes | no]
    allow_snat
        [yes | no]
    description
        [string]
    gateway_failsafe_device
        [string]
    ignore_persisted_weight
        [enabled | disabled]
    ip_tos_to_client
        [pass-through | [integer]]
    ip_tos_to_server
        [pass-through | [integer]]
    link_qos_to_client
        [pass-through | [integer]]
    link_qos_to_server
        [pass-through | [integer]]
    load_balancing_mode
        [dynamic-ratio-member | dynamic-ratio-node |
        fastest-app-response | fastest-node |
        least-connections-members |
        least-connections-node |
        least-sessions |
        observed-member | observed-node |
        predictive-member | predictive-node |
        ratio-least-connections-member |
        ratio-least-connections-node |
        ratio-member | ratio-node | ratio-session |
        round-robin | weighted-least-connections-member |
        weighted-least-connections-node]
    min_active_members
        [integer]
    min_up_members
        [integer]
    min_up_members_action
        [failover | reboot | restart-all]
    min_up_members_checking
        [enabled | disabled]
    monitor
        [name]
    profiles
        [none | profile_name]
    queue_depth_limit
        [integer]
    queue_on_connection_limit
        [enabled | disabled]
    queue_time_limit
        [integer]
    reselect_tries
        [integer]
    service_down_action
        [drop | none | reselect | reset]
    slow_ramp_time
        [integer]

    '''

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

    if __opts__['test']:
        return _test_output(ret, 'manage', params={
            'hostname': hostname,
            'username': username,
            'password': password,
            'name': name,
            'allow_nat': allow_nat,
            'allow_snat': allow_snat,
            'description': description,
            'gateway_failsafe_device': gateway_failsafe_device,
            'ignore_persisted_weight': ignore_persisted_weight,
            'ip_tos_client:': ip_tos_to_client,
            'ip_tos_server': ip_tos_to_server,
            'link_qos_to_client': link_qos_to_client,
            'link_qos_to_server': link_qos_to_server,
            'load_balancing_mode': load_balancing_mode,
            'min_active_members': min_active_members,
            'min_up_members': min_up_members,
            'min_up_members_checking': min_up_members_checking,
            'monitor': monitor,
            'profiles': profiles,
            'queue_depth_limit': queue_depth_limit,
            'queue_on_connection_limit': queue_on_connection_limit,
            'queue_time_limit': queue_time_limit,
            'reselect_tries': reselect_tries,
            'service_down_action': service_down_action,
            'slow_ramp_time': slow_ramp_time
        }
        )

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

    # if it exists
    if existing['code'] == 200:

        modified = __salt__['bigip.modify_pool'](hostname=hostname,
                                                 username=username,
                                                 password=password,
                                                 name=name,
                                                 allow_nat=allow_nat,
                                                 allow_snat=allow_snat,
                                                 description=description,
                                                 gateway_failsafe_device=gateway_failsafe_device,
                                                 ignore_persisted_weight=ignore_persisted_weight,
                                                 ip_tos_to_client=ip_tos_to_client,
                                                 ip_tos_to_server=ip_tos_to_server,
                                                 link_qos_to_client=link_qos_to_client,
                                                 link_qos_to_server=link_qos_to_server,
                                                 load_balancing_mode=load_balancing_mode,
                                                 min_active_members=min_active_members,
                                                 min_up_members=min_up_members,
                                                 min_up_members_action=min_up_members_action,
                                                 min_up_members_checking=min_up_members_checking,
                                                 monitor=monitor,
                                                 profiles=profiles,
                                                 queue_depth_limit=queue_depth_limit,
                                                 queue_on_connection_limit=queue_on_connection_limit,
                                                 queue_time_limit=queue_time_limit,
                                                 reselect_tries=reselect_tries,
                                                 service_down_action=service_down_action,
                                                 slow_ramp_time=slow_ramp_time)

        #was the modification successful?
        if modified['code'] == 200:

            #remove member listings and self-links
            del existing['content']['membersReference']
            del modified['content']['membersReference']
            del existing['content']['selfLink']
            del modified['content']['selfLink']

            ret = _check_for_changes('Pool', ret, existing, modified)
        else:
            ret = _load_result(modified, ret)

    # if it doesn't exist
    elif existing['code'] == 404:

        new = __salt__['bigip.create_pool'](hostname=hostname,
                                            username=username,
                                            password=password,
                                            name=name,
                                            allow_nat=allow_nat,
                                            allow_snat=allow_snat,
                                            description=description,
                                            gateway_failsafe_device=gateway_failsafe_device,
                                            ignore_persisted_weight=ignore_persisted_weight,
                                            ip_tos_to_client=ip_tos_to_client,
                                            ip_tos_to_server=ip_tos_to_server,
                                            link_qos_to_client=link_qos_to_client,
                                            link_qos_to_server=link_qos_to_server,
                                            load_balancing_mode=load_balancing_mode,
                                            min_active_members=min_active_members,
                                            min_up_members=min_up_members,
                                            min_up_members_action=min_up_members_action,
                                            min_up_members_checking=min_up_members_checking,
                                            monitor=monitor,
                                            profiles=profiles,
                                            queue_depth_limit=queue_depth_limit,
                                            queue_on_connection_limit=queue_on_connection_limit,
                                            queue_time_limit=queue_time_limit,
                                            reselect_tries=reselect_tries,
                                            service_down_action=service_down_action,
                                            slow_ramp_time=slow_ramp_time)

        # were we able to create it?
        if new['code'] == 200:
            ret['result'] = True
            ret['comment'] = 'Pool was created and enforced to the desired state.  Note: Only parameters specified ' \
                             'were enforced.  See changes for details.'
            ret['changes']['old'] = {}
            ret['changes']['new'] = new['content']

         # unable to create it
        else:
            ret = _load_result(new, ret)

    # else something else was returned
    else:
        ret = _load_result(existing, ret)

    return ret