Link to tasks panel in notifications
* Adjutant-UI now supports views for Tasks, we should link to it in the default notification templates. * To make this possible, and other potential uses, deprecate the TOKEN_SUBMISSION_URL in favor of HORIZON_URL * clean up some formatting issues with the notification template Change-Id: I1419fafe94812e64a0b3984f9f38528ec67ac8e4
This commit is contained in:
parent
efdb2ae24d
commit
7a448a369e
@ -85,8 +85,17 @@ def send_stage_email(task, email_conf, token=None):
|
||||
'actions': actions
|
||||
}
|
||||
if token:
|
||||
if settings.HORIZON_URL:
|
||||
tokenurl = settings.HORIZON_URL
|
||||
if not tokenurl.endswith('/'):
|
||||
tokenurl += '/'
|
||||
tokenurl += 'token/'
|
||||
else:
|
||||
tokenurl = settings.TOKEN_SUBMISSION_URL
|
||||
if not tokenurl.endswith('/'):
|
||||
tokenurl += '/'
|
||||
context.update({
|
||||
'tokenurl': settings.TOKEN_SUBMISSION_URL,
|
||||
'tokenurl': tokenurl,
|
||||
'token': token.token
|
||||
})
|
||||
|
||||
|
@ -32,3 +32,7 @@ class ActionNotFound(BaseException):
|
||||
|
||||
class SerializerMissingException(BaseException):
|
||||
""" Serializer configured but it does not exist """
|
||||
|
||||
|
||||
class ConfirmationException(BaseException):
|
||||
""" Missing or incorrect configuration value. """
|
||||
|
@ -70,6 +70,13 @@ class EmailNotification(NotificationEngine):
|
||||
context = {
|
||||
'task': task, 'notification': notification}
|
||||
|
||||
if settings.HORIZON_URL:
|
||||
task_url = settings.HORIZON_URL
|
||||
if not task_url.endswith('/'):
|
||||
task_url += '/'
|
||||
task_url += 'management/tasks/'
|
||||
context['task_url'] = task_url
|
||||
|
||||
if notification.error:
|
||||
subject = "Error - %s notification" % task.task_type
|
||||
else:
|
||||
|
@ -7,7 +7,7 @@ There is a task that needs some attention.
|
||||
Related Task:
|
||||
uuid: {{ task.uuid }}
|
||||
ip_address: {{ task.ip_address }}
|
||||
keystone_user: {{ task.keystone_user }}
|
||||
keystone_user: {{ task.keystone_user|safe }}
|
||||
project_id: {{ task.project_id }}
|
||||
task_type: {{ task.task_type }}
|
||||
cancelled: {{ task.cancelled }}
|
||||
@ -17,11 +17,17 @@ created_on: {{ task.created_on }}
|
||||
approved_on: {{ task.approved_on }}
|
||||
completed_on: {{ task.completed_on }}
|
||||
action_notes:
|
||||
{% for action, notes in task.action_notes.items %}- {{ action }}
|
||||
{% for note in notes %} - {{ note }}
|
||||
{% for action, notes in task.action_notes.items %}- {{ action|safe }}
|
||||
{% for note in notes %} - {{ note|safe }}
|
||||
{% endfor %}{% endfor %}
|
||||
|
||||
Notification details:
|
||||
uuid: {{ notification.uuid }}
|
||||
notes:
|
||||
{{ notification.notes }}
|
||||
{{ notification.notes|safe }}
|
||||
|
||||
{% if task_url %}
|
||||
Task link:
|
||||
{{ task_url }}{{ task.uuid }}
|
||||
|
||||
{% endif %}
|
||||
|
@ -27,6 +27,7 @@ import os
|
||||
import sys
|
||||
import yaml
|
||||
from adjutant.utils import setup_task_settings
|
||||
from adjutant.exceptions import ConfirmationException
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
# Application definition
|
||||
@ -148,7 +149,14 @@ USERNAME_IS_EMAIL = CONFIG['USERNAME_IS_EMAIL']
|
||||
# Keystone admin credentials:
|
||||
KEYSTONE = CONFIG['KEYSTONE']
|
||||
|
||||
TOKEN_SUBMISSION_URL = CONFIG['TOKEN_SUBMISSION_URL']
|
||||
TOKEN_SUBMISSION_URL = CONFIG.get('TOKEN_SUBMISSION_URL')
|
||||
if TOKEN_SUBMISSION_URL:
|
||||
print("'TOKEN_SUBMISSION_URL' is deprecated, use 'HORIZON_URL' instead")
|
||||
|
||||
HORIZON_URL = CONFIG.get('HORIZON_URL')
|
||||
|
||||
if not HORIZON_URL and not TOKEN_SUBMISSION_URL:
|
||||
raise ConfirmationException("Must supply 'HORIZON_URL'")
|
||||
|
||||
TOKEN_EXPIRE_TIME = CONFIG['TOKEN_EXPIRE_TIME']
|
||||
|
||||
|
@ -71,7 +71,7 @@ KEYSTONE = {
|
||||
'auth_url': "http://localhost:5000/v3",
|
||||
}
|
||||
|
||||
TOKEN_SUBMISSION_URL = 'http://localhost:8080/token/'
|
||||
HORIZON_URL = 'http://localhost:8080/'
|
||||
|
||||
TOKEN_EXPIRE_TIME = 24
|
||||
|
||||
@ -399,7 +399,7 @@ conf_dict = {
|
||||
"DEFAULT_TASK_SETTINGS": DEFAULT_TASK_SETTINGS,
|
||||
"TASK_SETTINGS": TASK_SETTINGS,
|
||||
"DEFAULT_ACTION_SETTINGS": DEFAULT_ACTION_SETTINGS,
|
||||
"TOKEN_SUBMISSION_URL": TOKEN_SUBMISSION_URL,
|
||||
"HORIZON_URL": HORIZON_URL,
|
||||
"TOKEN_EXPIRE_TIME": TOKEN_EXPIRE_TIME,
|
||||
"ROLES_MAPPING": ROLES_MAPPING,
|
||||
"PROJECT_QUOTA_SIZES": PROJECT_QUOTA_SIZES,
|
||||
|
@ -56,7 +56,7 @@ KEYSTONE:
|
||||
auth_url: http://localhost/identity/v3
|
||||
domain_id: default
|
||||
|
||||
TOKEN_SUBMISSION_URL: http://192.168.122.160:8080/token/
|
||||
HORIZON_URL: http://localhost:8080/
|
||||
|
||||
# time for the token to expire in hours
|
||||
TOKEN_EXPIRE_TIME: 24
|
||||
|
Loading…
x
Reference in New Issue
Block a user