Modify an existing node. Only a node which already exists will be modified and
    only the parameters specified will be enforced.

    hostname
        The host/address of the bigip device
    username
        The iControl REST username
    password
        The iControl REST password
    name
        The name of the node to modify
    connection_limit
        [integer]
    description
        [string]
    dynamic_ratio
        [integer]
    logging
        [enabled | disabled]
    monitor
        [[name] | none | default]
    rate_limit
        [integer]
    ratio
        [integer]
    session
        [user-enabled | user-disabled]
    node_state (state)
        [user-down | user-up ]

def modify_node(hostname, username, password, name,
                connection_limit=None,
                description=None,
                dynamic_ratio=None,
                logging=None,
                monitor=None,
                rate_limit=None,
                ratio=None,
                session=None,
                node_state=None):
    '''
    Modify an existing node. Only a node which already exists will be modified and
    only the parameters specified will be enforced.

    hostname
        The host/address of the bigip device
    username
        The iControl REST username
    password
        The iControl REST password
    name
        The name of the node to modify
    connection_limit
        [integer]
    description
        [string]
    dynamic_ratio
        [integer]
    logging
        [enabled | disabled]
    monitor
        [[name] | none | default]
    rate_limit
        [integer]
    ratio
        [integer]
    session
        [user-enabled | user-disabled]
    node_state (state)
        [user-down | user-up ]
    '''

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

    if __opts__['test']:
        return _test_output(ret, 'modify', params={
            'hostname': hostname,
            'username': username,
            'password': password,
            'name': name,
            'connection_limit': connection_limit,
            'description': description,
            'dynamic_ratio': dynamic_ratio,
            'logging': logging,
            'monitor': monitor,
            'rate_limit': rate_limit,
            'ratio': ratio,
            'session': session,
            'state:': node_state
        }
        )

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

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

        modified = __salt__['bigip.modify_node'](hostname=hostname,
                                                 username=username,
                                                 password=password,
                                                 name=name,
                                                 connection_limit=connection_limit,
                                                 description=description,
                                                 dynamic_ratio=dynamic_ratio,
                                                 logging=logging,
                                                 monitor=monitor,
                                                 rate_limit=rate_limit,
                                                 ratio=ratio,
                                                 session=session,
                                                 state=node_state)

        #was the modification successful?
        if modified['code'] == 200:
            ret = _check_for_changes('Node', ret, existing, modified)
        else:
            ret = _load_result(modified, ret)

    # not found, attempt to create it
    elif existing['code'] == 404:
        ret['comment'] = 'A node with this name was not found.'
    # an error occurred
    else:
        ret = _load_result(existing, ret)

    return ret