Skip to content

Commit

Permalink
Add cluser API stub
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidePrincipi committed Dec 28, 2023
1 parent 9280d4d commit 1e3f276
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/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"]

# TODO: 1) store the new relation records in Redis
# 2) raise the event
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
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ if errors > 0:

with agent.redis_connect(privileged=True) as rdb:
rdb.delete(f"cluster/counters_cache/users/{kdom}", f"cluster/counters_cache/groups/{kdom}")

# TODO: remove SET items matching kdom from cluster/module_domain
# TODO: raise module-domain-changed
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ rdb.srem('cluster/favorites', module_id)
rdb.delete(f'cluster/authorizations/module/{module_id}')
rdb.hdel('cluster/module_node', module_id)

# TODO: remove SET items matching module_id from cluster/module_domain

# Revoke module permissions, clean up permissions of other modules
rdb.delete(f'roles/module/{module_id}')
permpipe = rdb.pipeline()
Expand All @@ -131,7 +133,7 @@ trx.publish(agent_id + '/event/module-removed', json.dumps({
'module': module_id,
'node': node_id,
}))

# TODO: raise module-domain-changed
trx.execute()

json.dump({}, fp=sys.stdout)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/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"]

# TODO: 1) clear the relation records from Redis
# 2) raise the event
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ubind-user-domains-input",
"$id": "http://schema.nethserver.org/cluster/ubind-user-domains-input.json",
"description": "Input schema of the ubind-user-domains action",
"examples": [
{
"domains": [
"mydom.test"
]
}
],
"type": "object",
"required": [
"domains"
],
"properties": {
"domains": {
"description": "One or more domains to ubind from the module calling this action",
"type": "array",
"minItems": 1,
"items": {
"description": "A user domain name",
"type": "string",
"minLength": 1
}
}
}
}

0 comments on commit 1e3f276

Please sign in to comment.