Skip to content

Commit

Permalink
configure & event: manage subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
gsanchietti committed Apr 12, 2024
1 parent 9567630 commit 3c1d048
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions imageroot/actions/configure-module/20configure
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ agent.assert_exp(response['exit_code'] == 0)
with open('config.json', 'w') as cfp:
cfp.write(json.dumps(config | request))

# Load subscription info
rdb = agent.redis_connect(privileged=False)
subscription = rdb.hgetall('cluster/subscription')

with open('config.env', 'w') as env:
env.write(f'ADMIN_USER={request["api_user"]}\n')
env.write(f'ADMIN_PASSWORD={request["api_password"]}\n')
Expand All @@ -111,6 +115,10 @@ with open('config.env', 'w') as env:
env.write(f'WEBSSH_PATH={config["webssh_path"]}/\n')
env.write(f'GRAFANA_PATH=/grafana\n')
env.write(f'DATA_DIR=/nethsecurity-api/data\n')
if subscription:
env.write(f'VALID_SUBSCRIPTION=true\n')
else:
env.write(f'VALID_SUBSCRIPTION=false\n')

server_address = request["ovpn_network"].removesuffix('.0') + '.1'
with open('promtail.env', 'w') as promtail:
Expand Down
19 changes: 19 additions & 0 deletions imageroot/actions/configure-module/30subscription
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 agent

rdb = agent.redis_connect(privileged=False)

subscription = rdb.hgetall('cluster/subscription')

with open('subscription.env', 'w') as env:
if subscription:
env.write(f'VALID_SUBSCRIPTION=true\n')
else:
env.write(f'VALID_SUBSCRIPTION=false\n')

1 change: 1 addition & 0 deletions imageroot/events/subscription-changed/30subscription
1 change: 1 addition & 0 deletions imageroot/events/subscription-changed/80start_services

0 comments on commit 3c1d048

Please sign in to comment.