-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #545 from NethServer/feat-6814
Implement MM relation of modules and user domains
- Loading branch information
Showing
19 changed files
with
265 additions
and
6 deletions.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash | ||
|
||
echo -n $VAR1 | ||
echo -n "${VAR1}${AGENT_TASK_USER:?}" |
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
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
38 changes: 38 additions & 0 deletions
38
core/imageroot/var/lib/nethserver/cluster/actions/bind-user-domains/50bind_user_domains
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,38 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
import sys | ||
import json | ||
import agent | ||
import os | ||
|
||
request = json.load(sys.stdin) | ||
|
||
domain_list = request["domains"] | ||
module_id = os.environ["AGENT_TASK_USER"].removeprefix('module/') | ||
|
||
rdb = agent.redis_connect(privileged=False) | ||
try: | ||
test = int(rdb.hget(f'module/{module_id}/environment', 'NODE_ID')) | ||
except Exception as ex: | ||
print(f"Error: to validate a module_id instance {ex}", file=sys.stderr) | ||
sys.exit(0) | ||
|
||
previous_domains = rdb.hget(f'cluster/module_domains', module_id) or "" | ||
|
||
rdb = agent.redis_connect(privileged=True) | ||
rdb.hset(f'cluster/module_domains', module_id, " ".join(domain_list)) | ||
|
||
union_domains = set(domain_list) | set(previous_domains.split()) | ||
|
||
agent_id = os.environ['AGENT_ID'] | ||
trx = rdb.pipeline() | ||
trx.publish(agent_id + '/event/module-domain-changed', json.dumps({ | ||
"modules": [module_id], | ||
"domains": list(union_domains) | ||
})) | ||
trx.execute() |
29 changes: 29 additions & 0 deletions
29
core/imageroot/var/lib/nethserver/cluster/actions/bind-user-domains/validate-input.json
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,29 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "bind-user-domains-input", | ||
"$id": "http://schema.nethserver.org/cluster/bind-user-domains-input.json", | ||
"description": "Input schema of the bind-user-domains action", | ||
"examples": [ | ||
{ | ||
"domains": [ | ||
"mydom.test" | ||
] | ||
} | ||
], | ||
"type": "object", | ||
"required": [ | ||
"domains" | ||
], | ||
"properties": { | ||
"domains": { | ||
"description": "One or more domains to bind with the module calling this action", | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { | ||
"description": "A user domain name", | ||
"type": "string", | ||
"minLength": 1 | ||
} | ||
} | ||
} | ||
} |
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
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
14 changes: 14 additions & 0 deletions
14
core/imageroot/var/lib/nethserver/node/update-core.d/50update_grants
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,14 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
# | ||
|
||
import agent | ||
import cluster.grants | ||
|
||
rdb = agent.redis_connect(privileged=True) | ||
|
||
cluster.grants.grant(rdb, action_clause="bind-user-domains", to_clause="accountconsumer", on_clause='cluster') | ||
cluster.grants.grant(rdb, action_clause="list-modules", to_clause="accountprovider", on_clause='cluster') |
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
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