slapconfiguration: don't try to get slave schema if there are no slaves
Commit 4a593178 introduced a small but important change in behavior in slapconfiguration.
if validate.shared:
shared_list = options.pop('slave-instance-list')
+ shared_schema = self._getSharedSchema(software_description)
+ if shared_schema is None:
+ raise UserError(
+ "requested shared software-type %r seems to have no "
+ "JSON schema entry in the software.cfg.json."
+ )
validator = DefaultValidator(
- self._getSharedSchema(software_description),
+ shared_schema,
set_defaults.shared,
{'integer': int} if unstringify.shared else None,
) if shared_list else None # optimisation: skip creating unused validator
Before, _getSharedSchema
was only called in the positive branch of the conditional on the last line, i.e. if there were slaves.
Now, it's called earlier, even if there are no slaves. This has consequences for cases where a single SR contains multiple software types, some of which have slaves and some of which don't.
Say a SR has types a, a-slave, and b. The first two have name a
ad the second one has shared=True
. Requesting an a
will work, even with slaves, because there exists a shared software type with matching name. Requesting a b
will fail because it'll try to fetch the schema for b's slaves, which don't exist.