Skip to content

Commit

Permalink
lavalab-gen: Add support to configure LAVA event notifications
Browse files Browse the repository at this point in the history
As per
https://validation.linaro.org/static/docs/v2/advanced-installation.html#configuring-event-notifications

All options are optional, but if you want to actually turn notifications
on you'll need to set "event_notification_enabled" to "true".

Signed-off-by: Chris Paterson <[email protected]>
  • Loading branch information
patersonc authored and montjoie committed Jun 28, 2023
1 parent cac7cdd commit aeca7df
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ masters:
env:
- line1 A list of line to set as environment
- line2
event_notifications:
event_notification_topic: A string which event receivers can use for filtering (default is set to the name of the master)
event_notification_port: Port to use for event notifications (default to "5500")
event_notification_enabled: Set to true to enable event notifications (default to "false")
slaves:
- name: lab-slave-XX The name of the slave (where XX is a number)
host: name name of the host running lava-slave-XX (default to "local")
Expand Down
31 changes: 29 additions & 2 deletions lavalab-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@
"EMAIL_PORT": $email_port,
"EMAIL_USE_TLS": $email_use_tls,
"EMAIL_USE_SSL": $email_use_ssl,
"EMAIL_BACKEND": "$email_backend"
"EMAIL_BACKEND": "$email_backend",
"EVENT_TOPIC": "$event_notification_topic",
"INTERNAL_EVENT_SOCKET": "ipc:///tmp/lava.events",
"EVENT_SOCKET": "tcp://*:$event_notification_port",
"EVENT_NOTIFICATION": $event_notification_enabled,
"EVENT_ADDITIONAL_SOCKETS": []
}
""")

Expand Down Expand Up @@ -118,6 +123,7 @@ def main():
keywords_master = [
"allowed_hosts",
"build_args",
"event_notifications",
"groups",
"healthcheck_url", "host", "http_fqdn",
"loglevel", "lava-coordinator",
Expand Down Expand Up @@ -268,6 +274,24 @@ def main():
email_use_ssl = 'false'
if "email_backend" in worker["smtp"]:
email_backend = worker["smtp"]["email_backend"]
# Event notifications
event_notification_topic=name
event_notification_port='5500'
event_notification_enabled='false'
if "event_notifications" in worker:
if "event_notification_topic" in worker["event_notifications"]:
event_notification_topic = worker["event_notifications"]["event_notification_topic"]
if "event_notification_port" in worker["event_notifications"]:
event_notification_port = worker["event_notifications"]["event_notification_port"]
if "event_notification_enabled" in worker["event_notifications"]:
event_notification_enabled = worker["event_notifications"]["event_notification_enabled"]
# django does not like True or False but want true/false (no upper case)
if isinstance(event_notification_enabled, bool):
if event_notification_enabled:
event_notification_enabled = 'true'
else:
event_notification_enabled = 'false'
# Substitute variables in settings.conf
fsettings = open("%s/settings.conf" % workerdir, 'w')
fsettings.write(
template_settings_conf.substitute(
Expand All @@ -282,7 +306,10 @@ def main():
email_use_tls = email_use_tls,
email_use_ssl = email_use_ssl,
email_backend = email_backend,
server_email = server_email
server_email = server_email,
event_notification_topic = event_notification_topic,
event_notification_port = event_notification_port,
event_notification_enabled = event_notification_enabled
)
)
fsettings.close()
Expand Down

0 comments on commit aeca7df

Please sign in to comment.