Revision f533f224 api/actions.py
b/api/actions.py | ||
---|---|---|
12 | 12 |
from synnefo.api.faults import BadRequest, ServiceUnavailable |
13 | 13 |
from synnefo.api.util import random_password, get_vm |
14 | 14 |
from synnefo.util.vapclient import request_forwarding as request_vnc_forwarding |
15 |
from synnefo.logic.backend import (reboot_instance, startup_instance, shutdown_instance, |
|
16 |
get_instance_console) |
|
15 |
from synnefo.logic import backend |
|
17 | 16 |
from synnefo.logic.utils import get_rsapi_state |
18 | 17 |
|
19 | 18 |
|
... | ... | |
76 | 75 |
reboot_type = args.get('type', '') |
77 | 76 |
if reboot_type not in ('SOFT', 'HARD'): |
78 | 77 |
raise BadRequest('Malformed Request.') |
79 |
reboot_instance(vm, reboot_type.lower()) |
|
78 |
backend.reboot_instance(vm, reboot_type.lower())
|
|
80 | 79 |
return HttpResponse(status=202) |
81 | 80 |
|
82 | 81 |
@server_action('start') |
... | ... | |
87 | 86 |
|
88 | 87 |
if args: |
89 | 88 |
raise BadRequest('Malformed Request.') |
90 |
startup_instance(vm) |
|
89 |
backend.startup_instance(vm)
|
|
91 | 90 |
return HttpResponse(status=202) |
92 | 91 |
|
93 | 92 |
@server_action('shutdown') |
... | ... | |
98 | 97 |
|
99 | 98 |
if args: |
100 | 99 |
raise BadRequest('Malformed Request.') |
101 |
shutdown_instance(vm) |
|
100 |
backend.shutdown_instance(vm)
|
|
102 | 101 |
return HttpResponse(status=202) |
103 | 102 |
|
104 | 103 |
@server_action('rebuild') |
... | ... | |
196 | 195 |
if settings.TEST: |
197 | 196 |
console_data = {'kind': 'vnc', 'host': 'ganeti_node', 'port': 1000} |
198 | 197 |
else: |
199 |
console_data = get_instance_console(vm) |
|
198 |
console_data = backend.get_instance_console(vm)
|
|
200 | 199 |
|
201 | 200 |
if console_data['kind'] != 'vnc': |
202 |
raise ServiceUnavailable('Could not create a console of requested type.') |
|
201 |
message = 'Could not create a console of requested type.' |
|
202 |
raise ServiceUnavailable(message) |
|
203 | 203 |
|
204 | 204 |
# Let vncauthproxy decide on the source port. |
205 | 205 |
# The alternative: static allocation, e.g. |
... | ... | |
251 | 251 |
if not server_id: |
252 | 252 |
raise BadRequest('Malformed Request.') |
253 | 253 |
vm = get_vm(server_id, request.user) |
254 |
net.machines.add(vm) |
|
254 |
backend.connect_to_network(vm, net) |
|
255 |
vm.save() |
|
255 | 256 |
net.save() |
256 | 257 |
return HttpResponse(status=202) |
257 | 258 |
|
... | ... | |
270 | 271 |
if not server_id: |
271 | 272 |
raise BadRequest('Malformed Request.') |
272 | 273 |
vm = get_vm(server_id, request.user) |
273 |
net.machines.remove(vm) |
|
274 |
backend.disconnect_from_network(vm, net) |
|
275 |
vm.save() |
|
274 | 276 |
net.save() |
275 | 277 |
return HttpResponse(status=202) |
Also available in: Unified diff