Skip to content
Snippets Groups Projects
Commit 33ffc213 authored by Erik Reid's avatar Erik Reid
Browse files

take redis config from json file through env

parent fae6762b
No related branches found
No related tags found
No related merge requests found
import json
import logging
import os
import re
from celery import bootsteps, Task, states
......@@ -61,26 +62,19 @@ def _save_value_etree(key, xml_doc):
etree.tostring(xml_doc, encoding='unicode'))
class WorkerArgs(bootsteps.Step):
def __init__(self, worker, config_filename, **options):
with open(config_filename) as f:
logger = logging.getLogger(__name__)
logger.info(
"Initializing worker with config from: %r" % config_filename)
InventoryTask.config = config.load(f)
class LoadConfig(bootsteps.Step):
assert os.path.isfile(os.environ['INVENTORY_PROVIDER_CONFIG_FILENAME']), (
'config file %r not found' %
os.environ['INVENTORY_PROVIDER_CONFIG_FILENAME'])
with open(os.environ['INVENTORY_PROVIDER_CONFIG_FILENAME']) as f:
logging.info(
"Initializing worker with config from: %r" %
os.environ['INVENTORY_PROVIDER_CONFIG_FILENAME'])
InventoryTask.config = config.load(f)
def worker_args(parser):
parser.add_argument(
"--config_filename",
dest="config_filename",
action='store',
type=str,
help="Configuration filename")
app.user_options['worker'].add(worker_args)
app.steps['worker'].add(WorkerArgs)
app.steps['worker'].add(LoadConfig)
@app.task
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment