Beispiel #1
0
    def test_logging_handler(self):
        self.simulate_get("/v1.0/", headers=self._hdrs)

        # NOTE(TheSriram): Create a new LOG handler, and make sure the
        # the next time we try to create one, we receive the one created
        # earlier.

        LOG_new = logging.getLogger(__name__)
        LOG_exists = logging.getLogger(__name__)

        self.assertEqual(LOG_new, LOG_exists)
Beispiel #2
0
    def test_logging_handler(self):
        self.simulate_get('/v1.0/', headers=self._hdrs)

        # NOTE(TheSriram): Create a new LOG handler, and make sure the
        # the next time we try to create one, we receive the one created
        # earlier.

        LOG_new = logging.getLogger(__name__)
        LOG_exists = logging.getLogger(__name__)

        self.assertEqual(LOG_new, LOG_exists)
Beispiel #3
0
    def test_logging_requestid(self):
        self.simulate_get("/v1.0/", headers=self._hdrs)

        LOG = logging.getLogger(__name__)

        with LogCapture() as capture:
            LOG.info("Testing Request ID")

        self.assertTrue(self._testuuid(capture.records[0].request_id))
Beispiel #4
0
    def test_logging_requestid(self):
        self.app.get('/v1.0/', headers=self._hdrs, expect_errors=True)

        LOG = logging.getLogger(__name__)

        with LogCapture() as capture:
            LOG.info("Testing Request ID")

        self.assertTrue(self._testuuid(capture.records[0].request_id))
Beispiel #5
0
    def test_logging_requestid(self):
        self.simulate_get('/v1.0/', headers=self._hdrs)

        LOG = logging.getLogger(__name__)

        with LogCapture() as capture:
            LOG.info("Testing Request ID")

        self.assertTrue(self._testuuid(capture.records[0].request_id))
Beispiel #6
0
    def listen(self):
        """Self-host using 'bind' and 'port' from deuce conf"""
        msgtmpl = (u'Serving on host %(bind)s:%(port)s')
        logger = logging.getLogger(__name__)
        logger.info(msgtmpl,
                    {'bind': conf.server.host, 'port': conf.server.port})

        httpd = simple_server.make_server(conf.server.host,
                                          conf.server.port,
                                          self.app)
        httpd.serve_forever()
Beispiel #7
0
    def listen(self):
        """Self-host using 'bind' and 'port' from deuce conf"""
        msgtmpl = (u'Serving on host %(bind)s:%(port)s')
        logger = logging.getLogger(__name__)
        logger.info(msgtmpl, {
            'bind': conf.server.host,
            'port': conf.server.port
        })

        httpd = simple_server.make_server(conf.server.host, conf.server.port,
                                          self.app)
        httpd.serve_forever()
Beispiel #8
0
import falcon
import msgpack
import six
from six.moves.urllib.parse import urlparse, parse_qs
from stoplight import validate

import deuce
from deuce import conf
from deuce.drivers.metadatadriver import ConstraintError
from deuce.model import BlockStorage, Vault
from deuce.transport.validation import *
import deuce.transport.wsgi.errors as errors
from deuce.util import set_qs_on_url
import deuce.util.log as logging

logger = logging.getLogger(__name__)


class ItemResource(object):
    @validate(vault_id=VaultPutRule, storage_block_id=StorageBlockPutRule)
    def on_put(self, req, resp, vault_id, storage_block_id):
        """Note: This does not support PUT as it is read-only + DELETE
        """
        # PUT operations must go to /vaults/{vaultid}/blocks
        # instead of /vaults/{vaultid}/storage/blocks
        path = req.path

        path_parts = path.split('/')
        del path_parts[4]

        # If there exists a Block ID in Metadata then remove
Beispiel #9
0

import functools
import sys


import deuce.util.log as logging


LOG = logging.getLogger(__name__)


def _fail(returncode, ex):
    """Handles terminal errors.

    :param returncode: process return code to pass to sys.exit
    :param ex: the error that occurred
    """

    LOG.exception(ex)
    sys.exit(returncode)


def runnable(func):
    """Entry point wrapper.

    Note: This call blocks until the process is killed
          or interrupted.
    """

    @functools.wraps(func)
Beispiel #10
0
from deuce import conf

from deuce.drivers.blockstoragedriver import BlockStorageDriver

import hashlib
import importlib


from deuce.util import log

logger = log.getLogger(__name__)
from swiftclient.exceptions import ClientException

from six import BytesIO

import deuce


class SwiftStorageDriver(BlockStorageDriver):

    def __init__(self):
        self.lib_pack = importlib.import_module(
            conf.block_storage_driver.swift.swift_module)
        self.Conn = getattr(self.lib_pack, 'client')

    # =========== VAULTS ===============================

    def create_vault(self, vault_id):
        try:
            response = dict()
            self.Conn.put_container(
Beispiel #11
0
 def serve_forever(self):
     LOG = logging.getLogger(__name__)
     LOG.info("Mock Server - Started")
Beispiel #12
0
 def serve_forever(self):
     LOG = logging.getLogger(__name__)
     LOG.info("Mock Server - Started")
Beispiel #13
0
 def test_logging_withoutcontext(self):
     LOG = logging.getLogger(__name__)
     with LogCapture() as capture:
         LOG.info("Testing Request ID outside wsgi call")
     self.assertFalse(self._testuuid(capture.records[0].request_id))
Beispiel #14
0
 def test_logging_withoutcontext(self):
     LOG = logging.getLogger(__name__)
     with LogCapture() as capture:
         LOG.info("Testing Request ID outside wsgi call")
     self.assertFalse(self._testuuid(capture.records[0].request_id))