Skip to content

Commit

Permalink
Merge branch 'fix-booth-mode-pcs-0.10' into pcs-0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjelinek committed Jul 19, 2022
2 parents 1c6bf68 + f0b7b49 commit 025b3fe
Show file tree
Hide file tree
Showing 6 changed files with 767 additions and 972 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,7 +6,10 @@
- `pcs resource manage --monitor` no longer enables monitor operation for all
resources in a group if only one of the resources was requested to become
managed ([rhbz#1918527])
- Misleading error message from `pcs booth sync` when booth config directory
(`/etc/booth`) is missing ([rhbz#1791670])

[rhbz#1791670]: https://bugzilla.redhat.com/show_bug.cgi?id=1791670
[rhbz#1918527]: https://bugzilla.redhat.com/show_bug.cgi?id=1918527


Expand Down
10 changes: 10 additions & 0 deletions pcs/lib/booth/config_validators.py
Expand Up @@ -100,6 +100,16 @@ def remove_ticket(conf_facade, ticket_name):
return []


def ticket_options_normalization() -> validate.TypeNormalizeFunc:
return validate.option_value_normalization(
{
"mode": (
lambda value: value.lower() if isinstance(value, str) else value
)
}
)


def validate_ticket_name(ticket_name: str) -> reports.ReportItemList:
if not __TICKET_NAME_RE.search(ticket_name):
return [
Expand Down
14 changes: 11 additions & 3 deletions pcs/lib/commands/booth.py
Expand Up @@ -23,7 +23,10 @@
)
from pcs.common.services.errors import ManageServiceError
from pcs.common.str_tools import join_multilines
from pcs.lib import tools
from pcs.lib import (
tools,
validate,
)
from pcs.lib.booth import (
config_files,
config_validators,
Expand Down Expand Up @@ -329,17 +332,22 @@ def config_ticket_add(
booth_env = env.get_booth_env(instance_name)
try:
booth_conf = booth_env.config.read_to_facade()
options_pairs = validate.values_to_pairs(
options, config_validators.ticket_options_normalization()
)
report_processor.report_list(
config_validators.add_ticket(
booth_conf,
ticket_name,
options,
options_pairs,
allow_unknown_options=allow_unknown_options,
)
)
if report_processor.has_errors:
raise LibraryError()
booth_conf.add_ticket(ticket_name, options)
booth_conf.add_ticket(
ticket_name, validate.pairs_to_values(options_pairs)
)
booth_env.config.write_facade(booth_conf, can_overwrite=True)
except RawFileError as e:
report_processor.report(raw_file_error_report(e))
Expand Down

0 comments on commit 025b3fe

Please sign in to comment.