Revision 0971fa71 api/actions.py
b/api/actions.py | ||
---|---|---|
2 | 2 |
# Copyright (c) 2010 Greek Research and Technology Network |
3 | 3 |
# |
4 | 4 |
|
5 |
from synnefo.api.errors import * |
|
6 |
from synnefo.util.rapi import GanetiRapiClient |
|
7 |
|
|
8 | 5 |
from django.conf import settings |
9 | 6 |
from django.http import HttpResponse |
10 | 7 |
|
8 |
from synnefo.api.errors import * |
|
9 |
from synnefo.util.rapi import GanetiRapiClient |
|
10 |
from synnefo.logic import backend, utils |
|
11 |
|
|
11 | 12 |
server_actions = {} |
12 | 13 |
|
13 | 14 |
rapi = GanetiRapiClient(*settings.GANETI_CLUSTER_INFO) |
... | ... | |
51 | 52 |
# buildInProgress (409), |
52 | 53 |
# overLimit (413) |
53 | 54 |
|
54 |
type = args.get('type', '') |
|
55 |
if type not in ('SOFT', 'HARD'): |
|
55 |
reboot_type = args.get('type', '')
|
|
56 |
if reboot_type not in ('SOFT', 'HARD'):
|
|
56 | 57 |
raise BadRequest() |
57 | 58 |
|
58 |
server.start_action('REBOOT')
|
|
59 |
rapi.RebootInstance(server.backend_id, type.lower()) |
|
59 |
backend.start_action(server, 'REBOOT')
|
|
60 |
rapi.RebootInstance(server.backend_id, reboot_type.lower())
|
|
60 | 61 |
return HttpResponse(status=202) |
61 | 62 |
|
62 | 63 |
@server_action('start') |
... | ... | |
64 | 65 |
# Normal Response Code: 202 |
65 | 66 |
# Error Response Codes: serviceUnavailable (503), itemNotFound (404) |
66 | 67 |
|
67 |
server.start_action('START')
|
|
68 |
backend.start_action(server, 'START')
|
|
68 | 69 |
rapi.StartupInstance(server.backend_id) |
69 | 70 |
return HttpResponse(status=202) |
70 | 71 |
|
... | ... | |
73 | 74 |
# Normal Response Code: 202 |
74 | 75 |
# Error Response Codes: serviceUnavailable (503), itemNotFound (404) |
75 | 76 |
|
76 |
server.start_action('STOP')
|
|
77 |
backend.start_action(server, 'STOP')
|
|
77 | 78 |
rapi.ShutdownInstance(server.backend_id) |
78 | 79 |
return HttpResponse(status=202) |
79 | 80 |
|
Also available in: Unified diff