Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e8443130
authored
Mar 07, 2013
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SendMailTask: random fixes
parent
186c1dc3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
11 deletions
+14
-11
cloud/settings.py
+2
-0
firewall/views.py
+3
-3
one/jobs/hourly/scheduled_vm_cleanup.py
+4
-4
one/tasks.py
+5
-4
No files found.
cloud/settings.py
View file @
e8443130
...
...
@@ -212,6 +212,8 @@ firewall_settings = {
"dns_ttl"
:
"300"
,
}
EMAIL_HOST
=
'cronos.ik.bme.hu'
try
:
from
cloud.local_settings
import
*
except
:
...
...
firewall/views.py
View file @
e8443130
...
...
@@ -17,6 +17,7 @@ import sys
import
datetime
from
django.utils.timezone
import
utc
from
one.tasks
import
SendMailTask
def
reload_firewall
(
request
):
if
request
.
user
.
is_authenticated
():
...
...
@@ -48,9 +49,8 @@ def firewall_api(request):
obj
.
host
=
models
.
Host
.
objects
.
get
(
ipv4
=
data
[
"ip"
])
user
=
obj
.
host
.
owner
lang
=
user
.
person_set
.
all
()[
0
]
.
language
s
=
render_to_string
(
'mails/notification-ban-now.txt'
,
{
'user'
:
user
,
'bl'
:
obj
}
)
print
s
# send_mail(settings.EMAIL_SUBJECT_PREFIX + (_('New project: %s') % p.identifier), s, settings.SERVER_EMAIL, [])
msg
=
render_to_string
(
'mails/notification-ban-now.txt'
,
{
'user'
:
user
,
'bl'
:
obj
,
'instance:'
:
obj
.
host
.
instance_set
.
get
()
}
)
SendMailTask
.
delay
(
to
=
obj
.
host
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
obj
.
host
.
instance_set
.
get
()
.
name
,
msg
=
msg
)
except
(
Host
.
DoesNotExist
,
ValidationError
,
IntegrityError
,
AttributeError
):
pass
print
obj
.
modified_at
+
datetime
.
timedelta
(
minutes
=
5
)
...
...
one/jobs/hourly/scheduled_vm_cleanup.py
View file @
e8443130
...
...
@@ -31,12 +31,12 @@ class Job(HourlyJob):
delete
=
i
.
time_of_delete
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
)
if
delete
<
now
:
msg
=
render_to_string
(
'mails/notification-delete-now.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
}
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
_
(
'Delete notification'
)
,
msg
=
msg
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
i
.
name
,
msg
=
msg
)
else
:
for
t
in
d
:
if
delete
==
d
[
t
]:
msg
=
render_to_string
(
'mails/notification-delete.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
}
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
_
(
'Delete notification'
)
,
msg
=
msg
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
i
.
name
,
msg
=
msg
)
# suspend
for
i
in
Instance
.
objects
.
filter
(
state
=
'ACTIVE'
,
time_of_suspend__isnull
=
False
):
...
...
@@ -45,10 +45,10 @@ class Job(HourlyJob):
if
suspend
<
now
:
msg
=
render_to_string
(
'mails/notification-suspend-now.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
}
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
_
(
'Stop notification'
)
,
msg
=
msg
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
i
.
name
,
msg
=
msg
)
i
.
stop
()
else
:
for
t
in
d
:
if
suspend
==
d
[
t
]:
msg
=
render_to_string
(
'mails/notification-suspend.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
}
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
_
(
'Stop notification'
)
,
msg
=
msg
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
i
.
name
,
msg
=
msg
)
one/tasks.py
View file @
e8443130
...
...
@@ -4,12 +4,13 @@ import celery
import
os
import
sys
import
time
from
django.core.mail
import
send_mail
logger
=
logging
.
getLogger
(
__name__
)
class
SendMailTask
(
Task
):
def
run
(
self
,
to
,
subject
,
msg
):
sender
=
u'cloud@ik.bme.hu'
print
u'
%
s->
%
s [
%
s]'
%
(
sender
,
to
,
subject
)
logger
.
info
(
"[django][one][tasks.py]
%
s"
,
msg
)
sender
=
u'noreply@cloud.ik.bme.hu'
send_mail
(
subject
,
msg
,
sender
,
[
to
],
fail_silently
=
False
)
logger
.
info
(
"[django][one][tasks.py]
%
s->
%
s [
%
s]"
%
(
sender
,
to
,
subject
)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment