Commit 573e0671 authored by Xavier Thompson's avatar Xavier Thompson

slap/standalone: Add `slapos_bin` option

By default standalone will use the `slapos` executable in PATH.
This option allows a specific slapos binary to be used instead.
parent 6a988671
...@@ -136,7 +136,7 @@ class SupervisorConfigWriter(ConfigWriter): ...@@ -136,7 +136,7 @@ class SupervisorConfigWriter(ConfigWriter):
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[program:slapos-proxy] [program:slapos-proxy]
command = slapos proxy start --cfg {standalone_slapos._slapos_config} --verbose command = {standalone_slapos._slapos_bin} proxy start --cfg {standalone_slapos._slapos_config} --verbose
startretries = 0 startretries = 0
startsecs = 0 startsecs = 0
redirect_stderr = true redirect_stderr = true
...@@ -227,7 +227,7 @@ class SlapOSCommandWriter(ConfigWriter): ...@@ -227,7 +227,7 @@ class SlapOSCommandWriter(ConfigWriter):
#!/bin/sh #!/bin/sh
SLAPOS_CONFIGURATION={self._standalone_slapos._slapos_config} \\ SLAPOS_CONFIGURATION={self._standalone_slapos._slapos_config} \\
SLAPOS_CLIENT_CONFIGURATION=$SLAPOS_CONFIGURATION \\ SLAPOS_CLIENT_CONFIGURATION=$SLAPOS_CONFIGURATION \\
exec slapos "$@" exec {self._standalone_slapos._slapos_bin} "$@"
""").format(**locals())) """).format(**locals()))
os.chmod(path, 0o755) os.chmod(path, 0o755)
...@@ -317,6 +317,7 @@ class StandaloneSlapOS(object): ...@@ -317,6 +317,7 @@ class StandaloneSlapOS(object):
instance_root=None, instance_root=None,
shared_part_root=None, shared_part_root=None,
partition_forward_configuration=(), partition_forward_configuration=(),
slapos_bin='slapos',
): ):
# type: (str, str, int, str, Iterable[str], Optional[str], Optional[str], Optional[str], Iterable[Union[PartitionForwardConfiguration, PartitionForwardAsPartitionConfiguration]]) -> None # type: (str, str, int, str, Iterable[str], Optional[str], Optional[str], Optional[str], Iterable[Union[PartitionForwardConfiguration, PartitionForwardAsPartitionConfiguration]]) -> None
"""Constructor, creates a standalone slapos in `base_directory`. """Constructor, creates a standalone slapos in `base_directory`.
...@@ -330,6 +331,7 @@ class StandaloneSlapOS(object): ...@@ -330,6 +331,7 @@ class StandaloneSlapOS(object):
* `instance_root` -- directory to create instances, default to "inst" in `base_directory` * `instance_root` -- directory to create instances, default to "inst" in `base_directory`
* `shared_part_root` -- directory to hold shared parts software, default to "shared" in `base_directory`. * `shared_part_root` -- directory to hold shared parts software, default to "shared" in `base_directory`.
* `partition_forward_configuration` -- configuration of partition request forwarding to external SlapOS master. * `partition_forward_configuration` -- configuration of partition request forwarding to external SlapOS master.
* `slapos_bin` -- slapos executable to use, default to "slapos" (thus depending on the runtime PATH).
Error cases: Error cases:
* `PathTooDeepError` when `base_directory` is too deep. Because of limitation * `PathTooDeepError` when `base_directory` is too deep. Because of limitation
...@@ -347,10 +349,12 @@ class StandaloneSlapOS(object): ...@@ -347,10 +349,12 @@ class StandaloneSlapOS(object):
self._shared_part_list = list(shared_part_list) self._shared_part_list = list(shared_part_list)
self._partition_forward_configuration = list(partition_forward_configuration) self._partition_forward_configuration = list(partition_forward_configuration)
self._slapos_bin = slapos_bin
self._slapos_commands = { self._slapos_commands = {
'slapos-node-software': { 'slapos-node-software': {
'command': 'command':
'slapos node software --cfg {self._slapos_config} --all {debug_args}', '{self._slapos_bin} node software --cfg {self._slapos_config} --all {debug_args}',
'debug_args': 'debug_args':
'-v --buildout-debug', '-v --buildout-debug',
'stdout_logfile': 'stdout_logfile':
...@@ -358,7 +362,7 @@ class StandaloneSlapOS(object): ...@@ -358,7 +362,7 @@ class StandaloneSlapOS(object):
}, },
'slapos-node-instance': { 'slapos-node-instance': {
'command': 'command':
'slapos node instance --cfg {self._slapos_config} --all {debug_args}', '{self._slapos_bin} node instance --cfg {self._slapos_config} --all {debug_args}',
'debug_args': 'debug_args':
'-v --buildout-debug', '-v --buildout-debug',
'stdout_logfile': 'stdout_logfile':
...@@ -366,7 +370,7 @@ class StandaloneSlapOS(object): ...@@ -366,7 +370,7 @@ class StandaloneSlapOS(object):
}, },
'slapos-node-report': { 'slapos-node-report': {
'command': 'command':
'slapos node report --cfg {self._slapos_config} {debug_args}', '{self._slapos_bin} node report --cfg {self._slapos_config} {debug_args}',
'stdout_logfile': 'stdout_logfile':
'{self._log_directory}/slapos-node-report.log', '{self._log_directory}/slapos-node-report.log',
}, },
...@@ -425,7 +429,7 @@ class StandaloneSlapOS(object): ...@@ -425,7 +429,7 @@ class StandaloneSlapOS(object):
bin_directory = os.path.join(base_directory, 'bin') bin_directory = os.path.join(base_directory, 'bin')
ensureDirectoryExists(bin_directory) ensureDirectoryExists(bin_directory)
self._slapos_bin = os.path.join(bin_directory, 'slapos') self._slapos_wrapper = os.path.join(bin_directory, 'slapos')
self._slapos_node_auto_bin = os.path.join(bin_directory, 'slapos-node-auto') self._slapos_node_auto_bin = os.path.join(bin_directory, 'slapos-node-auto')
self._log_directory = os.path.join(var_directory, 'log') self._log_directory = os.path.join(var_directory, 'log')
...@@ -443,7 +447,7 @@ class StandaloneSlapOS(object): ...@@ -443,7 +447,7 @@ class StandaloneSlapOS(object):
SupervisorConfigWriter(self).writeConfig(self._supervisor_config) SupervisorConfigWriter(self).writeConfig(self._supervisor_config)
SlapOSConfigWriter(self).writeConfig(self._slapos_config) SlapOSConfigWriter(self).writeConfig(self._slapos_config)
SlapOSCommandWriter(self).writeConfig(self._slapos_bin) SlapOSCommandWriter(self).writeConfig(self._slapos_wrapper)
SlapOSNodeAutoWriter(self).writeConfig(self._slapos_node_auto_bin) SlapOSNodeAutoWriter(self).writeConfig(self._slapos_node_auto_bin)
self.start() self.start()
......
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