Commit 86029922 authored by Xavier Thompson's avatar Xavier Thompson

WIP

parent aad2d3f3
......@@ -449,31 +449,36 @@ class StandaloneSlapOS(object):
# buildout
self._slapos_bin = slapos_bin
self._slapos_commands = {
'slapos-node-software': {
# Commands that can't be daemonized in supervisord because they require dynamic arguments
self._slapos_custom_commands = {
'slapos-node-software-only': {
'command':
'{self._slapos_bin} node software --cfg {self._slapos_config} {debug_args}',
'{self._slapos_bin} node software --cfg {self._slapos_config} --only-sr {only_sr} {debug_args}',
'debug_args':
'-v --buildout-debug',
'stdout_logfile':
'{self._log_directory}/slapos-node-software.log',
},
'slapos-node-software-all': {
}
self._slapos_commands = {
'slapos-node-software': {
'command':
'{self._slapos_bin} node software --cfg {self._slapos_config} --all {debug_args}',
'{self._slapos_bin} node software --cfg {self._slapos_config} {debug_args}',
'debug_args':
'-v --buildout-debug',
'stdout_logfile':
'{self._log_directory}/slapos-node-software.log',
},
'slapos-node-software-only': {
'slapos-node-software-all': {
'command':
'{self._slapos_bin} node software --cfg {self._slapos_config} --only-sr {only_sr} {debug_args}',
'{self._slapos_bin} node software --cfg {self._slapos_config} --all {debug_args}',
'debug_args':
'-v --buildout-debug',
'stdout_logfile':
'{self._log_directory}/slapos-node-software.log',
},
'slapos-node-instance': {
'command':
'{self._slapos_bin} node instance --cfg {self._slapos_config} {debug_args}',
......@@ -909,7 +914,23 @@ class StandaloneSlapOS(object):
raise SlapOSNodeReportError(*e.args)
def _runSlapOSCommand(
self, command, max_retry=0, debug=False, error_lines=30, **kwargs):
self, command, max_retry=0, debug=False, error_lines=30, debug_args='', **kwargs):
try:
prog = self._slapos_custom_commands[command]
except KeyError:
pass
else:
command = prog['command'].format(**dict(locals(), **kwargs))
try:
subprocess.check_output(command, stderr=subprocess.STDOUT)
return
except subprocess.CalledProcessError as e:
raise SlapOSNodeCommandError({
'output': e.output,
'exitstatus': e.returncode,
})
if debug:
prog = self._slapos_commands[command]
# used in format(**locals()) below
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment