-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmock.py
More file actions
47 lines (34 loc) · 1.14 KB
/
mock.py
File metadata and controls
47 lines (34 loc) · 1.14 KB
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
from __future__ import unicode_literals
import time
from api.models import Node
from celery import task
@task(name='mock.prepare_formation')
def prepare_formation(formation, creds, params):
# create security group any other infrastructure
return
@task(name='mock.cleanup_formation')
def cleanup_formation(formation, creds, params):
# delete security group and any other infrastructure
return
@task(name='mock.launch_node')
def launch_node(node_id, creds, params, init, ssh_username, ssh_private_key):
node = Node.objects.get(uuid=node_id)
node.provider_id = 'i-1234567'
node.metadata = {'state': 'running'}
node.fqdn = 'localhost.localdomain.local'
time.sleep(1)
node.save()
@task(name='mock.terminate_node')
def terminate_node(node_id, creds, params, provider_id):
node = Node.objects.get(uuid=node_id)
node.metadata = {'state': 'terminated'}
node.save()
# delete the node itself from the database
time.sleep(1)
node.delete()
@task(name='mock.converge_node')
def converge_node(node_id, ssh_username, fqdn, ssh_private_key):
output = ""
rc = 0
time.sleep(1)
return output, rc