-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scripts to manage Samba DC service based on domain change event #39
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7b093f3
Add script to print bound domain list
stephdl 326bb78
Add script to reload Samba DC service based on domain change event
stephdl 85b2d07
Add command to print bound domain list in samba-dc.service
stephdl 5f7fecd
Add role delegation for list-modules to accountprovider
stephdl 5555c66
Add cluster module list to print-bound-domain-list script
stephdl 750ec5c
Add script to write user portal config file
stephdl 2b2cc32
Add api-moduled-overwrite.conf and remove print-bound-domain-list
stephdl 2302675
Update configure-module script to remove unnecessary code and improve…
stephdl 2de9790
Update service name in module-domain-changed event handler
stephdl 4a9dd55
Update user_manager_version to v0.7.0
stephdl 74dc22c
Refactor module filtering logic in write-user-portal-config script
stephdl e39b257
code review of Davide Principi on write-user-portal-config
stephdl 130d6ca
code review of Davide Principi on 10reload_services
stephdl c69680e
Remove unnecessary script to delegate role list-modules to accountpro…
stephdl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/bash | ||
|
||
# | ||
# Copyright (C) 2023 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
# we want to delegate the role list-modules to the accountprovider | ||
/usr/local/agent/bin/redis-exec SADD "${AGENT_ID}/roles/accountprovider" "list-modules" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright (C) 2023 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
import sys | ||
import json | ||
import agent | ||
import agent.tasks | ||
import os | ||
import json | ||
|
||
|
||
agent_install_dir = os.environ['AGENT_INSTALL_DIR'] | ||
# realm is mandatory we do not need to test it | ||
realm = os.environ["REALM"].lower() | ||
|
||
# Get the list of modules that have the realm in the list of modules | ||
stephdl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with agent.redis_connect(use_replica=True) as rdb: | ||
modules_set = set() | ||
for key, value in rdb.hscan_iter("cluster/module_domains"): | ||
stephdl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Iterate over the value and push each keys into modules_set | ||
for element in value.split(): | ||
if element.lower() == realm: | ||
stephdl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# remove string numbers from the key sogo1 -> sogo | ||
modules_set.add(key.rstrip('0123456789')) | ||
|
||
# Parse the response and compare the id with the modules_set | ||
stephdl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
response = agent.tasks.run(agent_id='cluster', action='list-modules', data=None) | ||
names_set=set() | ||
for item in response['output']: | ||
if item.get('id') in modules_set: | ||
names_set.add(item.get('name')) | ||
|
||
# Write modules set to a JSON file | ||
data = {"domain": realm, "services": list(names_set)} | ||
|
||
with open(f'{agent_install_dir}/api-moduled/public/config.json', 'w') as file: | ||
json.dump(data, file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Copyright (C) 2023 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
import os | ||
import sys | ||
import json | ||
import agent | ||
|
||
|
||
|
||
event = json.load(sys.stdin) | ||
if not os.environ["REALM"].lower() in [domain.lower() for domain in event["domains"]]: | ||
stephdl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sys.exit(0) | ||
|
||
agent.run_helper('systemctl', '--user', 'try-reload-or-restart', 'api-moduled.service').check_returncode() | ||
stephdl marked this conversation as resolved.
Show resolved
Hide resolved
|
2 changes: 2 additions & 0 deletions
2
imageroot/systemd/user/api-moduled.service.d/api-moduled-overwrite.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[Service] | ||
ExecStartPre=runagent write-user-portal-config |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Role definition and update must be moved to the core, to PR NethServer/ns8-core#545. This step can be removed.