Commit 49dac657 authored by Xavier Thompson's avatar Xavier Thompson

slap/standalone: Add slapos node software --only

Add a standalone method to build / remove a specified
list of softwares, using slapos node software --only.
parent 58d02eb6
......@@ -466,6 +466,14 @@ class StandaloneSlapOS(object):
'stdout_logfile':
'{self._log_directory}/slapos-node-software.log',
},
'slapos-node-software-only': {
'command':
'{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-instance': {
'command':
'{self._slapos_bin} node instance --cfg {self._slapos_config} {debug_args}',
......@@ -823,6 +831,35 @@ class StandaloneSlapOS(object):
except SlapOSNodeCommandError as e:
raise SlapOSNodeSoftwareError(*e.args)
def waitForSoftwareList(self, software_list, max_retry=0, debug=False, error_lines=30):
"""Synchronously install or uninstall all softwares in the given list.
This method retries on errors. If after `max_retry` times there's
still an error, the error is raised, containing `error_lines` of output
from the buildout command.
If `debug` is true, buildout is executed in the foreground, with flags to
drop in a debugger session if error occurs.
If `install_all` is true, all softwares will be installed, even the ones
for which the installation was already completed. This is equivalent to
running `slapos node software --all`.
Error cases:
* `SlapOSNodeSoftwareError` when buildout error while installing software.
* Unexpected `Exception` if unable to connect to embedded slap server.
"""
try:
return self._runSlapOSCommand(
'slapos-node-software-only',
max_retry=max_retry,
debug=debug,
error_lines=error_lines,
only_sr=','.join(software_list),
)
except SlapOSNodeCommandError as e:
raise SlapOSNodeSoftwareError(*e.args)
def waitForInstance(self, max_retry=0, debug=False, error_lines=30):
"""Instantiate all partitions previously requested for start.
......@@ -872,12 +909,12 @@ class StandaloneSlapOS(object):
raise SlapOSNodeReportError(*e.args)
def _runSlapOSCommand(
self, command, max_retry=0, debug=False, error_lines=30):
self, command, max_retry=0, debug=False, error_lines=30, **kwargs):
if debug:
prog = self._slapos_commands[command]
# used in format(**locals()) below
debug_args = prog.get('debug_args', '') # pylint: disable=unused-variable
command = prog['command'].format(**locals())
command = prog['command'].format(**dict(locals(), **kwargs))
try:
return subprocess.check_call(
command,
......
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