Skip to content

Commit

Permalink
More logs
Browse files Browse the repository at this point in the history
  • Loading branch information
arturo-seijas committed Dec 10, 2024
1 parent 9d761a5 commit 0e073d8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,21 @@ def reconcile(self, _: ops.HookEvent) -> None:
container.replan()

if self.state.unconfigured_api_users:
logger.debug("Unconfigured API users %s", self.state.unconfigured_api_users)
# Current credentials that will be updated on every successful operation
credentials = self.state.api_credentials
token = wazuh.authenticate_user("wazuh", WAZUH_USERS["wazuh"]["default_password"])
for username, details in self.state.unconfigured_api_users:
logger.debug("Configuring API user %s", username)
password = wazuh.generate_api_password()
# The user has already been created when installing
if details["default"]:
wazuh.change_api_password(username, password, token)
logger.debug("Changed API user %s", username)
# The user is new
else:
wazuh.create_readonly_api_user(username, password, token)
logger.debug("Created API user %s", username)
# Store the new credentials longside the existing ones
credentials[username] = password
self.app.add_secret(credentials, label=WAZUH_API_CREDENTIALS)
Expand Down

0 comments on commit 0e073d8

Please sign in to comment.