Skip to content

Commit

Permalink
Update diagnostics.py
Browse files Browse the repository at this point in the history
  • Loading branch information
shawaj authored Oct 20, 2024
1 parent 7a4a202 commit a892dd2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion hw_diag/views/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,15 @@ def shutdown():
@authenticate
def handle_hostname_update():
req_body = request.get_json()
new_hostname = req_body.get('hostname')
HOSTNAME_OVERRIDE = os.getenv('HOSTNAME_OVERRIDE', 'false')

if HOSTNAME_OVERRIDE != "false":
new_hostname = HOSTNAME_OVERRIDE
logging.info("Hostname overriden from env var. Not updating!")
else:
new_hostname = req_body.get('hostname')
logging.info("No hostname override, updating as per request!")

try:
balena_supervisor = BalenaSupervisor.new_from_env()
balena_supervisor.set_hostname(new_hostname)
Expand Down

0 comments on commit a892dd2

Please sign in to comment.