Пример #1
0
    def __init__(self, destination, **kwargs):
        self._configured = False

        if kwargs.has_key("config"):
            self._configure(kwargs["config"])
            self._configured = True

        if kwargs.has_key("loglevel"):
            log_level = kwargs["loglevel"]
        elif self._configured is True and self._config.has_option(
                'global', 'log_level'):
            log_level = self._config.get('global', 'log_level')
        else:
            log_level = 'WARN'

        self.log = logger.LogWrapper(name='vogeler').logger()

        if kwargs.has_key("dsn"):
            _dsn = kwargs["dsn"]
        elif self._configured is True and self._config.has_option(
                'amqp', 'dsn'):
            _dsn = self._config.get('amqp', 'dsn')
        else:
            self.log.fatal("No dsn provided. Cannot continue")

        try:
            self.routing_key = destination
            self.ch = amqp.setup_amqp(_dsn)
            self.log.info("Vogeler(Runner) is starting up")
        except Exception, e:
            msg = "Unable to connect to broker %s" % _dsn
            self.log.fatal(msg)
            raise VogelerRunnerException(e)
Пример #2
0
    def __init__(self, plugin_dir='/etc/vogeler/plugins', **kwargs):
        self._configured = False

        if kwargs.has_key("config"):
            self._configure(kwargs["config"])
            self._configured = True

        if kwargs.has_key("loglevel"):
            log_level = kwargs["loglevel"]
        elif self._configured is True and self._config.has_option(
                'global', 'log_level'):
            log_level = self._config.get('global', 'log_level')
        else:
            log_level = 'WARN'

        self.log = logger.LogWrapper(name='vogeler').logger()

        self.log.info("Vogeler is parsing plugins")
        self.registered_plugins = {}
        self.plugin_dir = plugin_dir
        self._compile_plugins()
Пример #3
0
    def __init__(self, callback_function=None, role='client', **kwargs):

        self._configured = False
        self.role = role

        if kwargs.has_key("config"):
            self._configure(kwargs["config"])
            self._configured = True

        if kwargs.has_key("loglevel"):
            log_level = kwargs["loglevel"]
        elif self._configured is True and self._config.has_option(
                'global', 'log_level'):
            log_level = self._config.get('global', 'log_level')
        else:
            log_level = 'WARN'

        self.log = logger.LogWrapper(name='vogeler-%s' % self.role).logger()

        if kwargs.has_key("dsn"):
            _dsn = kwargs["dsn"]
        elif self._configured is True and self._config.has_option(
                'amqp', 'dsn'):
            _dsn = self._config.get('amqp', 'dsn')
        else:
            error = "No dsn provided. Cannot continue"
            self.log.fatal(error)
            raise exceptions.VogelerMessagingException(error)

        try:
            self.ch, self.queue = amqp.setup_server(_dsn)
            self.callback_function = callback_function
        except Exception, e:
            error = "Error connecting to %s" % _dsn
            self.log.fatal(error)
            raise e
Пример #4
0
import urlparse, json, yaml, datetime

import vogeler.logger as logger
import vogeler.exceptions as exceptions

log = logger.LogWrapper(name='vogeler.db').logger()


class GenericPersistence(object):
    def __init__(self, dsn, **kwargs):
        try:
            _parsed = urlparse.urlparse(dsn)
            self.username, self.password = _parsed.username, _parsed.password
            self.host, self.port = _parsed.hostname, _parsed.port

            db = _parsed.path.split("/")[1]
            if self.host is None or self.port is None:
                log.fatal("Invalid DSN provided: %s" % dsn)
            if db is None:
                log.fatal("Invalid DSN provided: %s" % dsn)
        except:
            raise

        self.dbname = db
        self.connect()

    def connect(self, **kwargs):
        """
        Method for connection to a server
        """
        self.hook_connect(**kwargs)
Пример #5
0
import datetime, json
import pymongo as mongo

import vogeler.exceptions as exceptions
import vogeler.logger as logger

from vogeler.db.generic import GenericPersistence

log = logger.LogWrapper(name='vogeler.db.mongo').logger()


class Persistence(GenericPersistence):
    """
    The format for mongodb backends uses the following model:
    database name from param
    collection name - databasename_collection

    Will consider better options ;)

    Also, all inserts/saves are done with safe=True
    """
    def hook_connect(self, **kwargs):
        if self.username is None or self.password is None:
            connection_string = "mongodb://%s:%s" % (self.host, self.port)
        else:
            connection_string = "mongodb://%s:%s@%s:%s" % (
                self.username, self.password, self.host, self.port)
        self._server = mongo.Connection(host=connection_string)

    def hook_createdb(self, dbname):
        """
Пример #6
0
import datetime
import couchdbkit as couch
from couchdbkit.loaders import FileSystemDocsLoader

import vogeler.exceptions as exceptions
import vogeler.logger as logger

from vogeler.db.generic import GenericPersistence

log = logger.LogWrapper(name='vogeler.db.couch').logger()


class SystemRecord(couch.Document):
    """
    A couchdbkit document for storing our base information
    All documents, regardless of backend, should support
    the following fields:
    system_name
    created_at
    updated_at
    """
    system_name = couch.StringProperty()
    created_at = couch.DateTimeProperty()
    updated_at = couch.DateTimeProperty()


class Persistence(GenericPersistence):
    def hook_connect(self, **kwargs):
        if self.username is None or self.password is None:
            connection_string = "http://%s:%s" % (self.host, self.port)
        else: