1
2
3
4
5
6
7
8
9
10
11 from celery.loaders.base import BaseLoader
12 from zenoss.protocols.amqpconfig import AMQPConfig
13 from Products.ZenUtils.GlobalConfig import getGlobalConfiguration
14
15 from . import constants
16
17
19
20 override_backends = {
21 'zodb': 'Products.ZenUtils.celeryintegration.ZODBBackend'
22 }
23
29
31 """
32 Build a Celery configuration dictionary using global.conf.
33
34 This configuration may be overwritten or augmented later by a daemon.
35 """
36 globalCfg = getGlobalConfiguration()
37 amqpCfg = AMQPConfig()
38 amqpCfg.update(globalCfg)
39
40 config = {
41
42
43
44
45
46 constants.BROKER_HOST: amqpCfg.host,
47 constants.BROKER_PORT: amqpCfg.port,
48 constants.BROKER_USER: amqpCfg.user,
49 constants.BROKER_PASSWORD: amqpCfg.password,
50 constants.BROKER_VHOST: amqpCfg.vhost,
51 constants.BROKER_USE_SSL: amqpCfg.usessl,
52 constants.ACK_LATE: True,
53
54
55
56
57 constants.RESULT_BACKEND: 'zodb',
58
59
60
61
62
63
64 constants.MAX_TASKS_PER_PROCESS: 1,
65
66 constants.NUM_WORKERS: 2,
67
68
69
70
71
72
73 constants.USE_CELERY_LOGGING: False,
74
75 constants.LOG_FORMAT: "%(asctime)s %(levelname)s %(name)s: %(message)s",
76 constants.TASK_LOG_FORMAT: "%(asctime)s %(levelname)s zen.Job: %(message)s",
77
78 constants.STDOUT_LOG_LEVEL: 'INFO'
79 }
80 return config
81