Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Merge 0403f1c into b1641c0
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffybeing committed Mar 23, 2015
2 parents b1641c0 + 0403f1c commit 56cec1a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/deployment/@relengapi/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ This is effective for development, but certainly not for production.
The database for the relengapi core is named ``relengapi``.
Other blueprints may require additional URIs.

If you ever need to see what SQLAlchemy is doing with the connection pool, it is useful to enable the logging. To do that make sure you have the ``SQLALCHEMY_DB_LOG`` is flag to set to True.

.. _Deployment-Authentication:

Authentication
Expand Down Expand Up @@ -130,19 +132,19 @@ The configuration looks like this::

# Base LDAP URI
'uri': "ldaps://your.ldap.server/",

# This needs to be a user that has sufficient rights to read users and groups
'login_dn': "<dn for bind user>",
'login_password': "<password for bind user>",

# The search bases for users and groups, respectively
'user_base': 'o=users,dc=example,dc=com',
'group_base': 'o=groups,dc=example,dc=com',

# set this to True for extra logging
'debug': False,
}

Permissions are cumulative: a person has a permission if they are a member of any group configured with that permission.
In the example above, a user in both ``team_relops`` and ``team_releng`` would have permission to create tasks and to issue and view tokens.
The group name ``<everyone>`` is treated specially: it grants permission to all authenticated users, regardless of authentication mechanism.
Expand Down
7 changes: 7 additions & 0 deletions relengapi/lib/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
from sqlalchemy.orm import scoping
from sqlalchemy.pool import Pool


# db logging
logger = logging.getLogger(__name__)
logging.basicConfig()


class _QueryProperty(object):
Expand Down Expand Up @@ -75,6 +78,10 @@ def _get_db_config(self, dbname):

@synchronized(threading.Lock())
def engine(self, dbname):
# Get the log level for db logs
if self.app.config.get('SQLALCHEMY_DB_LOG'):
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)

if dbname not in self._engines:
uri = self._get_db_config(dbname)
self._engines[dbname] = sa.create_engine(uri)
Expand Down
6 changes: 6 additions & 0 deletions settings_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
# configuration is present, is to use '*.db' files in the directory containing
# the RelengAPI source code.

# set the flag True for logging SQLAlchemy engine activities
# default it is set to True
SQLALCHEMY_DB_LOG = True

# ===== Authentication and Authorization =====

RELENGAPI_AUTHENTICATION = {
Expand All @@ -36,3 +40,5 @@
# ===== Celery =====
# Any Celery configuration option can be included here; see
# http://docs.celeryproject.org/en/master/configuration.html#configuration


0 comments on commit 56cec1a

Please sign in to comment.