diff --git a/dbaas/api/task.py b/dbaas/api/task.py
index 98084fae6..f41620f25 100644
--- a/dbaas/api/task.py
+++ b/dbaas/api/task.py
@@ -160,6 +160,7 @@ class TaskAPI(viewsets.ReadOnlyModelViewSet):
'maintenance.tasks.restart_database',
'notification.tasks.change_database_persistence',
'maintenance.tasks.task_upgrade_disk_type',
+ 'maintenance.tasks.auto_upgrade_database_vm_offering',
]
model = TaskHistory
diff --git a/dbaas/maintenance/task_auto_upgrade_vm_offering.py b/dbaas/maintenance/task_auto_upgrade_vm_offering.py
index 33da4fc7c..555bf879d 100644
--- a/dbaas/maintenance/task_auto_upgrade_vm_offering.py
+++ b/dbaas/maintenance/task_auto_upgrade_vm_offering.py
@@ -6,7 +6,7 @@
from physical.models import (Plan, DatabaseInfra, Instance, Pool)
from util.providers import get_auto_upgrade_vm_settings
from workflow.workflow import steps_for_instances
-from util import get_vm_name
+from util import get_vm_name, email_notifications
LOG = logging.getLogger(__name__)
@@ -75,6 +75,7 @@ def task_auto_upgrade_vm_offering(database, task, retry_from=None, resize_target
last_vm_created = number_of_instances_before_task
if not retry_from:
+ email_notifications.upgrade_offering_notification(database, resize_target)
for i in range(number_of_instances):
instance = None
last_vm_created += 1
diff --git a/dbaas/notification/templates/email_extras/auto_upgrade_offering_notification.html b/dbaas/notification/templates/email_extras/auto_upgrade_offering_notification.html
new file mode 100644
index 000000000..114aa6365
--- /dev/null
+++ b/dbaas/notification/templates/email_extras/auto_upgrade_offering_notification.html
@@ -0,0 +1,20 @@
+
Automatic GCP offering upgrade for Database {{ database.name }}
+
+We would like to inform you that an automatic offer update is being carried out on DBaaS to meet your database {{database.name}} needs.
+
+The update will be done automatically from {{ current_offering.name }} to {{ future_offering.name }}.
+
+Please be aware that this upgrade may increase the costs.
+Any questions please contact the DBDevops responsible for your team.
+
+
+{% if database.team.email %}
+You are receiving this email because in our records you are in team {{ database.team.name }}.
+If this is not right, contact the DBaaS system administrators.
+{% else %}
+Team {{ database.team.name }} has no email set!
+{% endif %}
+
+Regards,
+DBaaS notification robot
+{{domain}}
diff --git a/dbaas/notification/templates/email_extras/auto_upgrade_offering_notification.txt b/dbaas/notification/templates/email_extras/auto_upgrade_offering_notification.txt
new file mode 100644
index 000000000..47bc1238b
--- /dev/null
+++ b/dbaas/notification/templates/email_extras/auto_upgrade_offering_notification.txt
@@ -0,0 +1,19 @@
+Automatic GCP offering upgrade for Database {{ database.name }}
+
+We would like to inform you that an automatic offer update is being carried out on DBaaS to meet your database {{database.name}} needs.
+
+The update will be done automatically from {{ current_offering.name }} to {{ future_offering.name }}.
+
+Please be aware that this upgrade may increase the costs.
+Any questions please contact the DBDevops responsible for your team.
+
+{% if database.team.email %}
+You are receiving this email because in our records you are in team {{ database.team.name }}.
+If this is not right, contact the DBaaS system administrators.
+{% else %}
+Team {{ database.team.name }} has no email set!
+{% endif %}
+
+Regards,
+DBaaS notification robot
+{{domain}}
diff --git a/dbaas/util/email_notifications.py b/dbaas/util/email_notifications.py
index 083c8b7e0..afe314e7b 100644
--- a/dbaas/util/email_notifications.py
+++ b/dbaas/util/email_notifications.py
@@ -157,8 +157,30 @@ def disk_resize_notification(database, new_disk, usage_percentage):
)
-def schedule_task_notification(database, scheduled_task, is_new,
- is_task_warning=False):
+def upgrade_offering_notification(database, resize_target):
+ LOG.info('Notifying auto upgrade offering to database: {}'.format(database))
+
+ current_offering = database.databaseinfra.offering
+ future_offering = database.get_future_offering(resize_target)
+
+ subject = _('[DBaaS] Database {} auto upgrade offering to {}').format(database, future_offering.name)
+ template = "auto_upgrade_offering_notification"
+
+ context = {
+ 'domain': get_domain(),
+ 'database': database,
+ 'current_offering': current_offering,
+ 'future_offering': future_offering,
+ 'database_url': get_database_url(database.id)
+ }
+
+ send_mail_template(
+ subject, template, email_from(), email_to(database.team),
+ fail_silently=False, attachments=None, context=context
+ )
+
+
+def schedule_task_notification(database, scheduled_task, is_new, is_task_warning=False):
subject_tmpl = '[DBaaS] Automatic Task {} for Database {}'
if is_task_warning: