예제 #1
0
파일: mongodb.py 프로젝트: CloudRift/Rift
from pymongo import MongoClient

from rift.config import get_config

STATUS_NEW = 'NEW'
STATUS_CONNECTED = 'CONNECTED'
STATUS_CLOSED = 'CLOSED'

conf = get_config()


class MongoDB(object):
    """
    An handler class to provide CRUD operations using MongoDB
    """

    def __init__(self):
        """
        Sets the address of the mongo server, specifies the database to use
        and connects to the server
        """
        self.server = conf.mongodb.server
        self.database_name = conf.mongodb.database
        self.status = STATUS_NEW

    def connect(self):
        """
        Creates a connection with the MongoDB server and database
        """
        self.connection = MongoClient(self.server)
        self.database = self.connection[self.database_name]
예제 #2
0
from celery import Celery

from rift.config import get_config

conf = get_config()

celery = Celery('cloudrift')

# load celery configurations from rift config and apply them
celery.conf.BROKER_URL = conf.celery.broker_url
celery.conf.CELERYD_CONCURRENCY = conf.celery.celeryd_concurrency
celery.conf.CELERY_TASK_SERIALIZER = conf.celery.celery_task_serializer
celery.conf.CELERYD_HIJACK_ROOT_LOGGER = conf.celery.celeryd_hijack_root_logger
예제 #3
0
파일: common.py 프로젝트: CloudRift/Rift
import os
import sys

from cryptography.fernet import Fernet

from rift import config
from rift import log

LOG = log.get_logger()
cfg = config.get_config()
KEY = None


def load_secret_key(filename=cfg.general.key_file):
    dev_location = './etc/rift/secret.key'
    key_path = None
    if os.path.exists(filename):
        key_path = filename
    elif os.path.exists(dev_location):
        key_path = dev_location
    else:
        LOG.error(
            ('Could not load secret key file at: %s or %s. Please add your '
             'key to one of those locations.'),
            filename,
            dev_location
        )
        sys.exit('Killing service')

    with open(key_path, 'rb') as f:
        key = f.read()
예제 #4
0
import os
import sys

from cryptography.fernet import Fernet

from rift import config
from rift import log

LOG = log.get_logger()
cfg = config.get_config()
KEY = None


def load_secret_key(filename=cfg.general.key_file):
    dev_location = './etc/rift/secret.key'
    key_path = None
    if os.path.exists(filename):
        key_path = filename
    elif os.path.exists(dev_location):
        key_path = dev_location
    else:
        LOG.error(
            ('Could not load secret key file at: %s or %s. Please add your '
             'key to one of those locations.'), filename, dev_location)
        sys.exit('Killing service')

    with open(key_path, 'rb') as f:
        key = f.read()

    LOG.info('Loaded secret key file from: %s', key_path)
    return key