chore: Stub out how the kernel will be configured, and connect transports and storage
Change-Id: Ib92e4f7914688a60f81e078de4da32f11067b80c Implements: blueprint endpoints
This commit is contained in:
parent
96baf5cde3
commit
01ad3f1a8f
42
bin/marconi-self-host
Normal file
42
bin/marconi-self-host
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2012 Rackspace, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Bootstrap for self-hosting a Marconi node
|
||||
|
||||
Alternatively, for hosting a WSGI app with an external server, configure
|
||||
kernel with the WSGI transport and export the WSGI app callable, e.g.:
|
||||
|
||||
logging.config.fileConfig(logging_conf_file)
|
||||
kernel = Kernel(conf_file)
|
||||
|
||||
app = kernel.transport.app
|
||||
|
||||
"""
|
||||
|
||||
import logging.config
|
||||
from marconi.common import Kernel
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# @todo Parse command-line args
|
||||
logging_config_file = '/etc/marconi/logging.conf'
|
||||
config_file = '/etc/marconi/marconi.conf'
|
||||
|
||||
logging.config.fileConfig(logging_config_file)
|
||||
kernel = Kernel(config_file)
|
||||
kernel.run()
|
62
etc/logging.conf-sample
Normal file
62
etc/logging.conf-sample
Normal file
@ -0,0 +1,62 @@
|
||||
; Loaded via logging.config.fileConfig
|
||||
; @todo Customize for Marconi loggers
|
||||
|
||||
[loggers]
|
||||
keys=root
|
||||
|
||||
[handlers]
|
||||
keys=production,file,devel
|
||||
|
||||
[formatters]
|
||||
keys=minimal,normal,debug
|
||||
|
||||
|
||||
###########
|
||||
# Loggers #
|
||||
###########
|
||||
|
||||
[logger_root]
|
||||
level=WARNING
|
||||
handlers=file
|
||||
|
||||
[logger_access]
|
||||
level=INFO
|
||||
qualname=access
|
||||
handlers=access_file
|
||||
|
||||
|
||||
################
|
||||
# Log Handlers #
|
||||
################
|
||||
|
||||
[handler_production]
|
||||
class=handlers.SysLogHandler
|
||||
level=ERROR
|
||||
formatter=normal
|
||||
args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
|
||||
|
||||
[handler_file]
|
||||
class=handlers.WatchedFileHandler
|
||||
level=WARNING
|
||||
formatter=normal
|
||||
args=('error.log',)
|
||||
|
||||
[handler_devel]
|
||||
class=StreamHandler
|
||||
level=NOTSET
|
||||
formatter=debug
|
||||
args=(sys.stdout,)
|
||||
|
||||
|
||||
##################
|
||||
# Log Formatters #
|
||||
##################
|
||||
|
||||
[formatter_minimal]
|
||||
format=%(message)s
|
||||
|
||||
[formatter_normal]
|
||||
format=(%(name)s): %(asctime)s %(levelname)s %(message)s
|
||||
|
||||
[formatter_debug]
|
||||
format=(%(name)s): %(asctime)s %(levelname)s %(module)s %(funcName)s %(message)s
|
13
etc/marconi.conf-sample
Normal file
13
etc/marconi.conf-sample
Normal file
@ -0,0 +1,13 @@
|
||||
[drivers]
|
||||
;transport = wsgi, zmq
|
||||
transport = wsgi
|
||||
storage = mongodb
|
||||
|
||||
[drivers:transport:wsgi]
|
||||
port = 8888
|
||||
|
||||
;[drivers:transport:zmq]
|
||||
;port = 9999
|
||||
|
||||
[drivers:storage:mongodb]
|
||||
uri = mongodb://db1.example.net,db2.example.net:2500/?replicaSet=test&ssl=true&w=majority
|
42
marconi/common/kernel.py
Normal file
42
marconi/common/kernel.py
Normal file
@ -0,0 +1,42 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2012 Rackspace, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Defines the Marconi Kernel
|
||||
|
||||
The Kernel loads up drivers per a given configuration, and manages their
|
||||
lifetimes.
|
||||
|
||||
"""
|
||||
|
||||
from ConfigParser import SafeConfigParser
|
||||
|
||||
import marconi.transport.wsgi as wsgi
|
||||
import marconi.storage.mongodb as mongodb
|
||||
|
||||
|
||||
class Kernel(object):
|
||||
|
||||
def __init__(self, config_file):
|
||||
# @todo error handling
|
||||
cfg = SafeConfigParser()
|
||||
cfg.read(config_file)
|
||||
|
||||
# @todo Determine driver types from cfg
|
||||
self.storage = mongodb.Driver(cfg)
|
||||
self.transport = wsgi.Driver(self.storage, cfg)
|
||||
|
||||
def run(self):
|
||||
self.transport.listen()
|
Loading…
Reference in New Issue
Block a user