Skip to content

software/slapos-master: add required software.cfg.json for client compatibility

Titouan Soulard requested to merge tsoulard/slapos:add-missing-schema into master

Description of the problem

Synopsis

Trying to launch a SlapOS Master would fail when using a parameter file. The command which caused the problem was the following: slapos request --state started --parameters-file ~/srv/project/request-parameter-slaposmaster.json slaposmaster ~/srv/project/slapos/software/slapos-master/software.cfg.

Cause

The root of this issue is that software/slapos-master does not contain a software.cfg.json, and JSON Schema is mandatory for using JSON-in-XML since MR #436 .

Proposed solution

Idea

The solution is quite obvious and involves creating a JSON Schema file for SlapOS Master. The only thing to do is to find the parameters to validate against.

1. Finding the parameters

Thinking that the parameters for SlapOS should be quite similar to the ones required for ERP5, I started by comparing stack/erp5/instance-erp5.cfg.in and software/slapos-master/instance-erp5.cfg.in, to find the parameters used by one and not the other. For the record, here is the command I ran and the terminal output:

# diff software/slapos-master/instance-erp5.cfg.in stack/erp5/instance-erp5.cfg.in | grep "slapparameter"
< {% set global_publisher_timeout = slapparameter_dict.get('publisher-timeout') -%}
> {% set global_publisher_timeout = slapparameter_dict.get('publisher-timeout', 300) -%}
< {% if slapparameter_dict.get('shared-certificate-authority-path', '') -%}
< ca-dir = {{ slapparameter_dict.get('shared-certificate-authority-path') }}
< country-code = {{ dumps(slapparameter_dict.get('country-code', 'ZZ')) }}
< email = {{ dumps(slapparameter_dict.get('email', 'nobody@example.com')) }}
< state = {{ dumps(slapparameter_dict.get('state', "('State',)")) }}
< city = {{ dumps(slapparameter_dict.get('city', 'City')) }}
< company = {{ dumps(slapparameter_dict.get('company', 'Compagny')) }}

Seems like the files are indeed quite similar, the missing parameters are linked to the SSL/TLS certificate.

2. Creating the schema

Therefore, I copied the software.cfg.json, instance-erp5-input-schema.json, instance-erp5-output-schema.json and schemas-definitions.json files from software/erp5 to software/slapos-master. The final step is to update the parameters in instance-erp5-input-schema.json according to the results of step (1). SlapOS Master now has the right definitions and can be ran with a --parameters-file argument.

Edited by Titouan Soulard

Merge request reports