Exemple #1
0
def get_resource_mgr_properties(context, parent_id, key=None, session=None):
    """Get properties from the properties table for a Resource Manager

    :param parent_id: ID of the Resource Managers
    :param key: key of the property. When not specified returns all the
     properties associated with parent_id
    :return: List of property objects
    """
    session = session or _get_session()
    with session.begin(subtransactions=True):
        try:
            if key:
                query = (session.query(
                    models.ResourceManagerProperties).filter_by(
                        parent_id=parent_id).filter_by(key=key).filter_by(
                            deleted=False))
                prop = query.one()
                return [prop]
            else:
                query = (session.query(
                    models.ResourceManagerProperties).filter_by(
                        parent_id=parent_id).filter_by(deleted=False))
                props = query.all()
                return props
        except sa_orm.exc.NoResultFound:
            msg = _("No Property found for Parent ID %s") % parent_id
            log_msg = ("No Property found for Parent ID %s") % parent_id
            LOG.error(log_msg)
            raise exception.NotFound(msg)
Exemple #2
0
def setup_logging():
    """
    Sets up the logging options for a log with supplied name
    """

    if CONF.log_config:
        # Use a logging configuration file for all settings...
        if os.path.exists(CONF.log_config):
            logging.config.fileConfig(CONF.log_config)
            return
        else:
            raise RuntimeError(
                _("Unable to locate specified logging "
                  "config file: %s" % CONF.log_config))

    root_logger = logging.root
    if CONF.debug:
        root_logger.setLevel(logging.DEBUG)
    elif CONF.verbose:
        root_logger.setLevel(logging.INFO)
    else:
        root_logger.setLevel(logging.WARNING)

    formatter = logging.Formatter(CONF.log_format, CONF.log_date_format)

    if CONF.use_syslog:
        try:
            facility = getattr(logging.handlers.SysLogHandler,
                               CONF.syslog_log_facility)
        except AttributeError:
            raise ValueError(_("Invalid syslog facility"))

        handler = logging.handlers.SysLogHandler(address='/dev/log',
                                                 facility=facility)
    elif CONF.log_file:
        logfile = CONF.log_file
        if CONF.log - dir:
            logfile = os.path.join(CONF.log - dir, logfile)
        handler = logging.handlers.WatchedFileHandler(logfile)
    else:
        handler = logging.StreamHandler(sys.stdout)

    handler.setFormatter(formatter)
    root_logger.addHandler(handler)
Exemple #3
0
def _get(context, _id, session, db_model):
    with session.begin(subtransactions=True):
        try:
            query = session.query(db_model).filter_by(id=_id)
            instance = query.one()
            return instance
        except sa_orm.exc.NoResultFound:
            msg = _("No %s found with ID %s") % (db_model.__tablename__, _id)
            log_msg = ("No %s found with ID %s") % (db_model.__tablename__,
                                                    _id)
            LOG.error(log_msg)
            raise exception.NotFound(msg)
Exemple #4
0
def get_deployment_config_file():
    """
    Retrieve the deployment_config_file config item, formatted as an
    absolute pathname.
    """
    path = CONF.paste_deploy.config_file
    if not path:
        path = _get_paste_config_path()
    if not path:
        msg = (_("Unable to locate paste config file for %s.") % CONF.prog)
        raise RuntimeError(msg)
    return os.path.abspath(path)
Exemple #5
0
    def __get_backend(self):
        if not self.__backend:
            if self.__config_group is None:
                backend_name = CONF[self.__pivot]
            else:
                backend_name = CONF[self.__config_group][self.__pivot]
            if backend_name not in self.__backends:
                msg = _('Invalid backend: %s') % backend_name
                raise exception.EonException(msg)

            backend = self.__backends[backend_name]
            if isinstance(backend, tuple):
                name = backend[0]
                fromlist = backend[1]
            else:
                name = backend
                fromlist = backend

            self.__backend = __import__(name, None, None, fromlist)
        return self.__backend
Exemple #6
0
def load_paste_app(app_name=None):
    """
    Builds and returns a WSGI app from a paste config file.

    We assume the last config file specified in the supplied ConfigOpts
    object is the paste config file.

    :param app_name: name of the application to load

    :raises RuntimeError when config file cannot be located or application
            cannot be loaded from config file
    """
    if app_name is None:
        app_name = CONF.prog

    # append the deployment flavor to the application name,
    # in order to identify the appropriate paste pipeline

    conf_file = get_deployment_config_file()

    try:
        logger = logging.getLogger(__name__)
        logger.debug(("Loading %(app_name)s from %(conf_file)s"), {
            'conf_file': conf_file,
            'app_name': app_name
        })

        app = deploy.loadapp("config:%s" % conf_file, name=app_name)

        # Log the options used when starting if we're in debug mode...
        if CONF.debug:
            CONF.log_opt_values(logger, logging.DEBUG)

        return app
    except (LookupError, ImportError) as e:
        msg = (_("Unable to load %(app_name)s from "
                 "configuration file %(conf_file)s."
                 "\nGot: %(e)r") % locals())
        logger.error(msg)
        raise RuntimeError(msg)
Exemple #7
0
class DeprecatedConfig(Exception):
    message = (_("Fatal call to deprecated config: %(msg)s"))

    def __init__(self, msg):
        super(Exception, self).__init__(self.message % dict(msg=msg))
Exemple #8
0
_ENGINE = None
_MAKER = None
_MAX_RETRIES = None
_RETRY_INTERVAL = None
BASE = models.Base
sa_logger = None
LOG = os_logging.getLogger(__name__)

STATUSES = [
    'active', 'saving', 'queued', 'killed', 'pending_delete', 'deleted'
]

db_opts = [
    cfg.IntOpt('sql_idle_timeout',
               default=3600,
               help=(_('Period in seconds after which SQLAlchemy should '
                       'reestablish its connection to the database.'))),
    cfg.IntOpt('sql_max_retries',
               default=60,
               help=(_('The number of times to retry a connection to the SQL'
                       'server.'))),
    cfg.IntOpt('sql_retry_interval',
               default=1,
               help=(_('The amount of time to wait (in seconds) before '
                       'attempting to retry the SQL connection.'))),
    cfg.BoolOpt('db_auto_create',
                default=False,
                help=(_('A boolean that determines if the database will be '
                        'automatically created.'))),
]

CONF = cfg.CONF
Exemple #9
0
import logging.handlers
import os
import sys

from eon.common.gettextutils import _
from eon.common import rpc
from oslo_config import cfg
from paste import deploy

from eon.version import version_info as version

paste_deploy_opts = [
    cfg.StrOpt('flavor',
               help=(_('Partial name of a pipeline in your paste configuration'
                       ' file with the service name removed. For example, if '
                       'your paste section name is '
                       '[pipeline:isc-api-keystone] use the value '
                       '"keystone"'))),
    cfg.StrOpt('config_file',
               help=(_('Name of the paste configuration file.'))),
]
common_opts = [
    cfg.IntOpt('limit_param_default',
               default=25,
               help=(_('Default value for the number of items returned by a '
                       'request if not specified explicitly in the request'))),
    cfg.IntOpt('api_limit_max',
               default=1000,
               help=(_('Maximum permissible number of items that could be '
                       'returned by a request'))),
    cfg.StrOpt('pydev_worker_debug_host',