Skip to content

Commit a171cb2

Browse files
committed
refactor(ns8-join): query list-modules action each time bind is triggered
1 parent 47b8d40 commit a171cb2

File tree

2 files changed

+3
-20
lines changed
  • root/usr
    • sbin
    • share/nethesis/nethserver-ns8-migration/apps/nethserver-nethvoice14

2 files changed

+3
-20
lines changed

root/usr/sbin/ns8-join

-9
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,6 @@ else:
287287
account_provider_domain = ""
288288
account_provider_external = ""
289289

290-
# call list-modules to update the list of modules ans save it as a file
291-
list_modules_response = call(api_endpoint, "list-modules", payload['token'], None, False)
292-
if list_modules_response['data']['exit_code'] != 0:
293-
print("Task list-modules has failed:", list_modules_response, file=sys.stderr)
294-
subprocess.run(['/usr/sbin/ns8-leave']) # leave the cluster, we failed to connect to the external domain
295-
sys.exit(1)
296-
with open('/var/lib/nethserver/nethserver-ns8-migration/list-modules.json', 'w') as fp:
297-
json.dump(list_modules_response['data']['output'], fp)
298-
299290
with open('/var/lib/nethserver/nethserver-ns8-migration/environment', 'a') as fp:
300291
fp.write(f"USER_DOMAIN={account_provider_domain}\n")
301292
fp.write(f"ACCOUNT_PROVIDER_EXTERNAL={account_provider_external}\n")

root/usr/share/nethesis/nethserver-ns8-migration/apps/nethserver-nethvoice14/bind

+3-11
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,9 @@
2222

2323
set -e
2424

25-
# read list-modules.json
26-
JSON_FILE="/var/lib/nethserver/nethserver-ns8-migration/list-modules.json"
27-
28-
# Check if nethvoice-proxy > 0 on the node
29-
is_installed=$(jq -r --argjson node_id "$MODULE_NODE_ID" '
30-
.[] | select(.id == "nethvoice-proxy") | .install_destinations[] | select(.node_id == $node_id) | .instances > 0
31-
' "$JSON_FILE")
32-
33-
# if not installed in the node, install first nethvoice-proxy
34-
if [[ "$is_installed" == "false" ]]; then
35-
ns8-action --attach cluster add-module "$(printf '{"image": "nethvoice-proxy", "node": %d}' "${MODULE_NODE_ID}")"
25+
if ns8-action --attach cluster list-modules | jq -e --arg node_id "$MODULE_NODE_ID" '.[] | select(.id == "nethvoice-proxy") | .install_destinations[] | select(.node_id == ($node_id | tonumber) and .eligible == true)' > /dev/null; then
26+
echo "Collabora has at least one eligible destination"
27+
ns8-action --attach cluster add-module "$(printf '{"image": "nethvoice-proxy", "node": %d}' "${MODULE_NODE_ID}")"
3628
fi
3729

3830
ns8-bind-app nethserver-nethvoice14

0 commit comments

Comments
 (0)