Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
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 = {
...
@@ -213,6 +213,7 @@ firewall_settings = {
}
}
EMAIL_HOST
=
'cronos.ik.bme.hu'
EMAIL_HOST
=
'cronos.ik.bme.hu'
CLOUD_URL
=
'https://cloud.ik.bme.hu/'
try
:
try
:
from
cloud.local_settings
import
*
from
cloud.local_settings
import
*
...
...
one/jobs/hourly/scheduled_vm_cleanup.py
View file @
efab9932
...
@@ -6,6 +6,8 @@ from one.models import Instance
...
@@ -6,6 +6,8 @@ from one.models import Instance
from
django.template.loader
import
render_to_string
from
django.template.loader
import
render_to_string
from
one.tasks
import
SendMailTask
from
one.tasks
import
SendMailTask
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
cloud.settings
import
CLOUD_URL
as
url
class
Job
(
HourlyJob
):
class
Job
(
HourlyJob
):
help
=
"Suspend/delete expired Instances."
help
=
"Suspend/delete expired Instances."
...
@@ -20,7 +22,7 @@ class Job(HourlyJob):
...
@@ -20,7 +22,7 @@ class Job(HourlyJob):
'2w'
:
self
.
calc
(
orig
=
now
,
days
=
14
),
'2w'
:
self
.
calc
(
orig
=
now
,
days
=
14
),
'1w'
:
self
.
calc
(
orig
=
now
,
days
=
7
),
'1w'
:
self
.
calc
(
orig
=
now
,
days
=
7
),
'1d'
:
self
.
calc
(
orig
=
now
,
days
=
1
),
'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:
# for i in d:
# print i+':'+unicode(d[i])
# print i+':'+unicode(d[i])
...
@@ -29,13 +31,13 @@ class Job(HourlyJob):
...
@@ -29,13 +31,13 @@ class Job(HourlyJob):
for
i
in
Instance
.
objects
.
filter
(
state__in
=
[
'ACTIVE'
,
'STOPPED'
],
time_of_delete__isnull
=
False
):
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
)
print
"
%
s delete:
%
s"
%
(
i
.
name
,
i
.
time_of_delete
)
delete
=
i
.
time_of_delete
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
)
delete
=
i
.
time_of_delete
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
)
if
delete
<
now
:
if
i
.
time_of_
delete
<
now
:
msg
=
render_to_string
(
'mails/notification-delete-now.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
}
)
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
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
i
.
name
,
msg
=
msg
)
else
:
else
:
for
t
in
d
:
for
t
in
d
:
if
delete
==
d
[
t
]:
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
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
i
.
name
,
msg
=
msg
)
# suspend
# suspend
...
@@ -43,12 +45,12 @@ class Job(HourlyJob):
...
@@ -43,12 +45,12 @@ class Job(HourlyJob):
print
"
%
s suspend:
%
s"
%
(
i
.
name
,
i
.
time_of_suspend
)
print
"
%
s suspend:
%
s"
%
(
i
.
name
,
i
.
time_of_suspend
)
suspend
=
i
.
time_of_suspend
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
)
suspend
=
i
.
time_of_suspend
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
)
if
suspend
<
now
:
if
i
.
time_of_
suspend
<
now
:
msg
=
render_to_string
(
'mails/notification-suspend-now.txt'
,
{
'user'
:
i
.
owner
,
'instance'
:
i
}
)
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
)
SendMailTask
.
delay
(
to
=
i
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
i
.
name
,
msg
=
msg
)
i
.
stop
()
i
.
stop
()
else
:
else
:
for
t
in
d
:
for
t
in
d
:
if
suspend
==
d
[
t
]:
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
)
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