Ensures that the Connection Factory is present

    name
        Name of the connection factory

    restype
        Type of the connection factory, can be either ``connection_factory``,
        ``queue_connection_factory` or ``topic_connection_factory``,
        defaults to ``connection_factory``

    description
        Description of the connection factory

    enabled
        Is the connection factory enabled? defaults to ``true``

    min_size
        Minimum and initial number of connections in the pool, defaults to ``1``

    max_size
        Maximum number of connections that can be created in the pool, defaults to ``250``

    resize_quantity
        Number of connections to be removed when idle_timeout expires, defaults to ``2``

    idle_timeout
        Maximum time a connection can remain idle in the pool, in seconds, defaults to ``300``

    wait_timeout
        Maximum time a caller can wait before timeout, in seconds, defaults to ``60``

    reconnect_on_failure
        Close all connections and reconnect on failure (or reconnect only when used), defaults to ``false``
    transaction_support
        Level of transaction support, can be either ``XATransaction``, ``LocalTransaction`` or ``NoTransaction``

    connection_validation
        Connection validation is required, defaults to ``false``

def connection_factory_present(name,
                               restype='connection_factory',
                               description='',
                               enabled=True,
                               min_size=1,
                               max_size=250,
                               resize_quantity=2,
                               idle_timeout=300,
                               wait_timeout=60,
                               reconnect_on_failure=False,
                               transaction_support='',
                               connection_validation=False,
                               server=None):
    '''
    Ensures that the Connection Factory is present

    name
        Name of the connection factory

    restype
        Type of the connection factory, can be either ``connection_factory``,
        ``queue_connection_factory` or ``topic_connection_factory``,
        defaults to ``connection_factory``

    description
        Description of the connection factory

    enabled
        Is the connection factory enabled? defaults to ``true``

    min_size
        Minimum and initial number of connections in the pool, defaults to ``1``

    max_size
        Maximum number of connections that can be created in the pool, defaults to ``250``

    resize_quantity
        Number of connections to be removed when idle_timeout expires, defaults to ``2``

    idle_timeout
        Maximum time a connection can remain idle in the pool, in seconds, defaults to ``300``

    wait_timeout
        Maximum time a caller can wait before timeout, in seconds, defaults to ``60``

    reconnect_on_failure
        Close all connections and reconnect on failure (or reconnect only when used), defaults to ``false``
    transaction_support
        Level of transaction support, can be either ``XATransaction``, ``LocalTransaction`` or ``NoTransaction``

    connection_validation
        Connection validation is required, defaults to ``false``
    '''
    ret = {'name': name, 'result': None, 'comment': None, 'changes': {}}

    # Manage parameters
    pool_data = {}
    res_data = {}
    pool_name = '{0}-Connection-Pool'.format(name)
    if restype == 'topic_connection_factory':
        pool_data['connectionDefinitionName'] = 'javax.jms.TopicConnectionFactory'
    elif restype == 'queue_connection_factory':
        pool_data['connectionDefinitionName'] = 'javax.jms.QueueConnectionFactory'
    elif restype == 'connection_factory':
        pool_data['connectionDefinitionName'] = 'javax.jms.ConnectionFactory'
    else:
        ret['result'] = False
        ret['comment'] = 'Invalid restype'
        return ret
    pool_data['description'] = description
    res_data['description'] = description
    res_data['enabled'] = enabled
    res_data['poolName'] = pool_name
    pool_data['steadyPoolSize'] = min_size
    pool_data['maxPoolSize'] = max_size
    pool_data['poolResizeQuantity'] = resize_quantity
    pool_data['idleTimeoutInSeconds'] = idle_timeout
    pool_data['maxWaitTimeInMillis'] = wait_timeout*1000
    pool_data['failAllConnections'] = reconnect_on_failure
    if transaction_support:
        if transaction_support == 'xa_transaction':
            pool_data['transactionSupport'] = 'XATransaction'
        elif transaction_support == 'local_transaction':
            pool_data['transactionSupport'] = 'LocalTransaction'
        elif transaction_support == 'no_transaction':
            pool_data['transactionSupport'] = 'NoTransaction'
        else:
            ret['result'] = False
            ret['comment'] = 'Invalid transaction_support'
            return ret
    pool_data['isConnectionValidationRequired'] = connection_validation

    pool_ret = _do_element_present(pool_name, 'connector_c_pool', pool_data, server)
    res_ret = _do_element_present(name, 'connector_resource', res_data, server)

    if not pool_ret['error'] and not res_ret['error']:
        if not __opts__['test']:
            ret['result'] = True

        if pool_ret['create'] or res_ret['create']:
            ret['changes']['pool'] = pool_ret['changes']
            ret['changes']['resource'] = res_ret['changes']
            if __opts__['test']:
                ret['comment'] = 'Connection factory set to be created'
            else:
                ret['comment'] = 'Connection factory created'
        elif pool_ret['update'] or res_ret['update']:
            ret['changes']['pool'] = pool_ret['changes']
            ret['changes']['resource'] = res_ret['changes']
            if __opts__['test']:
                ret['comment'] = 'Connection factory set to be updated'
            else:
                ret['comment'] = 'Connection factory updated'
        else:
            ret['result'] = True
            ret['changes'] = {}
            ret['comment'] = 'Connection factory is already up-to-date'
    else:
        ret['result'] = False
        ret['comment'] = 'ERROR: {0} // {1}'.format(pool_ret['error'], res_ret['error'])

    return ret