Let recon-cron work with conf.d

Change-Id: I862b74e0d9b20ba149581c1add6473dc1e5b2859
This commit is contained in:
Clay Gerrard 2018-01-10 15:53:06 -08:00
parent b0242f4fdc
commit 55a1b63db5

View File

@ -20,9 +20,8 @@ import os
import sys import sys
from gettext import gettext as _ from gettext import gettext as _
from six.moves.configparser import ConfigParser
from swift.common.utils import get_logger, dump_recon_cache from swift.common.utils import get_logger, dump_recon_cache, readconf
from swift.obj.diskfile import ASYNCDIR_BASE from swift.obj.diskfile import ASYNCDIR_BASE
@ -46,17 +45,13 @@ def get_async_count(device_dir, logger):
def main(): def main():
c = ConfigParser()
try: try:
conf_path = sys.argv[1] conf_path = sys.argv[1]
except Exception: except Exception:
print("Usage: %s CONF_FILE" % sys.argv[0].split('/')[-1]) print("Usage: %s CONF_FILE" % sys.argv[0].split('/')[-1])
print("ex: swift-recon-cron /etc/swift/object-server.conf") print("ex: swift-recon-cron /etc/swift/object-server.conf")
sys.exit(1) sys.exit(1)
if not c.read(conf_path): conf = readconf(conf_path, 'filter:recon')
print("Unable to read config file %s" % conf_path)
sys.exit(1)
conf = dict(c.items('filter:recon'))
device_dir = conf.get('devices', '/srv/node') device_dir = conf.get('devices', '/srv/node')
recon_cache_path = conf.get('recon_cache_path', '/var/cache/swift') recon_cache_path = conf.get('recon_cache_path', '/var/cache/swift')
recon_lock_path = conf.get('recon_lock_path', '/var/lock') recon_lock_path = conf.get('recon_lock_path', '/var/lock')