Beispiel #1
0
    def test_get_container_names(self):
        # Use default values
        self.assertEqual(
            {'storlet': 'storlet', 'dependency': 'dependency',
             'log': 'storletlog'},
            get_container_names({}))

        # Use explicit values
        self.assertEqual(
            {'storlet': 'conta', 'dependency': 'contb', 'log': 'contc'},
            get_container_names(
                {'storlet_container': 'conta',
                 'storlet_dependency': 'contb',
                 'storlet_logcontainer': 'contc'}))
Beispiel #2
0
def filter_factory(global_conf, **local_conf):
    conf = global_conf.copy()
    conf.update(local_conf)

    module_name = conf.get('storlet_gateway_module', 'stub')
    gateway_class = load_gateway(module_name)
    conf['gateway_module'] = gateway_class

    configParser = ConfigParser.RawConfigParser()
    configParser.read(
        conf.get('storlet_gateway_conf',
                 '/etc/swift/storlet_stub_gateway.conf'))
    gateway_conf = dict(configParser.items("DEFAULT"))

    # TODO(eranr): Add supported storlets languages and
    #  supported storlet API version
    containers = get_container_names(conf)
    swift_info = {
        'storlet_container': containers['storlet'],
        'storlet_dependency': containers['dependency'],
        'storlet_gateway_class': gateway_class.__name__
    }
    register_swift_info('storlet_handler', False, **swift_info)

    def storlet_handler_filter(app):
        return StorletHandlerMiddleware(app, conf, gateway_conf)

    return storlet_handler_filter
Beispiel #3
0
    def test_get_container_names(self):
        # Use default values
        self.assertEqual(
            {
                'storlet': 'storlet',
                'dependency': 'dependency',
                'log': 'storletlog'
            }, get_container_names({}))

        # Use explicit values
        self.assertEqual(
            {
                'storlet': 'conta',
                'dependency': 'contb',
                'log': 'contc'
            },
            get_container_names({
                'storlet_container': 'conta',
                'storlet_dependency': 'contb',
                'storlet_logcontainer': 'contc'
            }))
Beispiel #4
0
def filter_factory(global_conf, **local_conf):
    conf = global_conf.copy()
    conf.update(local_conf)

    module_name = conf.get('storlet_gateway_module', 'stub')
    gateway_class = load_gateway(module_name)
    conf['gateway_module'] = gateway_class

    configParser = ConfigParser.RawConfigParser()
    configParser.read(conf.get('storlet_gateway_conf',
                               '/etc/swift/storlet_stub_gateway.conf'))
    gateway_conf = dict(configParser.items("DEFAULT"))

    # TODO(eranr): Add supported storlets languages and
    #  supported storlet API version
    containers = get_container_names(conf)
    swift_info = {'storlet_container': containers['storlet'],
                  'storlet_dependency': containers['dependency'],
                  'storlet_gateway_class': gateway_class.__name__}
    register_swift_info('storlet_handler', False, **swift_info)

    def storlet_handler_filter(app):
        return StorletHandlerMiddleware(app, conf, gateway_conf)
    return storlet_handler_filter