|
|
|
|
@@ -3,6 +3,11 @@ const nodemailer = require('nodemailer');
|
|
|
|
|
const FROM = '"Qlik" <no-reply@qlik.com>';
|
|
|
|
|
var transporter;
|
|
|
|
|
|
|
|
|
|
const HOSTNAME_URL = process.env.HOSTNAME_URL || "https://qmicloud.qliktech.com";
|
|
|
|
|
const FOOTER = `<div style="color:#404040;font-size:16px;margin:30px 0px">
|
|
|
|
|
<p style="margin:0px">Check it out at <a href="${HOSTNAME_URL}">${HOSTNAME_URL}</a></p>
|
|
|
|
|
</div>`;
|
|
|
|
|
|
|
|
|
|
if ( process.env.GMAIL_USERNAME && process.env.GMAIL_PASSWORD ) {
|
|
|
|
|
//GMAIL
|
|
|
|
|
transporter = nodemailer.createTransport({
|
|
|
|
|
@@ -85,9 +90,7 @@ function getHtmlScenarioDestroyIn24( provision, scenario, period, warningDays) {
|
|
|
|
|
<p style="margin:0px">If you don't want this to happen, you've got ${(warningDays*24)} hours (from when this email was sent) as a grace period to get back at 'Running' status this provision.</p>
|
|
|
|
|
</div>
|
|
|
|
|
${common}
|
|
|
|
|
<div style="color:#404040;font-size:16px;margin:30px 0px">
|
|
|
|
|
<p style="margin:0px">Check it out at <a href="https://qmicloud.qliktech.com">https://qmicloud.qliktech.com</a></p>
|
|
|
|
|
</div>
|
|
|
|
|
${FOOTER}
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
@@ -107,12 +110,10 @@ function getHtmlScenarioVMsStopped( provision, scenario) {
|
|
|
|
|
<p style="margin:0px;color: #FF2020">All VMs for this provision <b>stopped</b> automatically.</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div style="color:#404040;font-size:16px;margin:30px 0px">
|
|
|
|
|
<p style="margin:0px">You can start them up again from <a href="https://qmicloud.qliktech.com">https://qmicloud.qliktech.com</a></p>
|
|
|
|
|
<p style="margin:0px">You can start them up again from <a href="${HOSTNAME_URL}">${HOSTNAME_URL}</a></p>
|
|
|
|
|
</div>
|
|
|
|
|
${common}
|
|
|
|
|
<div style="color:#404040;font-size:16px;margin:30px 0px">
|
|
|
|
|
<p style="margin:0px">Check it out at <a href="https://qmicloud.qliktech.com">https://qmicloud.qliktech.com</a></p>
|
|
|
|
|
</div>
|
|
|
|
|
${FOOTER}
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
@@ -137,9 +138,7 @@ function getHtmlScenarioWillStopIn24( provision, scenario, period, warningDays )
|
|
|
|
|
<p style="margin:0px">If you don't want the VMs to automatically stop, you've got ${warningDays*24} hours (from when this email was sent) as a grace period to extend this scenario's <b style="color: #009845">Running</b> VMs for ${(period+warningDays)} extra days.</p>
|
|
|
|
|
</div>
|
|
|
|
|
${common}
|
|
|
|
|
<div style="color:#404040;font-size:16px;margin:30px 0px">
|
|
|
|
|
<p style="margin:0px">Check it out at <a href="https://qmicloud.qliktech.com">https://qmicloud.qliktech.com</a></p>
|
|
|
|
|
</div>
|
|
|
|
|
${FOOTER}
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
@@ -173,9 +172,7 @@ function getHtmlNewProvision(provision, scenario) {
|
|
|
|
|
<div style="margin: 30px 0px;">
|
|
|
|
|
${htmlint}
|
|
|
|
|
</div>
|
|
|
|
|
<div style="color:#404040;font-size:16px;margin:30px 0px">
|
|
|
|
|
<p style="margin:0px">Check it out at <a href="https://qmicloud.qliktech.com">https://qmicloud.qliktech.com</a></p>
|
|
|
|
|
</div>
|
|
|
|
|
${FOOTER}
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
|
|
|
|
@@ -195,9 +192,7 @@ function getHtmlErrorProvision(provision, scenario) {
|
|
|
|
|
<p style="margin:0px">Scenario '${scenario.title}' failed during provision.</p>
|
|
|
|
|
</div>
|
|
|
|
|
${common}
|
|
|
|
|
<div style="color:#404040;font-size:16px;margin:30px 0px">
|
|
|
|
|
<p style="margin:0px">Check it out at <a href="https://qmicloud.qliktech.com">https://qmicloud.qliktech.com</a></p>
|
|
|
|
|
</div>
|
|
|
|
|
${FOOTER}
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
@@ -213,26 +208,24 @@ function getHtmlDestroyProvision(provision, scenario) {
|
|
|
|
|
<p style="margin:0px">Scenario '${scenario.title}' successfully destroyed!</p>
|
|
|
|
|
</div>
|
|
|
|
|
${common}
|
|
|
|
|
<div style="color:#404040;font-size:16px;margin:30px 0px">
|
|
|
|
|
<p style="margin:0px">Check it out at <a href="https://qmicloud.qliktech.com">https://qmicloud.qliktech.com</a></p>
|
|
|
|
|
</div>
|
|
|
|
|
${FOOTER}
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// async..await is not allowed in global scope, must use a wrapper
|
|
|
|
|
async function send( provision, scenario ) {
|
|
|
|
|
async function sendProvisionSuccess( provision, scenario ) {
|
|
|
|
|
const htmlText = getHtmlNewProvision(provision, scenario);
|
|
|
|
|
await _doSend(provision.user.upn, 'QMI Cloud - Provision finished successfully', htmlText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function sendError(provision, scenario ) {
|
|
|
|
|
async function sendProvisionError(provision, scenario ) {
|
|
|
|
|
const htmlText = getHtmlErrorProvision(provision, scenario);
|
|
|
|
|
await _doSend(provision.user.upn, 'QMI Cloud - Provision with failures', htmlText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function sendDestroyed(provision, scenario ) {
|
|
|
|
|
async function sendDestroyedSuccess(provision, scenario ) {
|
|
|
|
|
|
|
|
|
|
const htmlText = getHtmlDestroyProvision(provision, scenario);
|
|
|
|
|
await _doSend(provision.user.upn, 'QMI Cloud - Provision destroyed successfully', htmlText);
|
|
|
|
|
@@ -257,9 +250,9 @@ async function sendVMsStopped( provision, scenario ) {
|
|
|
|
|
await _doSend(provision.user.upn, 'QMI Cloud - VMs stopped automatically', htmlText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports.send = send;
|
|
|
|
|
module.exports.sendError = sendError;
|
|
|
|
|
module.exports.sendDestroyed = sendDestroyed;
|
|
|
|
|
module.exports.sendProvisionSuccess = sendProvisionSuccess;
|
|
|
|
|
module.exports.sendProvisionError = sendProvisionError;
|
|
|
|
|
module.exports.sendDestroyedSuccess = sendDestroyedSuccess;
|
|
|
|
|
module.exports.sendWillStopIn24 = sendWillStopIn24;
|
|
|
|
|
module.exports.sendVMsStopped = sendVMsStopped;
|
|
|
|
|
module.exports.sendWillDestroyIn24 = sendWillDestroyIn24;
|
|
|
|
|
|