Skip to content

Commit

Permalink
quick_setup: workaround - save another password when saving quick set…
Browse files Browse the repository at this point in the history
…up with stored_passwords

When saving quick_setup objects, the password object from a previously
saved quick setup was being overwritten when selecting the store
password option. This workaround checks if it's a stored password and if
so replaced the password id to avoid this scenario.

CMK-19163

Change-Id: I8fdf424e0ea0216944474719cef571b208fafa13
  • Loading branch information
TribeGav committed Sep 24, 2024
1 parent 624d4de commit 332db48
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmk/gui/quick_setup/v0_unstable/predefined/_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from cmk.utils.global_ident_type import GlobalIdent, PROGRAM_ID_QUICK_SETUP
from cmk.utils.hostaddress import HostName
from cmk.utils.password_store import ad_hoc_password_id
from cmk.utils.password_store import Password as StorePassword
from cmk.utils.rulesets.definition import RuleGroup
from cmk.utils.rulesets.ruleset_matcher import RuleConditionsSpec, RuleOptionsSpec, RuleSpec
Expand Down Expand Up @@ -233,6 +234,19 @@ def _create_and_save_special_agent_bundle(
site_selection = _find_unique_id(all_stages_form_data, "site_selection")
site_id = SiteId(site_selection) if site_selection else omd_site()
params = collect_params(all_stages_form_data, parameter_form)

# TODO: Find a better solution.
# Here we replace the password id if the user has selected from password store
# otherwise, the previous one will be overwritten.
if all_stages_form_data[FormSpecId("credentials")]["secret_access_key"][1] == "stored_password":
all_stages_form_data[FormSpecId("credentials")]["secret_access_key"] = (
"explicit_password",
all_stages_form_data[FormSpecId("credentials")]["secret_access_key"][1],
(
ad_hoc_password_id(),
all_stages_form_data[FormSpecId("credentials")]["secret_access_key"][2][1],
),
)
passwords = _collect_passwords_from_form_data(all_stages_form_data, parameter_form)

# TODO: DCD still to be implemented cmk-18341
Expand Down

0 comments on commit 332db48

Please sign in to comment.