-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathtasks.py
More file actions
49 lines (40 loc) · 1019 Bytes
/
tasks.py
File metadata and controls
49 lines (40 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
Long-running tasks for the Deis Controller API
This module orchestrates the real "heavy lifting" of Deis, and as such these
functions are decorated to run as asynchronous celery tasks.
"""
from __future__ import unicode_literals
from celery import task
@task
def deploy_release(app, release):
containers = app.container_set.all()
# TODO: parallelize
for c in containers:
try:
c.deploy(release)
except Exception:
c.state = 'error'
c.save()
raise
@task
def start_containers(containers):
# TODO: parallelize
for c in containers:
try:
c.create()
c.start()
except Exception:
c.state = 'error'
c.save()
raise
@task
def stop_containers(containers):
# TODO: parallelize
for c in containers:
try:
c.destroy()
c.delete()
except Exception:
c.state = 'error'
c.save()
raise