updated config file loading to work with paste.deploy configs
This commit is contained in:
parent
e94faaff7f
commit
25c775516c
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from swift.account_stats import AccountStat
|
from swift.stats.account_stats import AccountStat
|
||||||
from swift.common import utils
|
from swift.common import utils
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -15,20 +15,23 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
from paste.deploy import appconfig
|
||||||
|
|
||||||
from swift.account.server import DATADIR as account_server_data_dir
|
from swift.account.server import DATADIR as account_server_data_dir
|
||||||
from swift.common.db import AccountBroker
|
from swift.common.db import AccountBroker
|
||||||
from swift.common.internal_proxy import InternalProxy
|
from swift.common.internal_proxy import InternalProxy
|
||||||
from swift.common.utils import renamer, get_logger
|
from swift.common.utils import renamer, get_logger, readconf
|
||||||
from swift.common.daemon import Daemon
|
from swift.common.daemon import Daemon
|
||||||
|
|
||||||
class AccountStat(Daemon):
|
class AccountStat(Daemon):
|
||||||
def __init__(self, stats_conf):
|
def __init__(self, stats_conf):
|
||||||
super(self, AccountStat).__init__(stats_conf)
|
super(AccountStat, self).__init__(stats_conf)
|
||||||
target_dir = stats_conf.get('log_dir', '/var/log/swift')
|
target_dir = stats_conf.get('log_dir', '/var/log/swift')
|
||||||
|
#TODO: figure out the server configs. also figure out internal_proxy
|
||||||
account_server_conf_loc = stats_conf.get('account_server_conf',
|
account_server_conf_loc = stats_conf.get('account_server_conf',
|
||||||
'/etc/swift/account-server.conf')
|
'/etc/swift/account-server.conf')
|
||||||
server_conf = utils.readconf(account_server_conf_loc, 'account-server')
|
server_conf = appconfig('config:%s' % account_server_conf_loc,
|
||||||
|
name='account-server')
|
||||||
filename_format = stats_conf['source_filename_format']
|
filename_format = stats_conf['source_filename_format']
|
||||||
self.filename_format = filename_format
|
self.filename_format = filename_format
|
||||||
self.target_dir = target_dir
|
self.target_dir = target_dir
|
||||||
|
@ -19,6 +19,7 @@ import time
|
|||||||
import datetime
|
import datetime
|
||||||
import cStringIO
|
import cStringIO
|
||||||
import collections
|
import collections
|
||||||
|
from paste.deploy import appconfig
|
||||||
|
|
||||||
from swift.common.internal_proxy import InternalProxy
|
from swift.common.internal_proxy import InternalProxy
|
||||||
from swift.common.exceptions import ChunkReadTimeout
|
from swift.common.exceptions import ChunkReadTimeout
|
||||||
@ -31,7 +32,8 @@ class LogProcessor(object):
|
|||||||
|
|
||||||
proxy_server_conf_loc = stats_conf.get('proxy_server_conf',
|
proxy_server_conf_loc = stats_conf.get('proxy_server_conf',
|
||||||
'/etc/swift/proxy-server.conf')
|
'/etc/swift/proxy-server.conf')
|
||||||
self.proxy_server_conf = readconf(proxy_server_conf_loc, 'proxy-server')
|
self.proxy_server_conf = appconfig('config:%s' % proxy_server_conf_loc,
|
||||||
|
name='proxy-server')
|
||||||
if isinstance(logger, tuple):
|
if isinstance(logger, tuple):
|
||||||
self.logger = get_logger(*logger)
|
self.logger = get_logger(*logger)
|
||||||
else:
|
else:
|
||||||
@ -192,7 +194,7 @@ class LogProcessor(object):
|
|||||||
|
|
||||||
class LogProcessorDaemon(Daemon):
|
class LogProcessorDaemon(Daemon):
|
||||||
def __init__(self, conf):
|
def __init__(self, conf):
|
||||||
super(self, LogProcessorDaemon).__init__(conf)
|
super(LogProcessorDaemon, stats).__init__(conf)
|
||||||
self.log_processor = LogProcessor(conf, self.logger)
|
self.log_processor = LogProcessor(conf, self.logger)
|
||||||
c = readconf(conf)
|
c = readconf(conf)
|
||||||
self.lookback_hours = int(c.get('lookback_hours', '120'))
|
self.lookback_hours = int(c.get('lookback_hours', '120'))
|
||||||
|
@ -19,6 +19,7 @@ import hashlib
|
|||||||
import time
|
import time
|
||||||
import gzip
|
import gzip
|
||||||
import glob
|
import glob
|
||||||
|
from paste.deploy import appconfig
|
||||||
|
|
||||||
from swift.common.internal_proxy import InternalProxy
|
from swift.common.internal_proxy import InternalProxy
|
||||||
from swift.common.daemon import Daemon
|
from swift.common.daemon import Daemon
|
||||||
@ -41,15 +42,15 @@ class LogUploader(Daemon):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, uploader_conf, plugin_name):
|
def __init__(self, uploader_conf, plugin_name):
|
||||||
super(self, LogUploader).__init__(uploader_conf)
|
super(LogUploader, self).__init__(uploader_conf)
|
||||||
log_dir = uploader_conf.get('log_dir', '/var/log/swift/')
|
log_dir = uploader_conf.get('log_dir', '/var/log/swift/')
|
||||||
swift_account = uploader_conf['swift_account']
|
swift_account = uploader_conf['swift_account']
|
||||||
container_name = uploader_conf['container_name']
|
container_name = uploader_conf['container_name']
|
||||||
source_filename_format = uploader_conf['source_filename_format']
|
source_filename_format = uploader_conf['source_filename_format']
|
||||||
proxy_server_conf_loc = uploader_conf.get('proxy_server_conf',
|
proxy_server_conf_loc = uploader_conf.get('proxy_server_conf',
|
||||||
'/etc/swift/proxy-server.conf')
|
'/etc/swift/proxy-server.conf')
|
||||||
proxy_server_conf = utils.readconf(proxy_server_conf_loc,
|
proxy_server_conf = appconfig('config:%s' % proxy_server_conf_loc,
|
||||||
'proxy-server')
|
name='proxy-server')
|
||||||
if not log_dir.endswith('/'):
|
if not log_dir.endswith('/'):
|
||||||
log_dir = log_dir + '/'
|
log_dir = log_dir + '/'
|
||||||
self.log_dir = log_dir
|
self.log_dir = log_dir
|
||||||
|
Loading…
Reference in New Issue
Block a user