enable sending mail on warn event in the cron command for deployments

This commit is contained in:
deflax 2018-05-22 15:28:06 +03:00
parent b7c624578c
commit b6234c2f26
5 changed files with 11 additions and 19 deletions

View file

@ -55,7 +55,7 @@ def dashboard(user_pid):
abort(404) #hidden 403
inv_addresses = cuser.inv_addresses.order_by(Address.ip.asc()).all()
inv_deployments = cuser.inv_deployments.filter_by(deleted=False).order_by(Deployment.date_created.desc()).all()
inv_deployments = cuser.inv_deployments.filter_by(deleted=False).order_by(Deployment.machine_alias.asc()).all()
regions = {}
for region in sys_regions:
regions[region.pid] = region.description

View file

@ -2,8 +2,7 @@
<div class="page_wrap">
<div class="footerblock" id="newsmenu" style="float: left;">
<h4>News</h4>
<!--#include virtual="https://www.datapoint.bg/news/latest" -->
<!--<h4>News</h4>-->
</div>
<div class="footerblock" style="float: right;" align="right">

View file

@ -1,10 +0,0 @@
{% block page_content %}
<h4>News</h4>
{% for item in result %}
<p>
<a target="_blank" href="{{ item['link'] }}">{{ item['message'] }}</a>
<span class="tweet_day">{{ item['created_time'] | fbtime }}</span>
</p>
{% endfor %}
<a href="/news/all">>>></a>
{% endblock %}

View file

@ -123,6 +123,7 @@ addEventListener("DOMContentLoaded", function() {
<th>IP</th>
<th>Region</th>
<th>Reverse DNS</th>
<th>Deployment<th>
</tr>
</thead>
<tbody>
@ -131,6 +132,7 @@ addEventListener("DOMContentLoaded", function() {
<td data-title="IP">{{ address.ip }}</td>
<td data-title="Region">{{ regions[address.region_id] }}</td>
<td data-title="RDNS">{{ address.rdns }}</td>
<td data-title="Deployment">{{ address.assignee.deploy.machine_alias }}</td>
</tr>
{% endfor %}
</tbody>

View file

@ -69,7 +69,7 @@ def autodisable():
if today >= expiry:
email_content = '[!] Deployment "' + deploy.machine_alias + '" is past expiration date and will be marked INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c')
print(str(email_content) + " [mail sent]")
#send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content))
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content))
#send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
deploy.warning = False
deploy.enabled = False
@ -84,7 +84,7 @@ def autodisable():
if today >= expiry:
email_content = '[!] Service "' + service.description + '" is past expiration date and will be marked INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c')
print(str(email_content) + " [mail sent]")
#send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=service.owner, content=str(email_content))
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=service.owner, content=str(email_content))
#send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
service.warning = False
service.enabled = False
@ -98,7 +98,7 @@ def autodisable():
if today >= expiry:
email_content = '[!] Domain "' + domain.fqdn + '" is past expiration date and will be marked as INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c')
print(str(email_content) + " [mail sent]")
#send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=domain.owner, content=str(email_content))
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=domain.owner, content=str(email_content))
#send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
domain.warning = False
domain.enabled = False
@ -122,10 +122,11 @@ def autowarn():
db.session.commit()
warndays = deploy.period * 5
email_content = 'Deployment "' + deploy.machine_alias + '" is ' + str(daysleft.days) + ' days until expiration. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c')
if daysleft.days == warndays or round(daysleft.days / 2) == warndays:
#if daysleft.days == warndays or round(daysleft.days * 2) == warndays:
if round(daysleft.days * 2) == warndays:
print(str(email_content) + " [mail sent]")
#send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content))
#send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content))
send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
deploy.warning = True
if daysleft.days < warndays:
print(str(email_content))