Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tidy up config situation

  • Loading branch information...
commit 9edb8f702bcb23245dcfc449ff768a595fe034d2 1 parent ca3ca92
@oldpatricka oldpatricka authored
View
13 deployments/one_pd_one_eea.yml
@@ -1,11 +1,12 @@
process-dispatchers:
pd_0:
- logfile: /tmp/pd_0.log
- engines:
- default:
- deployable_type: eeagent
- slots: 4
- base_need: 1
+ config:
+ processdispatcher:
+ engines:
+ default:
+ deployable_type: eeagent
+ slots: 4
+ base_need: 1
nodes:
nodeone:
dt: eeagent
View
1  epuharness/config/epuharness.yml
@@ -8,6 +8,7 @@ server:
heartbeat: 30
exchange: default_dashi_exchange
epuharness:
+ logdir: /tmp
pidantic_dir: /tmp/SupD/epuharness
dashi:
topic: epu-harness
View
17 epuharness/deployment.py
@@ -5,12 +5,13 @@
DEFAULT_DEPLOYMENT = """---
process-dispatchers:
pd_0:
- logfile: /tmp/pd_0.log
- engines:
- default:
- deployable_type: eeagent
- slots: 4
- base_need: 1
+ config:
+ processdispatcher:
+ engines:
+ default:
+ deployable_type: eeagent
+ slots: 4
+ base_need: 1
nodes:
nodeone:
dt: eeagent
@@ -25,10 +26,6 @@
provisioner:
default_user: default
dtrs: epu.localdtrs.LocalDTRS
- logging:
- handlers:
- file:
- filename: /tmp/provisioner_0.log
epums:
epum_0:
config:
View
77 epuharness/harness.py
@@ -35,6 +35,7 @@ def __init__(self, exchange=None, pidantic_dir=None, amqp_uri=None, config=None)
config_files.append(config)
self.CFG = bootstrap.configure(config_files)
+ self.logdir = self.CFG.epuharness.logdir
self.pidantic_dir = pidantic_dir or self.CFG.epuharness.pidantic_dir
self.exchange = exchange or self.CFG.server.amqp.get('exchange', None) or str(uuid.uuid4())
self.CFG.server.amqp.exchange = self.exchange
@@ -148,8 +149,7 @@ def start(self, deployment_file=None, deployment_str=None):
# Start Process Dispatchers
self.process_dispatchers = deployment.get('process-dispatchers', {})
for pd_name, pd in self.process_dispatchers.iteritems():
- self._start_process_dispatcher(pd_name, pd.get('engines', {}),
- logfile=pd.get('logfile'))
+ self._start_process_dispatcher(pd_name, pd.get('config', {}))
# Start Nodes and EEAgents
@@ -184,7 +184,7 @@ def _start_epum(self, name, config,
log.info("Starting EPUM '%s'" % name)
- config_file = self._build_epum_config(self.exchange, config)
+ config_file = self._build_epum_config(name, self.exchange, config)
cmd = "%s %s" % (exe_name, config_file)
log.debug("Running command '%s'" % cmd)
@@ -192,11 +192,31 @@ def _start_epum(self, name, config,
directory=self.pidantic_dir)
pid.start()
- def _build_epum_config(self, exchange, config):
+ def _build_epum_config(self, name, exchange, config, logfile=None):
+
+ if not logfile:
+ logfile = os.path.join(self.logdir, "%s.log" % name)
default = {
"server":{
- "exchange": exchange
+ 'amqp':{
+ 'exchange': exchange
+ }
+ },
+ 'logging': {
+ 'loggers': {
+ 'epumanagement': {
+ 'handlers': ['file', 'console']
+ }
+ },
+ 'handlers': {
+ 'file': {
+ 'filename': logfile,
+ }
+ },
+ 'root': {
+ 'handlers': ['file', 'console']
+ }
}
}
@@ -220,7 +240,7 @@ def _start_provisioner(self, name, config,
log.info("Starting Provisioner '%s'" % name)
- config_file = self._build_provisioner_config(self.exchange, config)
+ config_file = self._build_provisioner_config(name, self.exchange, config)
cmd = "%s %s" % (exe_name, config_file)
log.debug("Running command '%s'" % cmd)
@@ -228,13 +248,31 @@ def _start_provisioner(self, name, config,
directory=self.pidantic_dir)
pid.start()
- def _build_provisioner_config(self, exchange, config):
+ def _build_provisioner_config(self, name, exchange, config, logfile=None):
+
+ if not logfile:
+ logfile = os.path.join(self.logdir, "%s.log" % name)
default = {
- "server":{
+ 'server':{
"exchange": exchange
},
- "provisioner":{
+ 'provisioner':{
+ },
+ 'logging': {
+ 'loggers': {
+ 'provisioner': {
+ 'handlers': ['file', 'console']
+ }
+ },
+ 'handlers': {
+ 'file': {
+ 'filename': logfile,
+ }
+ },
+ 'root': {
+ 'handlers': ['file', 'console']
+ }
}
}
@@ -254,12 +292,12 @@ def _build_provisioner_config(self, exchange, config):
return config_filename
- def _start_process_dispatcher(self, name, engines, logfile=None,
+ def _start_process_dispatcher(self, name, config, logfile=None,
exe_name="epu-processdispatcher-service"):
"""Starts a process dispatcher with SupervisorD
@param name: Name of process dispatcher to start
- @param engines: a dictionary of eeagent configs. Same format as the
+ @param config: a dictionary in the same format as the
Process Dispatcher config file
@param exe_name: the name of the process dispatcher executable
"""
@@ -267,7 +305,7 @@ def _start_process_dispatcher(self, name, engines, logfile=None,
log.info("Starting Process Dispatcher '%s'" % name)
config_file = self._build_process_dispatcher_config(self.exchange,
- name, engines, logfile=logfile)
+ name, config, logfile=logfile)
cmd = "%s %s" % (exe_name, config_file)
log.debug("Running command '%s'" % cmd)
@@ -276,7 +314,7 @@ def _start_process_dispatcher(self, name, engines, logfile=None,
pid.start()
- def _build_process_dispatcher_config(self, exchange, name, engines,
+ def _build_process_dispatcher_config(self, exchange, name, config,
logfile=None, static_resources=True):
"""Builds a yaml config file to feed to the process dispatcher
@@ -288,14 +326,13 @@ def _build_process_dispatcher_config(self, exchange, name, engines,
@param logfile: the log file for the Process Dispatcher
"""
if not logfile:
- logfile = "/dev/null"
- config = {
+ logfile = os.path.join(self.logdir, "%s.log" % name)
+ default = {
'server': {
'amqp': self.amqp_cfg,
},
'processdispatcher': {
'topic': name,
- 'engines': engines,
'static_resources': static_resources,
},
'logging': {
@@ -314,11 +351,13 @@ def _build_process_dispatcher_config(self, exchange, name, engines,
}
}
}
- config['server']['amqp']['exchange'] = exchange
+ default['server']['amqp']['exchange'] = exchange
- config_yaml = yaml.dump(config)
+ merged_config = dict_merge(default, config)
- (os_handle, config_filename) = tempfile.mkstemp(suffix='.yml')
+ config_yaml = yaml.dump(merged_config)
+
+ (os_handle, config_filename) = tempfile.mkstemp(prefix="%s_" % name, suffix='.yml')
os.write(os_handle, config_yaml)
os.close(os_handle)
Please sign in to comment.
Something went wrong with that request. Please try again.