Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lavalab-gen: Add support to configure LAVA event notifications #167

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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