enable sending mail on warn event in the cron command for deployments
This commit is contained in:
parent
b7c624578c
commit
b6234c2f26
5 changed files with 11 additions and 19 deletions
|
@ -55,7 +55,7 @@ def dashboard(user_pid):
|
||||||
abort(404) #hidden 403
|
abort(404) #hidden 403
|
||||||
|
|
||||||
inv_addresses = cuser.inv_addresses.order_by(Address.ip.asc()).all()
|
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 = {}
|
regions = {}
|
||||||
for region in sys_regions:
|
for region in sys_regions:
|
||||||
regions[region.pid] = region.description
|
regions[region.pid] = region.description
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
<div class="page_wrap">
|
<div class="page_wrap">
|
||||||
|
|
||||||
<div class="footerblock" id="newsmenu" style="float: left;">
|
<div class="footerblock" id="newsmenu" style="float: left;">
|
||||||
<h4>News</h4>
|
<!--<h4>News</h4>-->
|
||||||
<!--#include virtual="https://www.datapoint.bg/news/latest" -->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="footerblock" style="float: right;" align="right">
|
<div class="footerblock" style="float: right;" align="right">
|
||||||
|
|
|
@ -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 %}
|
|
|
@ -123,6 +123,7 @@ addEventListener("DOMContentLoaded", function() {
|
||||||
<th>IP</th>
|
<th>IP</th>
|
||||||
<th>Region</th>
|
<th>Region</th>
|
||||||
<th>Reverse DNS</th>
|
<th>Reverse DNS</th>
|
||||||
|
<th>Deployment<th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -131,6 +132,7 @@ addEventListener("DOMContentLoaded", function() {
|
||||||
<td data-title="IP">{{ address.ip }}</td>
|
<td data-title="IP">{{ address.ip }}</td>
|
||||||
<td data-title="Region">{{ regions[address.region_id] }}</td>
|
<td data-title="Region">{{ regions[address.region_id] }}</td>
|
||||||
<td data-title="RDNS">{{ address.rdns }}</td>
|
<td data-title="RDNS">{{ address.rdns }}</td>
|
||||||
|
<td data-title="Deployment">{{ address.assignee.deploy.machine_alias }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
13
manage.py
13
manage.py
|
@ -69,7 +69,7 @@ def autodisable():
|
||||||
if today >= expiry:
|
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')
|
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]")
|
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))
|
#send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
|
||||||
deploy.warning = False
|
deploy.warning = False
|
||||||
deploy.enabled = False
|
deploy.enabled = False
|
||||||
|
@ -84,7 +84,7 @@ def autodisable():
|
||||||
if today >= expiry:
|
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')
|
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]")
|
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))
|
#send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
|
||||||
service.warning = False
|
service.warning = False
|
||||||
service.enabled = False
|
service.enabled = False
|
||||||
|
@ -98,7 +98,7 @@ def autodisable():
|
||||||
if today >= expiry:
|
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')
|
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]")
|
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))
|
#send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
|
||||||
domain.warning = False
|
domain.warning = False
|
||||||
domain.enabled = False
|
domain.enabled = False
|
||||||
|
@ -122,10 +122,11 @@ def autowarn():
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
warndays = deploy.period * 5
|
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')
|
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]")
|
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))
|
send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
|
||||||
deploy.warning = True
|
deploy.warning = True
|
||||||
if daysleft.days < warndays:
|
if daysleft.days < warndays:
|
||||||
print(str(email_content))
|
print(str(email_content))
|
||||||
|
|
Loading…
Add table
Reference in a new issue