Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
efab9932
authored
Mar 07, 2013
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SendMailTask: random fixes v2
parent
d30ac29c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
cloud/settings.py
+1
-0
one/jobs/hourly/scheduled_vm_cleanup.py
+9
-7
No files found.
cloud/settings.py
View file @
efab9932
...
...
@@ -213,6 +213,7 @@ firewall_settings = {
}
EMAIL_HOST
=
'cronos.ik.bme.hu'
CLOUD_URL
=
'https://cloud.ik.bme.hu/'
try
:
from
cloud.local_settings
import
*
...
...
one/jobs/hourly/scheduled_vm_cleanup.py
View file @
efab9932
...
...
@@ -6,6 +6,8 @@ from one.models import Instance
from
django.template.loader
import
render_to_string
from
one.tasks
import
SendMailTask
from
django.utils.translation
import
ugettext_lazy
as
_
from
cloud.settings
import
CLOUD_URL
as
url
class
Job
(
HourlyJob
):
help
=
"Suspend/delete expired Instances."
...
...
@@ -20,7 +22,7 @@ class Job(HourlyJob):
'2w'
:
self
.
calc
(
orig
=
now
,
days
=
14
),
'1w'
:
self
.
calc
(
orig
=
now
,
days
=
7
),
'1d'
:
self
.
calc
(
orig
=
now
,
days
=
1
),
'1h'
:
self
.
calc
(
orig
=
now
,
hours
=
2
),
'1h'
:
self
.
calc
(
orig
=
now
,
hours
=
1
),
}
# for i in d:
# print i+':'+unicode(d[i])
...
...
@@ -29,13 +31,13 @@ class Job(HourlyJob):
for
i
in
Instance
.
objects
.
filter
(
state__in
=
[
'ACTIVE'
,
'STOPPED'
],
time_of_delete__isnull
=
False
):
print
"
%
s delete:
%
s"
%
(
i
.
name
,
i
.
time_of_delete
)
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
}
)
if
i
.
time_of_
delete
<
now
:
msg
=
render_to_string
(
'mails/notification-delete-now.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
,
'url'
:
url
}
)
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
}
)
msg
=
render_to_string
(
'mails/notification-delete.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
,
'url'
:
url
}
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
i
.
name
,
msg
=
msg
)
# suspend
...
...
@@ -43,12 +45,12 @@ class Job(HourlyJob):
print
"
%
s suspend:
%
s"
%
(
i
.
name
,
i
.
time_of_suspend
)
suspend
=
i
.
time_of_suspend
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
)
if
suspend
<
now
:
msg
=
render_to_string
(
'mails/notification-suspend-now.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
}
)
if
i
.
time_of_
suspend
<
now
:
msg
=
render_to_string
(
'mails/notification-suspend-now.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
,
'url'
:
url
}
)
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
}
)
msg
=
render_to_string
(
'mails/notification-suspend.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
,
'url'
:
url
}
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
i
.
name
,
msg
=
msg
)
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